| 143 | } |
| 144 | |
| 145 | void psbt_finalize_input(const tal_t *ctx, |
| 146 | struct wally_psbt_input *in, |
| 147 | const struct witness *witness) |
| 148 | { |
| 149 | const struct wally_map_item *redeem_script; |
| 150 | psbt_input_set_final_witness_stack(ctx, in, witness); |
| 151 | |
| 152 | /* There's this horrible edgecase where we set the final_witnesses |
| 153 | * directly onto the PSBT, but the input is a P2SH-wrapped input |
| 154 | * (which has redeemscripts that belong in the scriptsig). Because |
| 155 | * of how the internal libwally stuff works calling 'finalize' |
| 156 | * on these just .. ignores it!? Murder. Anyway, here we do a final |
| 157 | * scriptsig check -- if there's a redeemscript field still around we |
| 158 | * just go ahead and mush it into the final_scriptsig field. */ |
| 159 | redeem_script = wally_map_get_integer(&in->psbt_fields, /* PSBT_IN_REDEEM_SCRIPT */ 0x04); |
| 160 | if (redeem_script) { |
| 161 | u8 *redeemscript = tal_dup_arr(NULL, u8, |
| 162 | redeem_script->value, |
| 163 | redeem_script->value_len, 0); |
| 164 | u8 *final_scriptsig = |
| 165 | bitcoin_scriptsig_redeem(ctx, |
| 166 | take(redeemscript)); |
| 167 | tal_wally_start(); |
| 168 | wally_psbt_input_set_final_scriptsig(in, final_scriptsig, tal_bytelen(final_scriptsig)); |
| 169 | wally_psbt_input_set_redeem_script(in, tal_arr(in, u8, 0), 0); |
| 170 | tal_wally_end(ctx); |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | const struct witness ** |
| 175 | psbt_to_witnesses(const tal_t *ctx, |
no test coverage detected