From 8fdb7e108fbe77010799c8de95453a327dfa5777 Mon Sep 17 00:00:00 2001 From: sje397 Date: Tue, 14 Feb 2012 22:08:00 +1100 Subject: Added 'immature balance' for miners. Only displayed if the balance is greater than zero. This adds a field labelled 'Immature' in the overview section under the 'unconfirmed' field, which shows mined income that has not yet matured (which is currently not displayed anywhere, even though the transactions exist in the transaction list). To do that I added a 'GetImmatureBalance' method to the wallet, and connected that through to the GUI as per the 'GetBalance' and 'GetUnconfirmedBalance' methods. I did a small 'no-op' change to make the code in adjacent functions a little more readable (imo); it was a change I had made in my repo earlier...but I thought it wouldn't hurt so left it in. Immature balance comes from mined income that is at least two blocks deep in the chain (same logic as displayed transactions). My reasoning is: - as a miner, it's a critical stat I want to see - as a miner, and taking into account the label 'immature', the uncertainty is pretty clearly implied - those numbers are already displayed in the transaction list - this makes the overview numbers add up to what's in the transaction list - it's not displayed if the immature balance is 0, so won't bother non-miners I also 'cleaned' the overview UI a little, moving code to the XML and removing HTML. --- src/qt/walletmodel.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/qt/walletmodel.cpp') diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index b89c3dba33..807dfc6bf8 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -13,7 +13,8 @@ WalletModel::WalletModel(CWallet *wallet, OptionsModel *optionsModel, QObject *parent) : QObject(parent), wallet(wallet), optionsModel(optionsModel), addressTableModel(0), transactionTableModel(0), - cachedBalance(0), cachedUnconfirmedBalance(0), cachedNumTransactions(0), + cachedBalance(0), cachedUnconfirmedBalance(0), cachedImmatureBalance(0), + cachedNumTransactions(0), cachedEncryptionStatus(Unencrypted) { addressTableModel = new AddressTableModel(wallet, this); @@ -37,6 +38,11 @@ qint64 WalletModel::getUnconfirmedBalance() const return wallet->GetUnconfirmedBalance(); } +qint64 WalletModel::getImmatureBalance() const +{ + return wallet->GetImmatureBalance(); +} + int WalletModel::getNumTransactions() const { int numTransactions = 0; @@ -63,15 +69,18 @@ void WalletModel::updateTransaction(const QString &hash, int status) // Balance and number of transactions might have changed qint64 newBalance = getBalance(); qint64 newUnconfirmedBalance = getUnconfirmedBalance(); + qint64 newImmatureBalance = getImmatureBalance(); int newNumTransactions = getNumTransactions(); - if(cachedBalance != newBalance || cachedUnconfirmedBalance != newUnconfirmedBalance) - emit balanceChanged(newBalance, newUnconfirmedBalance); + if(cachedBalance != newBalance || cachedUnconfirmedBalance != newUnconfirmedBalance || cachedImmatureBalance != newImmatureBalance) + emit balanceChanged(newBalance, newUnconfirmedBalance, newImmatureBalance); + if(cachedNumTransactions != newNumTransactions) emit numTransactionsChanged(newNumTransactions); cachedBalance = newBalance; cachedUnconfirmedBalance = newUnconfirmedBalance; + cachedImmatureBalance = newImmatureBalance; cachedNumTransactions = newNumTransactions; } -- cgit v1.2.3