Skip to content

Commit 219953c

Browse files
committed
Show zero value txouts in listunspent.
It's reasonable that automatic coin selection will not pick a zero value txout, but they're actually spendable; and you should know if you have them. Listing also makes them available to tools like dust-b-gone.
1 parent b6ea3bc commit 219953c

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/wallet/rpcwallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2301,7 +2301,7 @@ Value listunspent(const Array& params, bool fHelp)
23012301
vector<COutput> vecOutputs;
23022302
assert(pwalletMain != NULL);
23032303
LOCK2(cs_main, pwalletMain->cs_wallet);
2304-
pwalletMain->AvailableCoins(vecOutputs, false);
2304+
pwalletMain->AvailableCoins(vecOutputs, false, NULL, true);
23052305
BOOST_FOREACH(const COutput& out, vecOutputs) {
23062306
if (out.nDepth < nMinDepth || out.nDepth > nMaxDepth)
23072307
continue;

src/wallet/wallet.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,7 +1481,7 @@ CAmount CWallet::GetImmatureWatchOnlyBalance() const
14811481
/**
14821482
* populate vCoins with vector of available COutputs.
14831483
*/
1484-
void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const CCoinControl *coinControl) const
1484+
void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const CCoinControl *coinControl, bool fIncludeZeroValue) const
14851485
{
14861486
vCoins.clear();
14871487

@@ -1508,7 +1508,7 @@ void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const
15081508
for (unsigned int i = 0; i < pcoin->vout.size(); i++) {
15091509
isminetype mine = IsMine(pcoin->vout[i]);
15101510
if (!(IsSpent(wtxid, i)) && mine != ISMINE_NO &&
1511-
!IsLockedCoin((*it).first, i) && pcoin->vout[i].nValue > 0 &&
1511+
!IsLockedCoin((*it).first, i) && (pcoin->vout[i].nValue > 0 || fIncludeZeroValue) &&
15121512
(!coinControl || !coinControl->HasSelected() || coinControl->IsSelected((*it).first, i)))
15131513
vCoins.push_back(COutput(pcoin, i, nDepth, (mine & ISMINE_SPENDABLE) != ISMINE_NO));
15141514
}

src/wallet/wallet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface
540540
//! check whether we are allowed to upgrade (or already support) to the named feature
541541
bool CanSupportFeature(enum WalletFeature wf) { AssertLockHeld(cs_wallet); return nWalletMaxVersion >= wf; }
542542

543-
void AvailableCoins(std::vector<COutput>& vCoins, bool fOnlyConfirmed=true, const CCoinControl *coinControl = NULL) const;
543+
void AvailableCoins(std::vector<COutput>& vCoins, bool fOnlyConfirmed=true, const CCoinControl *coinControl = NULL, bool fIncludeZeroValue=false) const;
544544
bool SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int nConfTheirs, std::vector<COutput> vCoins, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, CAmount& nValueRet) const;
545545

546546
bool IsSpent(const uint256& hash, unsigned int n) const;

0 commit comments

Comments
 (0)