mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
Prevent multiple calls to CWallet::AvailableCoins
This commit is contained in:
parent
c946a15075
commit
bb16c8894b
@ -1841,10 +1841,9 @@ 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) 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;
|
vector<COutput> vCoins(vAvailableCoins);
|
||||||
AvailableCoins(vCoins, true, coinControl);
|
|
||||||
|
|
||||||
// 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)
|
||||||
@ -2010,6 +2009,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);
|
||||||
|
|
||||||
nFeeRet = 0;
|
nFeeRet = 0;
|
||||||
// Start with no fee and loop until there is enough fee
|
// Start with no fee and loop until there is enough fee
|
||||||
while (true)
|
while (true)
|
||||||
@ -2059,7 +2061,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
|
|||||||
// Choose coins to use
|
// Choose coins to use
|
||||||
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))
|
if (!SelectCoins(vAvailableCoins, nValueToSelect, setCoins, nValueIn, coinControl))
|
||||||
{
|
{
|
||||||
strFailReason = _("Insufficient funds");
|
strFailReason = _("Insufficient funds");
|
||||||
return false;
|
return false;
|
||||||
|
@ -544,7 +544,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) 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;
|
CWalletDB *pwalletdbEncryption;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user