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)
This commit is contained in:
niftynei 2020-09-10 13:29:21 -05:00 committed by Rusty Russell
parent c5f748e716
commit 1f165c00ae

View file

@ -748,9 +748,12 @@ 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++) {
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;
if (!psbt->inputs[i].redeem_script)
continue;
/* P2SH requires push of the redeemscript, from libwally src */
script = tal_arr(tmpctx, u8, 0);
@ -759,6 +762,7 @@ void psbt_txid(const tal_t *ctx,
psbt->inputs[i].redeem_script_len);
wally_tx_set_input_script(tx, i, script, tal_bytelen(script));
}
}
tal_gather_wally(tal_steal(ctx, tx));
wally_txid(tx, txid);