| 87 | } |
| 88 | |
| 89 | void psbt_finalize_input(const tal_t *ctx, |
| 90 | struct wally_psbt_input *in, |
| 91 | const struct witness *witness) |
| 92 | { |
| 93 | const struct wally_map_item *redeem_script; |
| 94 | psbt_input_set_final_witness_stack(ctx, in, witness); |
| 95 | |
| 96 | /* There's this horrible edgecase where we set the final_witnesses |
| 97 | * directly onto the PSBT, but the input is a P2SH-wrapped input |
| 98 | * (which has redeemscripts that belong in the scriptsig). Because |
| 99 | * of how the internal libwally stuff works calling 'finalize' |
| 100 | * on these just .. ignores it!? Murder. Anyway, here we do a final |
| 101 | * scriptsig check -- if there's a redeemscript field still around we |
| 102 | * just go ahead and mush it into the final_scriptsig field. */ |
| 103 | redeem_script = wally_map_get_integer(&in->psbt_fields, /* PSBT_IN_REDEEM_SCRIPT */ 0x04); |
| 104 | if (redeem_script) { |
| 105 | u8 *redeemscript = tal_dup_arr(NULL, u8, |
| 106 | redeem_script->value, |
| 107 | redeem_script->value_len, 0); |
| 108 | u8 *final_scriptsig = |
| 109 | bitcoin_scriptsig_redeem(ctx, |
| 110 | take(redeemscript)); |
| 111 | tal_wally_start(); |
| 112 | wally_psbt_input_set_final_scriptsig(in, final_scriptsig, tal_bytelen(final_scriptsig)); |
| 113 | wally_psbt_input_set_redeem_script(in, tal_arr(in, u8, 0), 0); |
| 114 | tal_wally_end(ctx); |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | const struct witness ** |
| 119 | psbt_to_witnesses(const tal_t *ctx, |
no test coverage detected