wallet:AvailableCoins nMinDepth filter implemented + connected to sendmany async operation.

This commit is contained in:
furszy 2020-10-31 22:47:12 -03:00
parent e4e9712d08
commit fbfb2c0339
No known key found for this signature in database
GPG Key ID: 5DD23CCC686AA623
3 changed files with 11 additions and 8 deletions

View File

@ -900,14 +900,10 @@ bool AsyncRPCOperation_sendmany::find_utxos(bool fAcceptCoinbase=false) {
LOCK2(cs_main, pwalletMain->cs_wallet);
pwalletMain->AvailableCoins(vecOutputs, false, NULL, true, fAcceptCoinbase, true);
pwalletMain->AvailableCoins(vecOutputs, false, NULL, true, fAcceptCoinbase, true, mindepth_);
for (const COutput& out : vecOutputs) {
if (out.nDepth < mindepth_) {
continue;
}
if (destinations.size()) {
CTxDestination address;
if (!ExtractDestination(out.tx->vout[out.i].scriptPubKey, address)) {

View File

@ -3209,8 +3209,9 @@ CAmount CWallet::GetImmatureWatchOnlyBalance() const
return nTotal;
}
void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const CCoinControl *coinControl, bool fIncludeZeroValue, bool fIncludeCoinBase, bool fOnlySpendable) const
void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const CCoinControl *coinControl, bool fIncludeZeroValue, bool fIncludeCoinBase, bool fOnlySpendable, int nMinDepth) const
{
assert(nMinDepth >= 0);
vCoins.clear();
{
@ -3233,7 +3234,7 @@ void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const
continue;
int nDepth = pcoin->GetDepthInMainChain();
if (nDepth < 0)
if (nDepth < nMinDepth)
continue;
for (unsigned int i = 0; i < pcoin->vout.size(); i++) {

View File

@ -1010,7 +1010,13 @@ public:
/**
* populate vCoins with vector of available COutputs.
*/
void AvailableCoins(std::vector<COutput>& vCoins, bool fOnlyConfirmed=true, const CCoinControl *coinControl = NULL, bool fIncludeZeroValue=false, bool fIncludeCoinBase=true, bool fOnlySpendable=false) const;
void AvailableCoins(std::vector<COutput>& vCoins,
bool fOnlyConfirmed=true,
const CCoinControl *coinControl = NULL,
bool fIncludeZeroValue=false,
bool fIncludeCoinBase=true,
bool fOnlySpendable=false,
int nMinDepth = 0) const;
/**
* Shuffle and select coins until nTargetValue is reached while avoiding