psbt_open: method for adding a witness_stack to a psbt input

Set a stack of witnesses onto a PSBT input
This commit is contained in:
niftynei 2020-09-10 14:11:21 -05:00 committed by Rusty Russell
parent 82c0b48215
commit 7a5a7a0ac5
2 changed files with 20 additions and 0 deletions

View file

@ -471,3 +471,15 @@ bool psbt_has_required_fields(struct wally_psbt *psbt)
return true;
}
void psbt_input_set_final_witness_stack(struct wally_psbt_input *in,
const struct witness_element **elements)
{
wally_tx_witness_stack_init_alloc(tal_count(elements),
&in->final_witness);
for (size_t i = 0; i < tal_count(elements); i++)
wally_tx_witness_stack_add(in->final_witness,
elements[i]->witness,
tal_bytelen(elements[i]->witness));
}

View file

@ -14,6 +14,7 @@ struct wally_psbt;
struct wally_psbt_input;
struct wally_psbt_output;
struct wally_map;
struct witness_element;
struct input_set {
struct wally_tx_input tx_input;
@ -140,4 +141,11 @@ int psbt_find_serial_output(struct wally_psbt *psbt, u16 serial_id);
*/
bool psbt_has_required_fields(struct wally_psbt *psbt);
/* psbt_input_set_final_witness_stack - Set the witness stack for PSBT input
*
* @in - input to set final_witness for
* @witness_element - elements to add to witness stack
*/
void psbt_input_set_final_witness_stack(struct wally_psbt_input *in,
const struct witness_element **elements);
#endif /* LIGHTNING_COMMON_PSBT_OPEN_H */