From ed4c7fd4fdc1f5b89162d9e91ad57d16205b06eb Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Thu, 5 Sep 2013 12:23:08 +0200 Subject: [PATCH] qt: add vout index to transaction id in transactions details dialog --- src/qt/transactiondesc.cpp | 7 ++++--- src/qt/transactiondesc.h | 2 +- src/qt/transactionrecord.cpp | 9 +++++++-- src/qt/transactionrecord.h | 6 +++++- src/qt/transactiontablemodel.cpp | 4 ++-- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp index 55875c2e4..e27aa93a4 100644 --- a/src/qt/transactiondesc.cpp +++ b/src/qt/transactiondesc.cpp @@ -8,6 +8,7 @@ #include "ui_interface.h" #include "base58.h" #include "paymentserver.h" +#include "transactionrecord.h" #include @@ -32,7 +33,7 @@ QString TransactionDesc::FormatTxStatus(const CWalletTx& wtx) } } -QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, int unit) +QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, int vout, int unit) { QString strHTML; @@ -215,7 +216,7 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, int unit) if (wtx.mapValue.count("comment") && !wtx.mapValue["comment"].empty()) strHTML += "
" + tr("Comment") + ":
" + GUIUtil::HtmlEscape(wtx.mapValue["comment"], true) + "
"; - strHTML += "" + tr("Transaction ID") + ": " + wtx.GetHash().ToString().c_str() + "
"; + strHTML += "" + tr("Transaction ID") + ": " + TransactionRecord::formatSubTxId(wtx.GetHash(), vout) + "
"; // // PaymentRequest info: @@ -225,7 +226,7 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, int unit) if (r.first == "PaymentRequest") { PaymentRequestPlus req; - req.parse(QByteArray::fromRawData(r.second.c_str(), r.second.size())); + req.parse(QByteArray::fromRawData(r.second.data(), r.second.size())); QString merchant; if (req.getMerchant(PaymentServer::getCertStore(), merchant)) strHTML += "" + tr("Merchant") + ": " + GUIUtil::HtmlEscape(merchant) + "
"; diff --git a/src/qt/transactiondesc.h b/src/qt/transactiondesc.h index a659281dd..8b3684e96 100644 --- a/src/qt/transactiondesc.h +++ b/src/qt/transactiondesc.h @@ -14,7 +14,7 @@ class TransactionDesc: public QObject Q_OBJECT public: - static QString toHTML(CWallet *wallet, CWalletTx &wtx, int unit); + static QString toHTML(CWallet *wallet, CWalletTx &wtx, int vout, int unit); private: TransactionDesc() {} diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp index e95450876..ea2c1f0a5 100644 --- a/src/qt/transactionrecord.cpp +++ b/src/qt/transactionrecord.cpp @@ -224,8 +224,13 @@ bool TransactionRecord::statusUpdateNeeded() return status.cur_num_blocks != nBestHeight; } -std::string TransactionRecord::getTxID() +QString TransactionRecord::getTxID() const { - return hash.ToString() + strprintf("-%03d", idx); + return formatSubTxId(hash, idx); +} + +QString TransactionRecord::formatSubTxId(const uint256 &hash, int vout) +{ + return QString::fromStdString(hash.ToString() + strprintf("-%03d", vout)); } diff --git a/src/qt/transactionrecord.h b/src/qt/transactionrecord.h index d760d47c8..480e7a7f2 100644 --- a/src/qt/transactionrecord.h +++ b/src/qt/transactionrecord.h @@ -4,6 +4,7 @@ #include "uint256.h" #include +#include class CWallet; class CWalletTx; @@ -117,7 +118,10 @@ public: TransactionStatus status; /** Return the unique identifier for this transaction (part) */ - std::string getTxID(); + QString getTxID() const; + + /** Format subtransaction id */ + static QString formatSubTxId(const uint256 &hash, int vout); /** Update status from core wallet tx. */ diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp index 9c040d5b6..47ab4bcda 100644 --- a/src/qt/transactiontablemodel.cpp +++ b/src/qt/transactiontablemodel.cpp @@ -208,7 +208,7 @@ public: std::map::iterator mi = wallet->mapWallet.find(rec->hash); if(mi != wallet->mapWallet.end()) { - return TransactionDesc::toHTML(wallet, mi->second, unit); + return TransactionDesc::toHTML(wallet, mi->second, rec->idx, unit); } } return QString(""); @@ -569,7 +569,7 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const case AmountRole: return rec->credit + rec->debit; case TxIDRole: - return QString::fromStdString(rec->getTxID()); + return rec->getTxID(); case ConfirmedRole: // Return True if transaction counts for balance return rec->status.confirmed && !(rec->type == TransactionRecord::Generated &&