diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2011-05-28 22:31:27 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2011-05-28 22:31:27 +0200 |
commit | 8c937da5f2533dc31e5f071e4e3dcda12fe25e02 (patch) | |
tree | b5406350445c0e0223a5beeb1653ad671aac1c45 | |
parent | 63760fa1cdb9f07fea7bb4c05a7fd7e0af5ead6d (diff) |
"Receive with" i.s.o. "Receive from" address
-rw-r--r-- | gui/include/transactionrecord.h | 2 | ||||
-rw-r--r-- | gui/src/transactionrecord.cpp | 10 | ||||
-rw-r--r-- | gui/src/transactiontablemodel.cpp | 28 |
3 files changed, 18 insertions, 22 deletions
diff --git a/gui/include/transactionrecord.h b/gui/include/transactionrecord.h index 9769d8061e..d8aca76129 100644 --- a/gui/include/transactionrecord.h +++ b/gui/include/transactionrecord.h @@ -51,7 +51,7 @@ public: Generated, SendToAddress, SendToIP, - RecvFromAddress, + RecvWithAddress, RecvFromIP, SendToSelf }; diff --git a/gui/src/transactionrecord.cpp b/gui/src/transactionrecord.cpp index 4024e25c59..9feca4434b 100644 --- a/gui/src/transactionrecord.cpp +++ b/gui/src/transactionrecord.cpp @@ -128,7 +128,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWalletTx else { // Received by Bitcoin Address - sub.type = TransactionRecord::RecvFromAddress; + sub.type = TransactionRecord::RecvWithAddress; BOOST_FOREACH(const CTxOut& txout, wtx.vout) { if (txout.IsMine()) @@ -176,9 +176,9 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWalletTx if (txout.IsMine()) { - // Sent to self - sub.type = TransactionRecord::SendToSelf; - sub.credit = txout.nValue; + // Ignore parts sent to self, as this is usually the change + // from a transaction sent back to our own address. + continue; } else if (!mapValue["to"].empty()) { // Sent to IP @@ -199,7 +199,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWalletTx nValue += nTxFee; nTxFee = 0; } - sub.debit = nValue; + sub.debit = -nValue; sub.status.sortKey += strprintf("-%d", nOut); parts.append(sub); diff --git a/gui/src/transactiontablemodel.cpp b/gui/src/transactiontablemodel.cpp index 3a501979f5..57d618e9db 100644 --- a/gui/src/transactiontablemodel.cpp +++ b/gui/src/transactiontablemodel.cpp @@ -27,25 +27,17 @@ public: void refreshWallet() { qDebug() << "refreshWallet"; - cachedWallet.clear(); - /* Query wallet from core, and compare with our own - representation. + /* Query entire wallet from core. */ + cachedWallet.clear(); CRITICAL_BLOCK(cs_mapWallet) { for(std::map<uint256, CWalletTx>::iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) { - /* TODO: Make note of new and removed transactions */ - /* insertedIndices */ - /* removedIndices */ cachedWallet.append(TransactionRecord::decomposeTransaction(it->second)); } } - /* beginInsertRows(QModelIndex(), first, last) */ - /* endInsertRows */ - /* beginRemoveRows(QModelIndex(), first, last) */ - /* beginEndRows */ } /* Update our model of the wallet. @@ -64,6 +56,10 @@ public: { qDebug() << " " << QString::fromStdString(hash.ToString()); } + /* beginInsertRows(QModelIndex(), first, last) */ + /* endInsertRows */ + /* beginRemoveRows(QModelIndex(), first, last) */ + /* beginEndRows */ refreshWallet(); } @@ -218,17 +214,17 @@ QVariant TransactionTableModel::formatTxDescription(const TransactionRecord *wtx switch(wtx->type) { - case TransactionRecord::RecvFromAddress: - description = tr("From: ") + QString::fromStdString(lookupAddress(wtx->address)); + case TransactionRecord::RecvWithAddress: + description = tr("Received with: ") + QString::fromStdString(lookupAddress(wtx->address)); break; case TransactionRecord::RecvFromIP: - description = tr("From IP: ") + QString::fromStdString(wtx->address); + description = tr("Received from IP: ") + QString::fromStdString(wtx->address); break; case TransactionRecord::SendToAddress: - description = tr("To: ") + QString::fromStdString(lookupAddress(wtx->address)); + description = tr("Sent to: ") + QString::fromStdString(lookupAddress(wtx->address)); break; case TransactionRecord::SendToIP: - description = tr("To IP: ") + QString::fromStdString(wtx->address); + description = tr("Sent to IP: ") + QString::fromStdString(wtx->address); break; case TransactionRecord::SendToSelf: description = tr("Payment to yourself"); @@ -340,7 +336,7 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const /* Role for filtering tabs by type */ switch(rec->type) { - case TransactionRecord::RecvFromAddress: + case TransactionRecord::RecvWithAddress: case TransactionRecord::RecvFromIP: return TransactionTableModel::Received; case TransactionRecord::SendToAddress: |