mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 14:53:43 +01:00
Watchonly balances are shown separately in gui.
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user