Browse Source

psbt_open: method for adding a witness_stack to a psbt input

Set a stack of witnesses onto a PSBT input
travis-experimental
niftynei 4 years ago
committed by Rusty Russell
parent
commit
7a5a7a0ac5
  1. 12
      common/psbt_open.c
  2. 8
      common/psbt_open.h

12
common/psbt_open.c

@ -471,3 +471,15 @@ bool psbt_has_required_fields(struct wally_psbt *psbt)
return true; 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));
}

8
common/psbt_open.h

@ -14,6 +14,7 @@ struct wally_psbt;
struct wally_psbt_input; struct wally_psbt_input;
struct wally_psbt_output; struct wally_psbt_output;
struct wally_map; struct wally_map;
struct witness_element;
struct input_set { struct input_set {
struct wally_tx_input tx_input; 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); 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 */ #endif /* LIGHTNING_COMMON_PSBT_OPEN_H */

Loading…
Cancel
Save