| 23 | } |
| 24 | |
| 25 | void psbt_finalize_input(const tal_t *ctx, |
| 26 | struct wally_psbt_input *in, |
| 27 | const struct witness_element **elements) |
| 28 | { |
| 29 | psbt_input_set_final_witness_stack(ctx, in, elements); |
| 30 | |
| 31 | /* There's this horrible edgecase where we set the final_witnesses |
| 32 | * directly onto the PSBT, but the input is a P2SH-wrapped input |
| 33 | * (which has redeemscripts that belong in the scriptsig). Because |
| 34 | * of how the internal libwally stuff works calling 'finalize' |
| 35 | * on these just .. ignores it!? Murder. Anyway, here we do a final |
| 36 | * scriptsig check -- if there's a redeemscript field still around we |
| 37 | * just go ahead and mush it into the final_scriptsig field. */ |
| 38 | if (in->redeem_script) { |
| 39 | u8 *redeemscript = tal_dup_arr(NULL, u8, |
| 40 | in->redeem_script, |
| 41 | in->redeem_script_len, 0); |
| 42 | in->final_scriptsig = |
| 43 | bitcoin_scriptsig_redeem(NULL, |
| 44 | take(redeemscript)); |
| 45 | in->final_scriptsig_len = |
| 46 | tal_bytelen(in->final_scriptsig); |
| 47 | |
| 48 | in->redeem_script = tal_free(in->redeem_script); |
| 49 | in->redeem_script_len = 0; |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | const struct witness_stack ** |
| 54 | psbt_to_witness_stacks(const tal_t *ctx, |
no test coverage detected