Skip to content

Commit 3362a95

Browse files
author
MarcoFalke
committed
Merge #14196: [0.17][psbt] always drop the unnecessary utxo and convert non-witness utxo to witness when necessary
fcefc68 Convert non-witness UTXOs to witness if witness sig created (Andrew Chow) fcdea8a 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
2 parents 924cf79 + fcefc68 commit 3362a95

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/wallet/rpcwallet.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4534,8 +4534,15 @@ bool FillPSBT(const CWallet* pwallet, PartiallySignedTransaction& psbtx, const C
45344534
complete &= SignPSBTInput(PublicOnlySigningProvider(pwallet), *psbtx.tx, input, sigdata, i, sighash_type);
45354535
}
45364536

4537-
if (it != pwallet->mapWallet.end()) {
4538-
// Drop the unnecessary UTXO if we added both from the wallet.
4537+
if (sigdata.witness) {
4538+
// Convert the non-witness utxo to witness
4539+
if (input.witness_utxo.IsNull() && input.non_witness_utxo) {
4540+
input.witness_utxo = input.non_witness_utxo->vout[txin.prevout.n];
4541+
}
4542+
}
4543+
4544+
// If both UTXO types are present, drop the unnecessary one.
4545+
if (input.non_witness_utxo && !input.witness_utxo.IsNull()) {
45394546
if (sigdata.witness) {
45404547
input.non_witness_utxo = nullptr;
45414548
} else {

0 commit comments

Comments
 (0)