gui: Add transaction record type Fee

Github-Pull: bitcoin/bitcoin #12578
Rebased-From: 550f1f3d3498d051ab94afdc0b9fb883c0655b99
This commit is contained in:
João Barbosa 2018-03-01 18:20:17 +00:00 committed by Gregory Sanders
parent 41c8d4c89c
commit 3edcdf8f0b
6 changed files with 23 additions and 13 deletions

View file

@ -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();

View file

@ -335,6 +335,8 @@ struct WalletTx
std::vector<isminetype> txout_is_mine;
std::vector<CTxDestination> txout_address;
std::vector<isminetype> txout_address_is_mine;
std::vector<CAmount> txout_amounts;
std::vector<CAsset> txout_assets;
CAmountMap credit;
CAmountMap debit;
CAmountMap change;

View file

@ -105,13 +105,12 @@ QList<TransactionRecord> 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> TransactionRecord::decomposeTransaction(const interface
TransactionRecord sub(hash, nTime);
sub.idx = nOut;
sub.involvesWatchAddress = involvesWatchAddress;
sub.debit = -wtx.txout_amounts[nOut];
if (!boost::get<CNoDestination>(&wtx.txout_address[nOut]))
{
@ -134,16 +134,14 @@ QList<TransactionRecord> 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);
}
}

View file

@ -81,7 +81,8 @@ public:
SendToOther,
RecvWithAddress,
RecvFromOther,
SendToSelf
SendToSelf,
Fee
};
/** Number of confirmation recommended for accepting a transaction */

View file

@ -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");

View file

@ -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);