wallet:AvailableCoins fOnlySpendable filtering flag implemented + connected to sendmany async operation.

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

View File

@ -900,12 +900,9 @@ bool AsyncRPCOperation_sendmany::find_utxos(bool fAcceptCoinbase=false) {
LOCK2(cs_main, pwalletMain->cs_wallet);
pwalletMain->AvailableCoins(vecOutputs, false, NULL, true, fAcceptCoinbase);
pwalletMain->AvailableCoins(vecOutputs, false, NULL, true, fAcceptCoinbase, true);
BOOST_FOREACH(const COutput& out, vecOutputs) {
if (!out.fSpendable) {
continue;
}
for (const COutput& out : vecOutputs) {
if (out.nDepth < mindepth_) {
continue;

View File

@ -3209,7 +3209,7 @@ CAmount CWallet::GetImmatureWatchOnlyBalance() const
return nTotal;
}
void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const CCoinControl *coinControl, bool fIncludeZeroValue, bool fIncludeCoinBase) const
void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const CCoinControl *coinControl, bool fIncludeZeroValue, bool fIncludeCoinBase, bool fOnlySpendable) const
{
vCoins.clear();
@ -3237,13 +3237,20 @@ void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const
continue;
for (unsigned int i = 0; i < pcoin->vout.size(); i++) {
const auto& output = pcoin->vout[i];
isminetype mine = IsMine(output);
bool isSpendable = ((mine & ISMINE_SPENDABLE) != ISMINE_NO) ||
(coinControl && coinControl->fAllowWatchOnly && (mine & ISMINE_WATCH_SOLVABLE) != ISMINE_NO);
if (fOnlySpendable && !isSpendable)
continue;
isminetype mine = IsMine(pcoin->vout[i]);
if (!(IsSpent(wtxid, i)) && mine != ISMINE_NO &&
!IsLockedCoin((*it).first, i) && (pcoin->vout[i].nValue > 0 || fIncludeZeroValue) &&
(!coinControl || !coinControl->HasSelected() || coinControl->fAllowOtherInputs || coinControl->IsSelected((*it).first, i)))
vCoins.push_back(COutput(pcoin, i, nDepth,
((mine & ISMINE_SPENDABLE) != ISMINE_NO) ||
(coinControl && coinControl->fAllowWatchOnly && (mine & ISMINE_WATCH_SOLVABLE) != ISMINE_NO)));
vCoins.push_back(COutput(pcoin, i, nDepth, isSpendable));
}
}
}

View File

@ -1010,7 +1010,7 @@ 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) const;
void AvailableCoins(std::vector<COutput>& vCoins, bool fOnlyConfirmed=true, const CCoinControl *coinControl = NULL, bool fIncludeZeroValue=false, bool fIncludeCoinBase=true, bool fOnlySpendable=false) const;
/**
* Shuffle and select coins until nTargetValue is reached while avoiding