mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +01:00
psbt: hoist up psbt_add_serials, so we can use it elsewhere
We're going to use this in multifundchannel.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user