aboutsummaryrefslogtreecommitdiff
path: root/src/wallet.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2012-06-02 02:35:48 -0700
committerWladimir J. van der Laan <laanwj@gmail.com>2012-06-02 02:35:48 -0700
commit882ba0e7524b54be861b379366b5845a3978b256 (patch)
tree9a14251a5ef6b87e2fd63019b2287dbbad3e9528 /src/wallet.cpp
parent88d7bc930a5834fe41f26af183e512bb34672dab (diff)
parent8fdb7e108fbe77010799c8de95453a327dfa5777 (diff)
Merge pull request #837 from sje397/ShowImmatureBalance
Added 'immature balance' for miners. Only displayed if the balance is > 0
Diffstat (limited to 'src/wallet.cpp')
-rw-r--r--src/wallet.cpp27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/wallet.cpp b/src/wallet.cpp
index 3c4aeb4eaf..4e3b559f6a 100644
--- a/src/wallet.cpp
+++ b/src/wallet.cpp
@@ -567,7 +567,7 @@ void CWalletTx::GetAmounts(int64& nGeneratedImmature, int64& nGeneratedMature, l
}
-void CWalletTx::GetAccountAmounts(const string& strAccount, int64& nGenerated, int64& nReceived,
+void CWalletTx::GetAccountAmounts(const string& strAccount, int64& nGenerated, int64& nReceived,
int64& nSent, int64& nFee) const
{
nGenerated = nReceived = nSent = nFee = 0;
@@ -851,9 +851,8 @@ int64 CWallet::GetBalance() const
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
{
const CWalletTx* pcoin = &(*it).second;
- if (!pcoin->IsFinal() || !pcoin->IsConfirmed())
- continue;
- nTotal += pcoin->GetAvailableCredit();
+ if (pcoin->IsFinal() && pcoin->IsConfirmed())
+ nTotal += pcoin->GetAvailableCredit();
}
}
@@ -868,9 +867,23 @@ int64 CWallet::GetUnconfirmedBalance() const
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
{
const CWalletTx* pcoin = &(*it).second;
- if (pcoin->IsFinal() && pcoin->IsConfirmed())
- continue;
- nTotal += pcoin->GetAvailableCredit();
+ if (!pcoin->IsFinal() || !pcoin->IsConfirmed())
+ nTotal += pcoin->GetAvailableCredit();
+ }
+ }
+ return nTotal;
+}
+
+int64 CWallet::GetImmatureBalance() const
+{
+ int64 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.IsCoinBase() && pcoin.GetBlocksToMaturity() > 0 && pcoin.GetDepthInMainChain() >= 2)
+ nTotal += GetCredit(pcoin);
}
}
return nTotal;