Browse Source

Show unconfirmed balance on overview page

tags/v0.15.1
Wladimir J. van der Laan 10 years ago
parent
commit
df5ccbd2b2

+ 5
- 3
README.rst View File

@@ -16,13 +16,15 @@ This has been implemented:

- Tabbed interface

- Overview page with current balance, unconfirmed balance, etc

- User friendly transaction list with status icons, real-time filtering and a context menu that allows editing and copying labels

- Asks for confirmation before sending coins

- CSV export of transactions and address book

- User friendly transaction list with status icons, real-time filtering and a context menu that allows editing and copying labels

- Show alternative icon when on testnet
- Shows alternative icon when connected to testnet

- Progress bar on initial block download


+ 1
- 17
src/qt/bitcoingui.cpp View File

@@ -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

+ 0
- 2
src/qt/bitcoingui.h View File

@@ -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.

+ 16
- 2
src/qt/forms/overviewpage.ui View File

@@ -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>

+ 23
- 3
src/qt/overviewpage.cpp View File

@@ -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)));

}

+ 5
- 1
src/qt/overviewpage.h View File

@@ -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;

};


+ 5
- 0
src/qt/walletmodel.cpp View File

@@ -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;

+ 1
- 0
src/qt/walletmodel.h View File

@@ -31,6 +31,7 @@ public:
TransactionTableModel *getTransactionTableModel();

qint64 getBalance() const;
qint64 getUnconfirmedBalance() const;
int getNumTransactions() const;

/* Send coins */

+ 15
- 0
src/wallet.cpp View File

@@ -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
{

+ 1
- 0
src/wallet.h View File

@@ -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);

Loading…
Cancel
Save