Skip to content

Commit

Permalink
GUI: TransactionRecord: Add asset field
Browse files Browse the repository at this point in the history
  • Loading branch information
instagibbs committed Apr 8, 2019
1 parent 060ad2f commit ef2f717
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/qt/transactionrecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,20 @@ QList<TransactionRecord> 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);
Expand Down Expand Up @@ -101,7 +104,7 @@ QList<TransactionRecord> 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)
Expand All @@ -125,6 +128,7 @@ QList<TransactionRecord> 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<CNoDestination>(&wtx.txout_address[nOut]))
{
Expand All @@ -146,6 +150,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const interface
TransactionRecord sub(hash, nTime);
sub.type = TransactionRecord::Fee;
sub.amount = -nTxFee;
sub.asset = ::policyAsset;
parts.append(sub);
}
}
Expand All @@ -154,7 +159,7 @@ QList<TransactionRecord> 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;
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/qt/transactionrecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define BITCOIN_QT_TRANSACTIONRECORD_H

#include <amount.h>
#include <asset.h>
#include <uint256.h>

#include <QList>
Expand Down Expand Up @@ -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)
{
}
Expand All @@ -120,6 +121,7 @@ class TransactionRecord
Type type;
std::string address;
CAmount amount;
CAsset asset;
/**@}*/

/** Subtransaction index, for sort key */
Expand Down

0 comments on commit ef2f717

Please sign in to comment.