aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2018-08-08 14:27:20 -0700
committerfanquake <fanquake@gmail.com>2018-08-15 10:01:01 +0800
commitdbaadc9ea92fd0e221c60584a5d1ca871fdd9c66 (patch)
tree786da17e2210b98b63198b3540e3e4dde9c71a0f
parentad6d845ac9d43aac663fa46912b49aaf837a1a9e (diff)
downloadbitcoin-dbaadc9ea92fd0e221c60584a5d1ca871fdd9c66.tar.xz
Only wipe wrong UTXO type data if overwritten by wallet
GitHub-Pull: #13917 Rebased-From: c05712c
-rw-r--r--src/wallet/rpcwallet.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp
index 4e539a85de..92e6931645 100644
--- a/src/wallet/rpcwallet.cpp
+++ b/src/wallet/rpcwallet.cpp
@@ -4504,10 +4504,11 @@ bool FillPSBT(const CWallet* pwallet, PartiallySignedTransaction& psbtx, const C
// If we don't know about this input, skip it and let someone else deal with it
const uint256& txhash = txin.prevout.hash;
- const auto& it = pwallet->mapWallet.find(txhash);
+ const auto it = pwallet->mapWallet.find(txhash);
if (it != pwallet->mapWallet.end()) {
const CWalletTx& wtx = it->second;
CTxOut utxo = wtx.tx->vout[txin.prevout.n];
+ // Update both UTXOs from the wallet.
input.non_witness_utxo = wtx.tx;
input.witness_utxo = utxo;
}
@@ -4524,11 +4525,13 @@ bool FillPSBT(const CWallet* pwallet, PartiallySignedTransaction& psbtx, const C
complete &= SignPSBTInput(PublicOnlySigningProvider(pwallet), *psbtx.tx, input, sigdata, i, sighash_type);
}
- // Drop the unnecessary UTXO
- if (sigdata.witness) {
- input.non_witness_utxo = nullptr;
- } else {
- input.witness_utxo.SetNull();
+ if (it != pwallet->mapWallet.end()) {
+ // Drop the unnecessary UTXO if we added both from the wallet.
+ if (sigdata.witness) {
+ input.non_witness_utxo = nullptr;
+ } else {
+ input.witness_utxo.SetNull();
+ }
}
// Get public key paths