Skip to content

Commit

Permalink
Only wipe wrong UTXO type data if overwritten by wallet
Browse files Browse the repository at this point in the history
GitHub-Pull: bitcoin#13917
Rebased-From: c05712c
  • Loading branch information
sipa authored and Michael Polzer committed Sep 14, 2018
1 parent f108a9f commit 34bf962
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/wallet/rpcwallet.cpp
Expand Up @@ -4527,10 +4527,11 @@ bool FillPSCT(const CWallet* pwallet, PartiallySignedTransaction& psctx, 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;
}
Expand All @@ -4547,11 +4548,13 @@ bool FillPSCT(const CWallet* pwallet, PartiallySignedTransaction& psctx, const C
complete &= SignPSCTInput(PublicOnlySigningProvider(pwallet), *psctx.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
Expand Down

0 comments on commit 34bf962

Please sign in to comment.