From fcdea8ad2ac1f4f55133fdf9047410631e9cc21f Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Tue, 11 Sep 2018 00:09:57 -0400 Subject: Drop the unnecessary UTXO based on the UTXOs present, not on earlier wallet things Instead of dropping the unnecessary UTXO based on whether the wallet did something, do it based on whether two UTXOs are there. --- src/wallet/rpcwallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index bb7ceb424c..96e63dac23 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4525,8 +4525,8 @@ 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 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 { -- cgit v1.2.3 From fcefc6851a624b59bd1bb42d211ce69f85969880 Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Tue, 11 Sep 2018 00:11:00 -0400 Subject: Convert non-witness UTXOs to witness if witness sig created If a witness signature was created when a non-witness UTXO is used, convert the non-witness UTXO to a witness one. --- src/wallet/rpcwallet.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 96e63dac23..b268e9a877 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4525,6 +4525,13 @@ bool FillPSBT(const CWallet* pwallet, PartiallySignedTransaction& psbtx, const C complete &= SignPSBTInput(PublicOnlySigningProvider(pwallet), *psbtx.tx, input, sigdata, i, sighash_type); } + 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) { -- cgit v1.2.3