From a5232659bfb7f51126c48d3380085b96fa203aa1 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 26 Jun 2023 08:29:21 +0930 Subject: [PATCH] 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 --- wallet/reservation.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/wallet/reservation.c b/wallet/reservation.c index 4d3b470df..e04a4cd2d 100644 --- a/wallet/reservation.c +++ b/wallet/reservation.c @@ -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); } }