diff --git a/src/interfaces/wallet.cpp b/src/interfaces/wallet.cpp index 74c03c1399..496d83f435 100644 --- a/src/interfaces/wallet.cpp +++ b/src/interfaces/wallet.cpp @@ -74,6 +74,11 @@ static WalletTx MakeWalletTx(CWallet& wallet, const CWalletTx& wtx) EXCLUSIVE_LO IsMine(wallet, result.txout_address.back()) : ISMINE_NO); } + // ELEMENTS: Retrieve unblinded information about outputs + for (unsigned int i = 0; i < wtx.tx->vout.size(); ++i) { + result.txout_amounts.emplace_back(wtx.GetOutputValueOut(i)); + result.txout_assets.emplace_back(wtx.GetOutputAsset(i)); + } result.credit = wtx.GetCredit(ISMINE_ALL); result.debit = wtx.GetDebit(ISMINE_ALL); result.change = wtx.GetChange(); diff --git a/src/interfaces/wallet.h b/src/interfaces/wallet.h index e9f8d31975..ca7c104c93 100644 --- a/src/interfaces/wallet.h +++ b/src/interfaces/wallet.h @@ -335,6 +335,8 @@ struct WalletTx std::vector txout_is_mine; std::vector txout_address; std::vector txout_address_is_mine; + std::vector txout_amounts; + std::vector txout_assets; CAmountMap credit; CAmountMap debit; CAmountMap change; diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp index 727dbf6f4a..e8cd8a408c 100644 --- a/src/qt/transactionrecord.cpp +++ b/src/qt/transactionrecord.cpp @@ -105,13 +105,12 @@ QList TransactionRecord::decomposeTransaction(const interface // // Debit // - CAmount nTxFee = nDebit - wtx.tx->GetValueOutMap()[::policyAsset]; for (unsigned int nOut = 0; nOut < wtx.tx->vout.size(); nOut++) { const CTxOut& txout = wtx.tx->vout[nOut]; - if(wtx.txout_is_mine[nOut]) + if(wtx.txout_is_mine[nOut] || txout.IsFee()) { // Ignore parts sent to self, as this is usually the change // from a transaction sent back to our own address. @@ -121,6 +120,7 @@ QList TransactionRecord::decomposeTransaction(const interface TransactionRecord sub(hash, nTime); sub.idx = nOut; sub.involvesWatchAddress = involvesWatchAddress; + sub.debit = -wtx.txout_amounts[nOut]; if (!boost::get(&wtx.txout_address[nOut])) { @@ -134,16 +134,14 @@ QList TransactionRecord::decomposeTransaction(const interface sub.type = TransactionRecord::SendToOther; sub.address = mapValue["to"]; } - - CAmount nValue = txout.nValue.GetAmount(); - /* Add fee to first output */ - if (nTxFee > 0) - { - nValue += nTxFee; - nTxFee = 0; - } - sub.debit = -nValue; - + parts.append(sub); + } + CAmount nTxFee = GetFeeMap(*wtx.tx)[::policyAsset]; + if (nTxFee > 0) + { + TransactionRecord sub(hash, nTime); + sub.type = TransactionRecord::Fee; + sub.debit = -nTxFee; parts.append(sub); } } diff --git a/src/qt/transactionrecord.h b/src/qt/transactionrecord.h index e187309d3f..913005f23d 100644 --- a/src/qt/transactionrecord.h +++ b/src/qt/transactionrecord.h @@ -81,7 +81,8 @@ public: SendToOther, RecvWithAddress, RecvFromOther, - SendToSelf + SendToSelf, + Fee }; /** Number of confirmation recommended for accepting a transaction */ diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp index b4be068904..35a9bd0fa4 100644 --- a/src/qt/transactiontablemodel.cpp +++ b/src/qt/transactiontablemodel.cpp @@ -356,6 +356,8 @@ QString TransactionTableModel::formatTxType(const TransactionRecord *wtx) const return tr("Payment to yourself"); case TransactionRecord::Generated: return tr("Mined"); + case TransactionRecord::Fee: + return tr("Fee"); default: return QString(); } @@ -372,6 +374,7 @@ QVariant TransactionTableModel::txAddressDecoration(const TransactionRecord *wtx return QIcon(":/icons/tx_input"); case TransactionRecord::SendToAddress: case TransactionRecord::SendToOther: + case TransactionRecord::Fee: return QIcon(":/icons/tx_output"); default: return QIcon(":/icons/tx_inout"); diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp index 6d08a3b0fb..07144aa1c6 100644 --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -91,6 +91,7 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa TransactionFilterProxy::TYPE(TransactionRecord::SendToOther)); typeWidget->addItem(tr("To yourself"), TransactionFilterProxy::TYPE(TransactionRecord::SendToSelf)); typeWidget->addItem(tr("Mined"), TransactionFilterProxy::TYPE(TransactionRecord::Generated)); + typeWidget->addItem(tr("Fee"), TransactionFilterProxy::TYPE(TransactionRecord::Fee)); typeWidget->addItem(tr("Other"), TransactionFilterProxy::TYPE(TransactionRecord::Other)); hlayout->addWidget(typeWidget);