MCPcopy Create free account
hub / github.com/ElementsProject/lightning / psbt_finalize_input

Function psbt_finalize_input

common/psbt_internal.c:89–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87}
88
89void 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
118const struct witness **
119psbt_to_witnesses(const tal_t *ctx,

Callers 2

handle_tx_sigsFunction · 0.85

Calls 5

bitcoin_scriptsig_redeemFunction · 0.85
tal_wally_startFunction · 0.85
tal_bytelenFunction · 0.85
tal_wally_endFunction · 0.85

Tested by

no test coverage detected