From ef2f717e67a01e89f82acfa57594770eac86455e Mon Sep 17 00:00:00 2001 From: Gregory Sanders Date: Mon, 8 Apr 2019 11:24:23 -0400 Subject: [PATCH] GUI: TransactionRecord: Add asset field --- src/qt/transactionrecord.cpp | 9 +++++++-- src/qt/transactionrecord.h | 6 ++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp index 326efc3137..f6a18f228e 100644 --- a/src/qt/transactionrecord.cpp +++ b/src/qt/transactionrecord.cpp @@ -56,17 +56,20 @@ QList TransactionRecord::decomposeTransaction(const interface // Received by Bitcoin Address sub.type = TransactionRecord::RecvWithAddress; sub.address = EncodeDestination(wtx.txout_address[i]); + sub.asset = wtx.txout_assets[i]; } else { // Received by IP connection (deprecated features), or a multisignature or other non-simple transaction sub.type = TransactionRecord::RecvFromOther; sub.address = mapValue["from"]; + sub.asset = wtx.txout_assets[i]; } if (wtx.is_coinbase) { // Generated sub.type = TransactionRecord::Generated; + sub.asset = wtx.txout_assets[i]; } parts.append(sub); @@ -101,7 +104,7 @@ QList TransactionRecord::decomposeTransaction(const interface CAmount nChange = valueFor(wtx.change, ::policyAsset); parts.append(TransactionRecord(hash, nTime, TransactionRecord::SendToSelf, "", - -(nDebit - nChange) + (nCredit - nChange))); + -(nDebit - nChange) + (nCredit - nChange), ::policyAsset)); parts.last().involvesWatchAddress = involvesWatchAddress; // maybe pass to TransactionRecord as constructor argument } else if (fAllFromMe) @@ -125,6 +128,7 @@ QList TransactionRecord::decomposeTransaction(const interface sub.idx = nOut; sub.involvesWatchAddress = involvesWatchAddress; sub.amount = -wtx.txout_amounts[nOut]; + sub.asset = wtx.txout_assets[nOut]; if (!boost::get(&wtx.txout_address[nOut])) { @@ -146,6 +150,7 @@ QList TransactionRecord::decomposeTransaction(const interface TransactionRecord sub(hash, nTime); sub.type = TransactionRecord::Fee; sub.amount = -nTxFee; + sub.asset = ::policyAsset; parts.append(sub); } } @@ -154,7 +159,7 @@ QList TransactionRecord::decomposeTransaction(const interface // // Mixed debit transaction, can't break down payees // - parts.append(TransactionRecord(hash, nTime, TransactionRecord::Other, "", nNet)); + parts.append(TransactionRecord(hash, nTime, TransactionRecord::Other, "", nNet, CAsset())); parts.last().involvesWatchAddress = involvesWatchAddress; } } diff --git a/src/qt/transactionrecord.h b/src/qt/transactionrecord.h index 8341c8ef76..ee087e5b11 100644 --- a/src/qt/transactionrecord.h +++ b/src/qt/transactionrecord.h @@ -6,6 +6,7 @@ #define BITCOIN_QT_TRANSACTIONRECORD_H #include +#include #include #include @@ -101,9 +102,9 @@ class TransactionRecord TransactionRecord(uint256 _hash, qint64 _time, Type _type, const std::string &_address, - const CAmount& _amount): + const CAmount& _amount, const CAsset& _asset): hash(_hash), time(_time), type(_type), address(_address), - amount(_amount), + amount(_amount), asset(_asset), idx(0) { } @@ -120,6 +121,7 @@ class TransactionRecord Type type; std::string address; CAmount amount; + CAsset asset; /**@}*/ /** Subtransaction index, for sort key */