Browse Source

psbt_txid: it's possible a psbt may already have the finalized scriptsig

If we've already got a scriptSig field filled out for a PSBT input, we
use that instead of 'deriving' the scriptSig from the redeemscript
(finalizing a PSBT removes the redeemscript field)
travis-experimental
niftynei 4 years ago
committed by Rusty Russell
parent
commit
1f165c00ae
  1. 24
      bitcoin/psbt.c

24
bitcoin/psbt.c

@ -748,16 +748,20 @@ void psbt_txid(const tal_t *ctx,
wally_tx_clone_alloc(psbt->tx, 0, &tx);
for (size_t i = 0; i < tx->num_inputs; i++) {
u8 *script;
if (!psbt->inputs[i].redeem_script)
continue;
/* P2SH requires push of the redeemscript, from libwally src */
script = tal_arr(tmpctx, u8, 0);
script_push_bytes(&script,
psbt->inputs[i].redeem_script,
psbt->inputs[i].redeem_script_len);
wally_tx_set_input_script(tx, i, script, tal_bytelen(script));
if (psbt->inputs[i].final_scriptsig) {
wally_tx_set_input_script(tx, i,
psbt->inputs[i].final_scriptsig,
psbt->inputs[i].final_scriptsig_len);
} else if (psbt->inputs[i].redeem_script) {
u8 *script;
/* P2SH requires push of the redeemscript, from libwally src */
script = tal_arr(tmpctx, u8, 0);
script_push_bytes(&script,
psbt->inputs[i].redeem_script,
psbt->inputs[i].redeem_script_len);
wally_tx_set_input_script(tx, i, script, tal_bytelen(script));
}
}
tal_gather_wally(tal_steal(ctx, tx));

Loading…
Cancel
Save