wallet:AvailableCoins fOnlySpendable filtering flag implemented + connected to sendmany async operation.
This commit is contained in:
parent
ac792a3947
commit
e4e9712d08
|
@ -900,12 +900,9 @@ bool AsyncRPCOperation_sendmany::find_utxos(bool fAcceptCoinbase=false) {
|
||||||
|
|
||||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
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) {
|
for (const COutput& out : vecOutputs) {
|
||||||
if (!out.fSpendable) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (out.nDepth < mindepth_) {
|
if (out.nDepth < mindepth_) {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -3209,7 +3209,7 @@ CAmount CWallet::GetImmatureWatchOnlyBalance() const
|
||||||
return nTotal;
|
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();
|
vCoins.clear();
|
||||||
|
|
||||||
|
@ -3237,13 +3237,20 @@ void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < pcoin->vout.size(); i++) {
|
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]);
|
isminetype mine = IsMine(pcoin->vout[i]);
|
||||||
if (!(IsSpent(wtxid, i)) && mine != ISMINE_NO &&
|
if (!(IsSpent(wtxid, i)) && mine != ISMINE_NO &&
|
||||||
!IsLockedCoin((*it).first, i) && (pcoin->vout[i].nValue > 0 || fIncludeZeroValue) &&
|
!IsLockedCoin((*it).first, i) && (pcoin->vout[i].nValue > 0 || fIncludeZeroValue) &&
|
||||||
(!coinControl || !coinControl->HasSelected() || coinControl->fAllowOtherInputs || coinControl->IsSelected((*it).first, i)))
|
(!coinControl || !coinControl->HasSelected() || coinControl->fAllowOtherInputs || coinControl->IsSelected((*it).first, i)))
|
||||||
vCoins.push_back(COutput(pcoin, i, nDepth,
|
vCoins.push_back(COutput(pcoin, i, nDepth, isSpendable));
|
||||||
((mine & ISMINE_SPENDABLE) != ISMINE_NO) ||
|
|
||||||
(coinControl && coinControl->fAllowWatchOnly && (mine & ISMINE_WATCH_SOLVABLE) != ISMINE_NO)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1010,7 +1010,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* populate vCoins with vector of available COutputs.
|
* 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
|
* Shuffle and select coins until nTargetValue is reached while avoiding
|
||||||
|
|
Loading…
Reference in New Issue