diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index d6e6d38223da..7b35308332f1 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -3194,7 +3194,6 @@ UniValue listunspent(const JSONRPCRequest& request) false, // include cold staking ALL_COINS, // coin type false, // only confirmed - false, // include zero value false // use IX ); for (const COutput& out : vecOutputs) { diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 29fa4b5515b2..22f8070cd8e9 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2128,7 +2128,6 @@ bool CWallet::AvailableCoins(std::vector* pCoins, // --> populates bool fIncludeColdStaking, // Default: false AvailableCoinsType nCoinType, // Default: ALL_COINS bool fOnlyConfirmed, // Default: true - bool fIncludeZeroValue, // Default: false bool fUseIX // Default: false ) const { @@ -2153,24 +2152,32 @@ bool CWallet::AvailableCoins(std::vector* pCoins, // --> populates if (nCoinType == STAKEABLE_COINS && nDepth < Params().GetConsensus().nStakeMinDepth) continue; for (unsigned int i = 0; i < pcoin->vout.size(); i++) { - bool found = false; - if (nCoinType == ONLY_10000) { - found = pcoin->vout[i].nValue == 10000 * COIN; - } else { - found = true; - } - if (!found) continue; + // Check for only 10k utxo + if (nCoinType == ONLY_10000 && pcoin->vout[i].nValue != 10000 * COIN) continue; + + // Check for stakeable utxo if (nCoinType == STAKEABLE_COINS && pcoin->vout[i].IsZerocoinMint()) continue; + + // Check if the utxo was spent. if (IsSpent(wtxid, i)) continue; isminetype mine = IsMine(pcoin->vout[i]); - if ( (mine == ISMINE_NO) || - (mine == ISMINE_WATCH_ONLY && coinControl && !coinControl->fAllowWatchOnly) || - (IsLockedCoin((*it).first, i) && nCoinType != ONLY_10000) || - (pcoin->vout[i].nValue <= 0 && !fIncludeZeroValue) || - (fCoinsSelected && !coinControl->fAllowOtherInputs && !coinControl->IsSelected(COutPoint((*it).first, i))) - ) continue; + + // Check If not mine + if (mine == ISMINE_NO) continue; + + // Check if watch only utxo are allowed + if (mine == ISMINE_WATCH_ONLY && coinControl && !coinControl->fAllowWatchOnly) continue; + + // Skip locked utxo + if (IsLockedCoin((*it).first, i) && nCoinType != ONLY_10000) continue; + + // Check if we should include zero value utxo + if (pcoin->vout[i].nValue <= 0) continue; + + if (fCoinsSelected && !coinControl->fAllowOtherInputs && !coinControl->IsSelected(COutPoint((*it).first, i))) + continue; // --Skip P2CS outputs // skip cold coins @@ -2561,7 +2568,6 @@ bool CWallet::CreateTransaction(const std::vector& vecSend, false, // fIncludeColdStaking coin_type, true, // fOnlyConfirmed - false, // fIncludeZeroValue useIX); nFeeRet = 0; diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 2a8034048ede..9d52f6b4f47d 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -362,7 +362,6 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface bool fIncludeColdStaking = false, AvailableCoinsType nCoinType = ALL_COINS, bool fOnlyConfirmed = true, - bool fIncludeZeroValue = false, bool fUseIX = false ) const; //! >> Available coins (spending)