From 2935b211033610d7ef0deef9bf1b344a5bac029f Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Tue, 10 Dec 2013 15:27:53 +0100 Subject: [PATCH] qt: Hide unspendable outputs in coin control --- src/qt/walletmodel.cpp | 6 ++++-- src/wallet.cpp | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index d32e74b78a5..098d39e8a72 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -60,7 +60,8 @@ qint64 WalletModel::getBalance(const CCoinControl *coinControl) const std::vector vCoins; wallet->AvailableCoins(vCoins, true, coinControl); BOOST_FOREACH(const COutput& out, vCoins) - nBalance += out.tx->vout[out.i].nValue; + if(out.fSpendable) + nBalance += out.tx->vout[out.i].nValue; return nBalance; } @@ -585,7 +586,8 @@ void WalletModel::listCoins(std::map >& mapCoins) } CTxDestination address; - if(!ExtractDestination(cout.tx->vout[cout.i].scriptPubKey, address)) continue; + if(!out.fSpendable || !ExtractDestination(cout.tx->vout[cout.i].scriptPubKey, address)) + continue; mapCoins[CBitcoinAddress(address).ToString().c_str()].push_back(out); } } diff --git a/src/wallet.cpp b/src/wallet.cpp index 3d679f4c564..40ace9c40b7 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -1259,6 +1259,8 @@ bool CWallet::SelectCoins(int64_t nTargetValue, setvout[out.i].nValue; setCoinsRet.insert(make_pair(out.tx, out.i)); }