diff options
author | JaSK <temp@temp.temp> | 2014-03-29 05:15:28 +0100 |
---|---|---|
committer | JaSK <temp@temp.temp> | 2014-07-02 15:48:38 +0200 |
commit | ffd40da361639faeef405c7e4a504a340d77aa5b (patch) | |
tree | 66131441451335db0f91a7d19cfddb9665aa82f1 /src/wallet.cpp | |
parent | 2935b211033610d7ef0deef9bf1b344a5bac029f (diff) |
Watchonly balances are shown separately in gui.
Diffstat (limited to 'src/wallet.cpp')
-rw-r--r-- | src/wallet.cpp | 53 |
1 files changed, 49 insertions, 4 deletions
diff --git a/src/wallet.cpp b/src/wallet.cpp index 40ace9c40b..d4e9fe9d18 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -738,7 +738,7 @@ bool CWallet::IsChange(const CTxOut& txout) const // a better way of identifying which outputs are 'the send' and which are // 'the change' will need to be implemented (maybe extend CWalletTx to remember // which output, if any, was change). - if (ExtractDestination(txout.scriptPubKey, address) && ::IsMine(*this, address)) + if (ExtractDestination(txout.scriptPubKey, address) && ::IsMine(*this, address) == MINE_SPENDABLE) { LOCK(cs_wallet); if (!mapAddressBook.count(address)) @@ -793,7 +793,7 @@ int CWalletTx::GetRequestCount() const } void CWalletTx::GetAmounts(list<pair<CTxDestination, int64_t> >& listReceived, - list<pair<CTxDestination, int64_t> >& listSent, int64_t& nFee, string& strSentAccount) const + list<pair<CTxDestination, int64_t> >& listSent, int64_t& nFee, string& strSentAccount, const isminefilter& filter) const { nFee = 0; listReceived.clear(); @@ -820,9 +820,9 @@ void CWalletTx::GetAmounts(list<pair<CTxDestination, int64_t> >& listReceived, // Don't report 'change' txouts if (pwallet->IsChange(txout)) continue; - fIsMine = pwallet->IsMine(txout); + fIsMine = (pwallet->IsMine(txout) & filter); } - else if (!(fIsMine = pwallet->IsMine(txout))) + else if (!(fIsMine = (pwallet->IsMine(txout) & filter))) continue; // In either case, we need to get the destination address @@ -1066,6 +1066,51 @@ int64_t CWallet::GetImmatureBalance() const return nTotal; } +int64_t CWallet::GetWatchOnlyBalance() const +{ + int64_t nTotal = 0; + { + LOCK(cs_wallet); + for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) + { + const CWalletTx* pcoin = &(*it).second; + if (pcoin->IsTrusted()) + nTotal += pcoin->GetAvailableWatchOnlyCredit(); + } + } + + return nTotal; +} + +int64_t CWallet::GetUnconfirmedWatchOnlyBalance() const +{ + int64_t nTotal = 0; + { + LOCK(cs_wallet); + for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) + { + const CWalletTx* pcoin = &(*it).second; + if (!IsFinalTx(*pcoin) || (!pcoin->IsTrusted() && pcoin->GetDepthInMainChain() == 0)) + nTotal += pcoin->GetAvailableWatchOnlyCredit(); + } + } + return nTotal; +} + +int64_t CWallet::GetImmatureWatchOnlyBalance() const +{ + int64_t nTotal = 0; + { + LOCK(cs_wallet); + for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) + { + const CWalletTx* pcoin = &(*it).second; + nTotal += pcoin->GetImmatureWatchOnlyCredit(); + } + } + return nTotal; +} + // populate vCoins with vector of available COutputs. void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const CCoinControl *coinControl) const { |