diff options
author | João Barbosa <joao@uphold.com> | 2016-03-08 00:15:17 +0000 |
---|---|---|
committer | João Barbosa <joao@uphold.com> | 2016-03-22 08:43:37 +0000 |
commit | bb16c8894becfba8764b13d448ba6e7e7f1608c2 (patch) | |
tree | 530fdb3d0eca0d2d707c41870fc248841a386097 | |
parent | c946a15075ba5a2da74a08bb5575391541196475 (diff) |
Prevent multiple calls to CWallet::AvailableCoins
-rw-r--r-- | src/wallet/wallet.cpp | 10 | ||||
-rw-r--r-- | src/wallet/wallet.h | 2 |
2 files changed, 7 insertions, 5 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 654e617071..51a2ad78d7 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1841,10 +1841,9 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int return true; } -bool CWallet::SelectCoins(const CAmount& nTargetValue, set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, CAmount& nValueRet, const CCoinControl* coinControl) const +bool CWallet::SelectCoins(const vector<COutput>& vAvailableCoins, const CAmount& nTargetValue, set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, CAmount& nValueRet, const CCoinControl* coinControl) const { - vector<COutput> vCoins; - AvailableCoins(vCoins, true, coinControl); + vector<COutput> vCoins(vAvailableCoins); // coin control -> return all selected outputs (we want all selected to go into the transaction for sure) if (coinControl && coinControl->HasSelected() && !coinControl->fAllowOtherInputs) @@ -2010,6 +2009,9 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt { LOCK2(cs_main, cs_wallet); { + std::vector<COutput> vAvailableCoins; + AvailableCoins(vAvailableCoins, true, coinControl); + nFeeRet = 0; // Start with no fee and loop until there is enough fee while (true) @@ -2059,7 +2061,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt // Choose coins to use set<pair<const CWalletTx*,unsigned int> > setCoins; CAmount nValueIn = 0; - if (!SelectCoins(nValueToSelect, setCoins, nValueIn, coinControl)) + if (!SelectCoins(vAvailableCoins, nValueToSelect, setCoins, nValueIn, coinControl)) { strFailReason = _("Insufficient funds"); return false; diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index d009211a92..e37d972a15 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -544,7 +544,7 @@ private: * all coins from coinControl are selected; Never select unconfirmed coins * 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) 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) const; CWalletDB *pwalletdbEncryption; |