diff --git a/src/darksend.cpp b/src/darksend.cpp index 27cf88350..795ce10db 100644 --- a/src/darksend.cpp +++ b/src/darksend.cpp @@ -1855,8 +1855,10 @@ bool CDarksendPool::CreateDenominated() return false; } + bool fCreateMixingCollaterals = !pwalletMain->HasCollateralInputs(); + BOOST_FOREACH(CompactTallyItem& item, vecTally) { - if(!CreateDenominated(item)) continue; + if(!CreateDenominated(item, fCreateMixingCollaterals)) continue; return true; } @@ -1865,7 +1867,7 @@ bool CDarksendPool::CreateDenominated() } // Create denominations -bool CDarksendPool::CreateDenominated(const CompactTallyItem& tallyItem) +bool CDarksendPool::CreateDenominated(const CompactTallyItem& tallyItem, bool fCreateMixingCollaterals) { std::vector vecSend; CAmount nValueLeft = tallyItem.nAmount; @@ -1882,7 +1884,7 @@ bool CDarksendPool::CreateDenominated(const CompactTallyItem& tallyItem) // ****** Add collateral outputs ************ / - if(!pwalletMain->HasCollateralInputs()) { + if(fCreateMixingCollaterals) { vecSend.push_back((CRecipient){scriptCollateral, PRIVATESEND_COLLATERAL*4, false}); nValueLeft -= PRIVATESEND_COLLATERAL*4; } diff --git a/src/darksend.h b/src/darksend.h index 549d74989..179aea537 100644 --- a/src/darksend.h +++ b/src/darksend.h @@ -382,7 +382,7 @@ private: /// Create denominations bool CreateDenominated(); - bool CreateDenominated(const CompactTallyItem& tallyItem); + bool CreateDenominated(const CompactTallyItem& tallyItem, bool fCreateMixingCollaterals); /// Split up large inputs or make fee sized inputs bool MakeCollateralAmounts(); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 1fba05b73..e3bae0cf2 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2118,6 +2118,8 @@ void CWallet::AvailableCoins(vector& vCoins, bool fOnlyConfirmed, const if(found && fMasterNode) found = pcoin->vout[i].nValue != 1000*COIN; // do not use Hot MN funds } else if(nCoinType == ONLY_1000) { found = pcoin->vout[i].nValue == 1000*COIN; + } else if(nCoinType == ONLY_PRIVATESEND_COLLATERAL) { + found = IsCollateralAmount(pcoin->vout[i].nValue); } else { found = true; } @@ -2781,12 +2783,9 @@ int CWallet::CountInputsWithAmount(CAmount nInputAmount) bool CWallet::HasCollateralInputs(bool fOnlyConfirmed) const { vector vCoins; - AvailableCoins(vCoins, fOnlyConfirmed); + AvailableCoins(vCoins, fOnlyConfirmed, NULL, false, ONLY_PRIVATESEND_COLLATERAL); - BOOST_FOREACH(const COutput& out, vCoins) - if(IsCollateralAmount(out.tx->vout[out.i].nValue)) return true; - - return false; + return !vCoins.empty(); } bool CWallet::IsCollateralAmount(CAmount nInputAmount) const diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 149b5bac2..e039d0155 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -97,7 +97,8 @@ enum AvailableCoinsType ONLY_DENOMINATED = 2, ONLY_NOT1000IFMN = 3, ONLY_NONDENOMINATED_NOT1000IFMN = 4, - ONLY_1000 = 5 // find masternode outputs including locked ones (use with caution) + ONLY_1000 = 5, // find masternode outputs including locked ones (use with caution) + ONLY_PRIVATESEND_COLLATERAL = 6 }; struct CompactTallyItem