aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2011-07-11 20:42:10 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2011-07-11 20:42:10 +0200
commitdf5ccbd2b2c72039f1e0e69fc51957f7c2d6068d (patch)
tree9aaf5b94f95172365a44be8b78eae7b2ba382a27 /src
parenteee0d2391cb9d2c72d75c9912363392f87c7b976 (diff)
Show unconfirmed balance on overview page
Diffstat (limited to 'src')
-rw-r--r--src/qt/bitcoingui.cpp18
-rw-r--r--src/qt/bitcoingui.h2
-rw-r--r--src/qt/forms/overviewpage.ui18
-rw-r--r--src/qt/overviewpage.cpp26
-rw-r--r--src/qt/overviewpage.h6
-rw-r--r--src/qt/walletmodel.cpp5
-rw-r--r--src/qt/walletmodel.h1
-rw-r--r--src/wallet.cpp15
-rw-r--r--src/wallet.h1
9 files changed, 67 insertions, 25 deletions
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index 567de52275..144bb22a8a 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -217,19 +217,13 @@ void BitcoinGUI::setWalletModel(WalletModel *walletModel)
{
this->walletModel = walletModel;
- // Keep up to date with wallet
- setBalance(walletModel->getBalance());
- connect(walletModel, SIGNAL(balanceChanged(qint64)), this, SLOT(setBalance(qint64)));
-
- setNumTransactions(walletModel->getNumTransactions());
- connect(walletModel, SIGNAL(numTransactionsChanged(int)), this, SLOT(setNumTransactions(int)));
-
// Report errors from wallet thread
connect(walletModel, SIGNAL(error(QString,QString)), this, SLOT(error(QString,QString)));
// Put transaction list in tabs
transactionView->setModel(walletModel);
+ overviewPage->setModel(walletModel);
addressBookPage->setModel(walletModel->getAddressTableModel());
receiveCoinsPage->setModel(walletModel->getAddressTableModel());
sendCoinsPage->setModel(walletModel);
@@ -280,11 +274,6 @@ void BitcoinGUI::aboutClicked()
dlg.exec();
}
-void BitcoinGUI::setBalance(qint64 balance)
-{
- overviewPage->setBalance(balance);
-}
-
void BitcoinGUI::setNumConnections(int count)
{
QString icon;
@@ -346,11 +335,6 @@ void BitcoinGUI::setNumBlocks(int count)
.arg(QLocale::system().toString(lastBlockDate)));
}
-void BitcoinGUI::setNumTransactions(int count)
-{
- overviewPage->setNumTransactions(count);
-}
-
void BitcoinGUI::error(const QString &title, const QString &message)
{
// Report errors from network/worker thread
diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h
index 6f4ca19146..95e0eb70fe 100644
--- a/src/qt/bitcoingui.h
+++ b/src/qt/bitcoingui.h
@@ -79,10 +79,8 @@ private:
void createTrayIcon();
public slots:
- void setBalance(qint64 balance);
void setNumConnections(int count);
void setNumBlocks(int count);
- void setNumTransactions(int count);
void error(const QString &title, const QString &message);
/* It is currently not possible to pass a return value to another thread through
BlockingQueuedConnection, so use an indirected pointer.
diff --git a/src/qt/forms/overviewpage.ui b/src/qt/forms/overviewpage.ui
index 4cb28d5bf7..d8362a7b25 100644
--- a/src/qt/forms/overviewpage.ui
+++ b/src/qt/forms/overviewpage.ui
@@ -46,20 +46,34 @@
</property>
</widget>
</item>
- <item row="1" column="0">
+ <item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Number of transactions:</string>
</property>
</widget>
</item>
- <item row="1" column="1">
+ <item row="2" column="1">
<widget class="QLabel" name="labelNumTransactions">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Unconfirmed:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="labelUnconfirmed">
+ <property name="text">
+ <string>0 BTC</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>
diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp
index 87f95fddf3..c620200b49 100644
--- a/src/qt/overviewpage.cpp
+++ b/src/qt/overviewpage.cpp
@@ -1,6 +1,7 @@
#include "overviewpage.h"
#include "ui_overviewpage.h"
+#include "walletmodel.h"
#include "guiutil.h"
OverviewPage::OverviewPage(QWidget *parent) :
@@ -14,9 +15,14 @@ OverviewPage::OverviewPage(QWidget *parent) :
ui->labelBalance->setToolTip(tr("Your current balance"));
ui->labelBalance->setTextInteractionFlags(Qt::TextSelectableByMouse|Qt::TextSelectableByKeyboard);
+ // Balance: <balance>
+ ui->labelUnconfirmed->setFont(QFont("Monospace", -1, QFont::Bold));
+ ui->labelUnconfirmed->setToolTip(tr("Balance of transactions that have yet to be confirmed"));
+ ui->labelUnconfirmed->setTextInteractionFlags(Qt::TextSelectableByMouse|Qt::TextSelectableByKeyboard);
+
+ ui->labelNumTransactions->setToolTip(tr("Total number of transactions in wallet"));
+
// Overview page should show:
- // Balance
- // Unconfirmed balance
// Last received transaction(s)
// Last sent transaction(s)
}
@@ -26,12 +32,26 @@ OverviewPage::~OverviewPage()
delete ui;
}
-void OverviewPage::setBalance(qint64 balance)
+void OverviewPage::setBalance(qint64 balance, qint64 unconfirmedBalance)
{
ui->labelBalance->setText(GUIUtil::formatMoney(balance) + QString(" BTC"));
+ ui->labelUnconfirmed->setText(GUIUtil::formatMoney(unconfirmedBalance) + QString(" BTC"));
}
void OverviewPage::setNumTransactions(int count)
{
ui->labelNumTransactions->setText(QLocale::system().toString(count));
}
+
+void OverviewPage::setModel(WalletModel *model)
+{
+ this->model = model;
+
+ // Keep up to date with wallet
+ setBalance(model->getBalance(), model->getUnconfirmedBalance());
+ connect(model, SIGNAL(balanceChanged(qint64)), this, SLOT(setBalance(qint64)));
+
+ setNumTransactions(model->getNumTransactions());
+ connect(model, SIGNAL(numTransactionsChanged(int)), this, SLOT(setNumTransactions(int)));
+
+}
diff --git a/src/qt/overviewpage.h b/src/qt/overviewpage.h
index fbd6853b37..acf83c720f 100644
--- a/src/qt/overviewpage.h
+++ b/src/qt/overviewpage.h
@@ -6,6 +6,7 @@
namespace Ui {
class OverviewPage;
}
+class WalletModel;
class OverviewPage : public QWidget
{
@@ -15,12 +16,15 @@ public:
explicit OverviewPage(QWidget *parent = 0);
~OverviewPage();
+ void setModel(WalletModel *model);
+
public slots:
- void setBalance(qint64 balance);
+ void setBalance(qint64 balance, qint64 unconfirmedBalance);
void setNumTransactions(int count);
private:
Ui::OverviewPage *ui;
+ WalletModel *model;
};
diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp
index 052bf37e39..3e7152da14 100644
--- a/src/qt/walletmodel.cpp
+++ b/src/qt/walletmodel.cpp
@@ -28,6 +28,11 @@ qint64 WalletModel::getBalance() const
return wallet->GetBalance();
}
+qint64 WalletModel::getUnconfirmedBalance() const
+{
+ return wallet->GetUnconfirmedBalance();
+}
+
int WalletModel::getNumTransactions() const
{
int numTransactions = 0;
diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h
index 5b46dfb69d..4c34cfbb59 100644
--- a/src/qt/walletmodel.h
+++ b/src/qt/walletmodel.h
@@ -31,6 +31,7 @@ public:
TransactionTableModel *getTransactionTableModel();
qint64 getBalance() const;
+ qint64 getUnconfirmedBalance() const;
int getNumTransactions() const;
/* Send coins */
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);