diff --git a/common/psbt_open.c b/common/psbt_open.c index 7874a6e30..66f4f70be 100644 --- a/common/psbt_open.c +++ b/common/psbt_open.c @@ -584,3 +584,25 @@ bool psbt_side_finalized(const struct wally_psbt *psbt, enum tx_role role) } return true; } + +/* Adds serials to inputs + outputs that don't have one yet */ +void psbt_add_serials(struct wally_psbt *psbt, enum tx_role role) +{ + u16 serial_id; + for (size_t i = 0; i < psbt->num_inputs; i++) { + /* Skip ones that already have a serial id */ + if (psbt_get_serial_id(&psbt->inputs[i].unknowns, &serial_id)) + continue; + + serial_id = psbt_new_input_serial(psbt, role); + psbt_input_set_serial_id(psbt, &psbt->inputs[i], serial_id); + } + for (size_t i = 0; i < psbt->num_outputs; i++) { + /* Skip ones that already have a serial id */ + if (psbt_get_serial_id(&psbt->outputs[i].unknowns, &serial_id)) + continue; + + serial_id = psbt_new_output_serial(psbt, role); + psbt_output_set_serial_id(psbt, &psbt->outputs[i], serial_id); + } +} diff --git a/common/psbt_open.h b/common/psbt_open.h index 73e4bba63..0da44b1c5 100644 --- a/common/psbt_open.h +++ b/common/psbt_open.h @@ -183,4 +183,15 @@ psbt_to_witness_stacks(const tal_t *ctx, /* psbt_side_finalized - True if designated role has all signature data */ bool psbt_side_finalized(const struct wally_psbt *psbt, enum tx_role role); + +/* psbt_add_serials - Add serials to inputs/outputs that are missing them + * + * Adds a serial of the correct parity for the designated {role} to all + * inputs and outputs of this PSBT that do not currently have a serial_id + * set. + * + * @psbt - the psbt to add serials to + * @role - the role we should use to select serial parity + */ +void psbt_add_serials(struct wally_psbt *psbt, enum tx_role role); #endif /* LIGHTNING_COMMON_PSBT_OPEN_H */ diff --git a/lightningd/dual_open_control.c b/lightningd/dual_open_control.c index 91a7d3552..45bfee147 100644 --- a/lightningd/dual_open_control.c +++ b/lightningd/dual_open_control.c @@ -332,28 +332,6 @@ static bool psbt_side_contribs_changed(struct wally_psbt *orig, return false; } -/* Adds serials to inputs + outputs that don't have one yet */ -static void psbt_add_serials(struct wally_psbt *psbt, enum tx_role role) -{ - u16 serial_id; - for (size_t i = 0; i < psbt->num_inputs; i++) { - /* Skip ones that already have a serial id */ - if (psbt_get_serial_id(&psbt->inputs[i].unknowns, &serial_id)) - continue; - - serial_id = psbt_new_input_serial(psbt, role); - psbt_input_set_serial_id(psbt, &psbt->inputs[i], serial_id); - } - for (size_t i = 0; i < psbt->num_outputs; i++) { - /* Skip ones that already have a serial id */ - if (psbt_get_serial_id(&psbt->outputs[i].unknowns, &serial_id)) - continue; - - serial_id = psbt_new_output_serial(psbt, role); - psbt_output_set_serial_id(psbt, &psbt->outputs[i], serial_id); - } -} - /* dualopend dies? Remove dualopend ptr from payload */ static void openchannel2_remove_dualopend(struct subd *dualopend, struct openchannel2_payload *payload)