Skip to content

Commit

Permalink
qt: add vout index to transaction id in transactions details dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
laanwj committed Sep 6, 2013
1 parent d22d975 commit ed4c7fd
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
7 changes: 4 additions & 3 deletions src/qt/transactiondesc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "ui_interface.h"
#include "base58.h"
#include "paymentserver.h"
#include "transactionrecord.h"

#include <string>

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

Expand Down Expand Up @@ -215,7 +216,7 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, int unit)
if (wtx.mapValue.count("comment") && !wtx.mapValue["comment"].empty())
strHTML += "<br><b>" + tr("Comment") + ":</b><br>" + GUIUtil::HtmlEscape(wtx.mapValue["comment"], true) + "<br>";

strHTML += "<b>" + tr("Transaction ID") + ":</b> " + wtx.GetHash().ToString().c_str() + "<br>";
strHTML += "<b>" + tr("Transaction ID") + ":</b> " + TransactionRecord::formatSubTxId(wtx.GetHash(), vout) + "<br>";

//
// PaymentRequest info:
Expand All @@ -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 += "<b>" + tr("Merchant") + ":</b> " + GUIUtil::HtmlEscape(merchant) + "<br>";
Expand Down
2 changes: 1 addition & 1 deletion src/qt/transactiondesc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
Expand Down
9 changes: 7 additions & 2 deletions src/qt/transactionrecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

6 changes: 5 additions & 1 deletion src/qt/transactionrecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "uint256.h"

#include <QList>
#include <QString>

class CWallet;
class CWalletTx;
Expand Down Expand Up @@ -117,7 +118,10 @@ class TransactionRecord
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.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/qt/transactiontablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class TransactionTablePriv
std::map<uint256, CWalletTx>::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("");
Expand Down Expand Up @@ -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 &&
Expand Down

0 comments on commit ed4c7fd

Please sign in to comment.