diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2011-07-15 15:09:49 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2011-07-15 15:09:49 +0200 |
commit | a35ee9633690fbadc001b2d8fe1dd3ebb852dc25 (patch) | |
tree | a2b22bdcd1d3aeef4181fdae3771fac004fc2bda /src | |
parent | fa989f42c1e2a927267ef8839563e21a2cd4b712 (diff) |
Add call to request unconfirmed balance
Diffstat (limited to 'src')
-rw-r--r-- | src/wallet.cpp | 15 | ||||
-rw-r--r-- | src/wallet.h | 1 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/wallet.cpp b/src/wallet.cpp index 5b88f387c7..fa57755242 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -570,6 +570,21 @@ int64 CWallet::GetBalance() const return nTotal; } +int64 CWallet::GetUnconfirmedBalance() const +{ + int64 nTotal = 0; + CRITICAL_BLOCK(cs_mapWallet) + { + 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(); + } + } + return nTotal; +} bool CWallet::SelectCoinsMinConf(int64 nTargetValue, int nConfMine, int nConfTheirs, set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64& nValueRet) const { diff --git a/src/wallet.h b/src/wallet.h index 7d9db97267..078d7e6e97 100644 --- a/src/wallet.h +++ b/src/wallet.h @@ -57,6 +57,7 @@ public: void ReacceptWalletTransactions(); void ResendWalletTransactions(); int64 GetBalance() const; + int64 GetUnconfirmedBalance() const; bool CreateTransaction(const std::vector<std::pair<CScript, int64> >& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, int64& nFeeRet); bool CreateTransaction(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, CReserveKey& reservekey, int64& nFeeRet); bool CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey); |