wallet: fix psbt_using_utxos when used with base PSBT.

We were setting the wrong input number: don't assume it's the
same as the UTXO number, but simply the last-appended input.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2023-06-26 08:29:21 +09:30
parent 3b1652842e
commit a5232659bf

View File

@@ -314,7 +314,8 @@ struct wally_psbt *psbt_using_utxos(const tal_t *ctx,
this_nsequence, scriptSig,
NULL, redeemscript);
psbt_input_set_wit_utxo(psbt, i, scriptPubkey, utxos[i]->amount);
psbt_input_set_wit_utxo(psbt, psbt->num_inputs-1,
scriptPubkey, utxos[i]->amount);
if (is_elements(chainparams)) {
/* FIXME: persist asset tags */
amount_sat_to_asset(&utxos[i]->amount,
@@ -334,7 +335,7 @@ struct wally_psbt *psbt_using_utxos(const tal_t *ctx,
tx = wallet_transaction_get(ctx, wallet,
&utxos[i]->outpoint.txid);
if (tx)
psbt_input_set_utxo(psbt, i, tx->wtx);
psbt_input_set_utxo(psbt, psbt->num_inputs-1, tx->wtx);
}
}