Skip to content

Commit c05712c

Browse files
committed
Only wipe wrong UTXO type data if overwritten by wallet
1 parent f87d0a9 commit c05712c

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/wallet/rpcwallet.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4504,10 +4504,11 @@ bool FillPSBT(const CWallet* pwallet, PartiallySignedTransaction& psbtx, const C
45044504

45054505
// If we don't know about this input, skip it and let someone else deal with it
45064506
const uint256& txhash = txin.prevout.hash;
4507-
const auto& it = pwallet->mapWallet.find(txhash);
4507+
const auto it = pwallet->mapWallet.find(txhash);
45084508
if (it != pwallet->mapWallet.end()) {
45094509
const CWalletTx& wtx = it->second;
45104510
CTxOut utxo = wtx.tx->vout[txin.prevout.n];
4511+
// Update both UTXOs from the wallet.
45114512
input.non_witness_utxo = wtx.tx;
45124513
input.witness_utxo = utxo;
45134514
}
@@ -4524,11 +4525,13 @@ bool FillPSBT(const CWallet* pwallet, PartiallySignedTransaction& psbtx, const C
45244525
complete &= SignPSBTInput(PublicOnlySigningProvider(pwallet), *psbtx.tx, input, sigdata, i, sighash_type);
45254526
}
45264527

4527-
// Drop the unnecessary UTXO
4528-
if (sigdata.witness) {
4529-
input.non_witness_utxo = nullptr;
4530-
} else {
4531-
input.witness_utxo.SetNull();
4528+
if (it != pwallet->mapWallet.end()) {
4529+
// Drop the unnecessary UTXO if we added both from the wallet.
4530+
if (sigdata.witness) {
4531+
input.non_witness_utxo = nullptr;
4532+
} else {
4533+
input.witness_utxo.SetNull();
4534+
}
45324535
}
45334536

45344537
// Get public key paths

0 commit comments

Comments
 (0)