From b92fd202e243bf3cbb6902833d991296213b8c2f Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 22 May 2012 22:45:05 +0100 Subject: [PATCH] PPCoin: Separate newmint value from stake in RPC 'getinfo' output --- src/bitcoinrpc.cpp | 1 + src/wallet.cpp | 18 +++++++++++++++++- src/wallet.h | 1 + 3 files changed, 19 insertions(+), 1 deletions(-) diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index 453fafd..4836fe3 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -308,6 +308,7 @@ Value getinfo(const Array& params, bool fHelp) Object obj; obj.push_back(Pair("version", (int)VERSION)); obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance()))); + obj.push_back(Pair("newmint", ValueFromAmount(pwalletMain->GetNewMint()))); obj.push_back(Pair("stake", ValueFromAmount(pwalletMain->GetStake()))); obj.push_back(Pair("blocks", (int)nBestHeight)); obj.push_back(Pair("connections", (int)vNodes.size())); diff --git a/src/wallet.cpp b/src/wallet.cpp index 51c4b88..c245f84 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -772,13 +772,29 @@ int64 CWallet::GetStake() const for (map::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) { const CWalletTx* pcoin = &(*it).second; - if ((pcoin->IsCoinBase() || pcoin->IsCoinStake()) && pcoin->GetBlocksToMaturity() > 0 && pcoin->GetDepthInMainChain() > 0) + if (pcoin->IsCoinStake() && pcoin->GetBlocksToMaturity() > 0 && pcoin->GetDepthInMainChain() > 0) nTotal += CWallet::GetCredit(*pcoin); } } return nTotal; } +int64 CWallet::GetNewMint() const +{ + int64 nTotal = 0; + CRITICAL_BLOCK(cs_wallet) + { + for (map::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) + { + const CWalletTx* pcoin = &(*it).second; + if (pcoin->IsCoinBase() && pcoin->GetBlocksToMaturity() > 0 && pcoin->GetDepthInMainChain() > 0) + nTotal += CWallet::GetCredit(*pcoin); + } + } + return nTotal; +} + + bool CWallet::SelectCoinsMinConf(int64 nTargetValue, unsigned int nSpendTime, int nConfMine, int nConfTheirs, set >& setCoinsRet, int64& nValueRet) const { setCoinsRet.clear(); diff --git a/src/wallet.h b/src/wallet.h index 0e2cead..775143f 100644 --- a/src/wallet.h +++ b/src/wallet.h @@ -87,6 +87,7 @@ public: int64 GetBalance() const; int64 GetUnconfirmedBalance() const; int64 GetStake() const; + int64 GetNewMint() const; bool CreateTransaction(const std::vector >& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, int64& nFeeRet); bool CreateTransaction(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, CReserveKey& reservekey, int64& nFeeRet); bool CreateCoinStake(unsigned int nBits, CTransaction& txNew); -- 1.7.1