Update wallet.cpp

This commit is contained in:
saizsassin 2018-05-10 01:07:55 +05:30 committed by GitHub
parent 9f55bae05c
commit 38202a0953
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,27 +1,10 @@
Skip to content
All gists
GitHub
New gist
Please verify your email address to access all of GitHubs features.
An email containing verification instructions was sent to sairaj.leo@gmail.com.
0
@saizsassin saizsassin/wallet.cpp
Created 40 minutes ago
Code
Revisions 1
wallet.cpp
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2016 The Bitcoin Core developers // Copyright (c) 2009-2016 The Bitcoin Core developers
// Copyright (c) Flo Developers 2013-2018 // Copyright (c) Flo Developers 2013-2018
// Distributed under the MIT software license, see the accompanying // Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <iostream>
#include "wallet/wallet.h" #include "wallet/wallet.h"
#include <algorithm> #include <algorithm>
#include "base58.h" #include "base58.h"
@ -2475,8 +2458,19 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, const int nConfMin
bool CWallet::SelectCoins(const std::vector<COutput>& vAvailableCoins, const CAmount& nTargetValue, std::set<CInputCoin>& setCoinsRet, CAmount& nValueRet, const CCoinControl* coinControl) const bool CWallet::SelectCoins(const std::vector<COutput>& vAvailableCoins, const CAmount& nTargetValue, std::set<CInputCoin>& setCoinsRet, CAmount& nValueRet, const CCoinControl* coinControl) const
{ {
std::vector<COutput> vCoins(vAvailableCoins); std::vector<COutput> vCoinsTmp(vAvailableCoins);
std::vector<COutput>::iterator it;
std::set<unsigned int> time;
for(it=vCoinsTmp.begin();it!=vCoinsTmp.end();it++)
time.insert(it->tx->nTimeReceived);
std::vector<COutput> vCoins;
vCoins.clear();
for(std::set<unsigned int>::iterator its = time.begin();its!=time.end();its++)
for(it=vCoinsTmp.begin();it!=vCoinsTmp.end();it++)
if(it->tx->nTimeReceived == *its)
vCoins.push_back(*it);
// 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)
{ {
@ -2493,6 +2487,7 @@ bool CWallet::SelectCoins(const std::vector<COutput>& vAvailableCoins, const CAm
// calculate value from preset inputs and store them // calculate value from preset inputs and store them
std::vector<CInputCoin> setPresetCoins; std::vector<CInputCoin> setPresetCoins;
CAmount nValueFromPresetInputs = 0; CAmount nValueFromPresetInputs = 0;
setPresetCoins.clear();
std::vector<COutPoint> vPresetInputs; std::vector<COutPoint> vPresetInputs;
if (coinControl) if (coinControl)
@ -2511,6 +2506,7 @@ bool CWallet::SelectCoins(const std::vector<COutput>& vAvailableCoins, const CAm
} else } else
return false; // TODO: Allow non-wallet inputs return false; // TODO: Allow non-wallet inputs
} }
// remove preset inputs from vCoins // remove preset inputs from vCoins
for (std::vector<COutput>::iterator it = vCoins.begin(); it != vCoins.end() && coinControl && coinControl->HasSelected();) for (std::vector<COutput>::iterator it = vCoins.begin(); it != vCoins.end() && coinControl && coinControl->HasSelected();)
@ -2520,7 +2516,7 @@ bool CWallet::SelectCoins(const std::vector<COutput>& vAvailableCoins, const CAm
else else
++it; ++it;
} }
setCoinsRet.clear(); setCoinsRet.clear();
setCoinsRet.insert(setPresetCoins.begin(), setPresetCoins.end()); setCoinsRet.insert(setPresetCoins.begin(), setPresetCoins.end());
nValueRet = nValueFromPresetInputs; nValueRet = nValueFromPresetInputs;
@ -4369,25 +4365,3 @@ bool CMerkleTx::AcceptToMemoryPool(const CAmount& nAbsurdFee, CValidationState&
{ {
return ::AcceptToMemoryPool(mempool, state, tx, true, nullptr, nullptr, false, nAbsurdFee); return ::AcceptToMemoryPool(mempool, state, tx, true, nullptr, nullptr, false, nAbsurdFee);
} }
@saizsassin
Attach files by dragging & dropping,
, or pasting from the clipboard.
Styling with Markdown is supported
© 2018 GitHub, Inc.
Terms
Privacy
Security
Status
Help
Contact GitHub
API
Training
Shop
Blog
About
Press h to open a hovercard with more details.