| 35 | } |
| 36 | |
| 37 | struct wally_psbt *create_psbt(const tal_t *ctx, size_t num_inputs, size_t num_outputs, u32 locktime) |
| 38 | { |
| 39 | int wally_err; |
| 40 | struct wally_tx *wtx; |
| 41 | struct wally_psbt *psbt; |
| 42 | |
| 43 | tal_wally_start(); |
| 44 | if (wally_tx_init_alloc(WALLY_TX_VERSION_2, locktime, num_inputs, num_outputs, &wtx) != WALLY_OK) |
| 45 | abort(); |
| 46 | /* wtx is freed below */ |
| 47 | tal_wally_end(NULL); |
| 48 | |
| 49 | psbt = init_psbt(ctx, num_inputs, num_outputs); |
| 50 | |
| 51 | tal_wally_start(); |
| 52 | wally_err = wally_psbt_set_global_tx(psbt, wtx); |
| 53 | assert(wally_err == WALLY_OK); |
| 54 | tal_wally_end(psbt); |
| 55 | |
| 56 | wally_tx_free(wtx); |
| 57 | return psbt; |
| 58 | } |
| 59 | |
| 60 | struct wally_psbt *clone_psbt(const tal_t *ctx, struct wally_psbt *psbt) |
| 61 | { |