mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Merge #7649: Prevent multiple calls to CWallet::AvailableCoins
bb16c88
Prevent multiple calls to CWallet::AvailableCoins (João Barbosa)
This commit is contained in:
parent
aa584522da
commit
74fe8fe598
@ -2614,12 +2614,11 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CWallet::SelectCoins(const CAmount& nTargetValue, set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, CAmount& nValueRet, const CCoinControl* coinControl, AvailableCoinsType nCoinType, bool fUseInstantSend) const
|
bool CWallet::SelectCoins(const vector<COutput>& vAvailableCoins, const CAmount& nTargetValue, set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, CAmount& nValueRet, const CCoinControl* coinControl, AvailableCoinsType nCoinType, bool fUseInstantSend) const
|
||||||
{
|
{
|
||||||
// Note: this function should never be used for "always free" tx types like dstx
|
// Note: this function should never be used for "always free" tx types like dstx
|
||||||
|
|
||||||
vector<COutput> vCoins;
|
vector<COutput> vCoins(vAvailableCoins);
|
||||||
AvailableCoins(vCoins, true, coinControl, false, nCoinType, fUseInstantSend);
|
|
||||||
|
|
||||||
// coin control -> return all selected outputs (we want all selected to go into the transaction for sure)
|
// coin control -> return all selected outputs (we want all selected to go into the transaction for sure)
|
||||||
if (coinControl && coinControl->HasSelected() && !coinControl->fAllowOtherInputs)
|
if (coinControl && coinControl->HasSelected() && !coinControl->fAllowOtherInputs)
|
||||||
@ -3218,6 +3217,9 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
|
|||||||
{
|
{
|
||||||
LOCK2(cs_main, cs_wallet);
|
LOCK2(cs_main, cs_wallet);
|
||||||
{
|
{
|
||||||
|
std::vector<COutput> vAvailableCoins;
|
||||||
|
AvailableCoins(vAvailableCoins, true, coinControl, false, nCoinType, fUseInstantSend);
|
||||||
|
|
||||||
nFeeRet = 0;
|
nFeeRet = 0;
|
||||||
if(nFeePay > 0) nFeeRet = nFeePay;
|
if(nFeePay > 0) nFeeRet = nFeePay;
|
||||||
// Start with no fee and loop until there is enough fee
|
// Start with no fee and loop until there is enough fee
|
||||||
@ -3269,7 +3271,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
|
|||||||
set<pair<const CWalletTx*,unsigned int> > setCoins;
|
set<pair<const CWalletTx*,unsigned int> > setCoins;
|
||||||
CAmount nValueIn = 0;
|
CAmount nValueIn = 0;
|
||||||
|
|
||||||
if (!SelectCoins(nValueToSelect, setCoins, nValueIn, coinControl, nCoinType, fUseInstantSend))
|
if (!SelectCoins(vAvailableCoins, nValueToSelect, setCoins, nValueIn, coinControl, nCoinType, fUseInstantSend))
|
||||||
{
|
{
|
||||||
if (nCoinType == ONLY_NONDENOMINATED) {
|
if (nCoinType == ONLY_NONDENOMINATED) {
|
||||||
strFailReason = _("Unable to locate enough PrivateSend non-denominated funds for this transaction.");
|
strFailReason = _("Unable to locate enough PrivateSend non-denominated funds for this transaction.");
|
||||||
|
@ -610,7 +610,7 @@ private:
|
|||||||
* all coins from coinControl are selected; Never select unconfirmed coins
|
* all coins from coinControl are selected; Never select unconfirmed coins
|
||||||
* if they are not ours
|
* if they are not ours
|
||||||
*/
|
*/
|
||||||
bool SelectCoins(const CAmount& nTargetValue, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, CAmount& nValueRet, const CCoinControl *coinControl = NULL, AvailableCoinsType nCoinType=ALL_COINS, bool fUseInstantSend = true) const;
|
bool SelectCoins(const std::vector<COutput>& vAvailableCoins, const CAmount& nTargetValue, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, CAmount& nValueRet, const CCoinControl *coinControl = NULL, AvailableCoinsType nCoinType=ALL_COINS, bool fUseInstantSend = true) const;
|
||||||
|
|
||||||
CWalletDB *pwalletdbEncryption;
|
CWalletDB *pwalletdbEncryption;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user