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

Function psbt_finalize_input

common/psbt_internal.c:25–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23}
24
25void 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
53const struct witness_stack **
54psbt_to_witness_stacks(const tal_t *ctx,

Callers 1

handle_tx_sigsFunction · 0.85

Calls 4

bitcoin_scriptsig_redeemFunction · 0.85
tal_bytelenFunction · 0.85
tal_freeFunction · 0.85

Tested by

no test coverage detected