aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2018-12-01 12:31:12 -0500
committerMarcoFalke <falke.marco@gmail.com>2018-12-01 12:31:14 -0500
commit3362a95be360dd798c32fc0184c0fe67da6ef43a (patch)
tree59c19ab6de01fa8cddc164445fc573034d6b68ce
parent924cf794e1f45993213b72aea3704b151eb10b8d (diff)
parentfcefc6851a624b59bd1bb42d211ce69f85969880 (diff)
downloadbitcoin-3362a95be360dd798c32fc0184c0fe67da6ef43a.tar.xz
Merge #14196: [0.17][psbt] always drop the unnecessary utxo and convert non-witness utxo to witness when necessary
fcefc6851a Convert non-witness UTXOs to witness if witness sig created (Andrew Chow) fcdea8ad2a Drop the unnecessary UTXO based on the UTXOs present, not on earlier wallet things (Andrew Chow) Pull request description: When we sign an input in a psbt that has a non-witness utxo but a witness signature is produced, we will now replace the non-witness utxo with the corresponding witness utxo. Furthermore, we should make sure that the correct UTXO type is used based on what UTXOs are there, not based on earlier wallet behavior. Note that this is PR'd to the 0.17 branch because the code here no longer exists in master. Tree-SHA512: 882e9e4e9b77d6ac1743c35c0d59023aad6f4f19193398f97f2c6b81f6627d74e5220b1d674a0edba1ff2fc2a7f61afbf838d3faf0a964fccd3dee97c631aa47
-rw-r--r--src/wallet/rpcwallet.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp
index 9ddd21126a..0a9242327b 100644
--- a/src/wallet/rpcwallet.cpp
+++ b/src/wallet/rpcwallet.cpp
@@ -4534,8 +4534,15 @@ bool FillPSBT(const CWallet* pwallet, PartiallySignedTransaction& psbtx, const C
complete &= SignPSBTInput(PublicOnlySigningProvider(pwallet), *psbtx.tx, input, sigdata, i, sighash_type);
}
- if (it != pwallet->mapWallet.end()) {
- // Drop the unnecessary UTXO if we added both from the wallet.
+ if (sigdata.witness) {
+ // Convert the non-witness utxo to witness
+ if (input.witness_utxo.IsNull() && input.non_witness_utxo) {
+ input.witness_utxo = input.non_witness_utxo->vout[txin.prevout.n];
+ }
+ }
+
+ // If both UTXO types are present, drop the unnecessary one.
+ if (input.non_witness_utxo && !input.witness_utxo.IsNull()) {
if (sigdata.witness) {
input.non_witness_utxo = nullptr;
} else {