GUI: TransactionRecord: Collapse credit+debit fields to just amount

This commit is contained in:
Luke Dashjr 2018-12-15 02:31:51 +00:00 committed by Gregory Sanders
parent 0aeab14f75
commit 060ad2f566
3 changed files with 16 additions and 17 deletions

View file

@ -43,14 +43,13 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const interface
//
for(unsigned int i = 0; i < wtx.tx->vout.size(); i++)
{
const CTxOut& txout = wtx.tx->vout[i];
isminetype mine = wtx.txout_is_mine[i];
if(mine)
{
TransactionRecord sub(hash, nTime);
CTxDestination address;
sub.idx = i; // vout index
sub.credit = txout.nValue.GetAmount();
sub.amount = wtx.txout_amounts[i];
sub.involvesWatchAddress = mine & ISMINE_WATCH_ONLY;
if (wtx.txout_address_is_mine[i])
{
@ -102,7 +101,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)));
parts.last().involvesWatchAddress = involvesWatchAddress; // maybe pass to TransactionRecord as constructor argument
}
else if (fAllFromMe)
@ -125,7 +124,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const interface
TransactionRecord sub(hash, nTime);
sub.idx = nOut;
sub.involvesWatchAddress = involvesWatchAddress;
sub.debit = -wtx.txout_amounts[nOut];
sub.amount = -wtx.txout_amounts[nOut];
if (!boost::get<CNoDestination>(&wtx.txout_address[nOut]))
{
@ -146,7 +145,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const interface
{
TransactionRecord sub(hash, nTime);
sub.type = TransactionRecord::Fee;
sub.debit = -nTxFee;
sub.amount = -nTxFee;
parts.append(sub);
}
}
@ -155,7 +154,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const interface
//
// Mixed debit transaction, can't break down payees
//
parts.append(TransactionRecord(hash, nTime, TransactionRecord::Other, "", nNet, 0));
parts.append(TransactionRecord(hash, nTime, TransactionRecord::Other, "", nNet));
parts.last().involvesWatchAddress = involvesWatchAddress;
}
}

View file

@ -89,20 +89,21 @@ public:
static const int RecommendedNumConfirmations = 6;
TransactionRecord():
hash(), time(0), type(Other), address(""), debit(0), credit(0), idx(0)
hash(), time(0), type(Other), address(""), amount(0), idx(0)
{
}
TransactionRecord(uint256 _hash, qint64 _time):
hash(_hash), time(_time), type(Other), address(""), debit(0),
credit(0), idx(0)
hash(_hash), time(_time), type(Other), address(""), amount(0),
idx(0)
{
}
TransactionRecord(uint256 _hash, qint64 _time,
Type _type, const std::string &_address,
const CAmount& _debit, const CAmount& _credit):
hash(_hash), time(_time), type(_type), address(_address), debit(_debit), credit(_credit),
const CAmount& _amount):
hash(_hash), time(_time), type(_type), address(_address),
amount(_amount),
idx(0)
{
}
@ -118,8 +119,7 @@ public:
qint64 time;
Type type;
std::string address;
CAmount debit;
CAmount credit;
CAmount amount;
/**@}*/
/** Subtransaction index, for sort key */

View file

@ -428,7 +428,7 @@ QVariant TransactionTableModel::addressColor(const TransactionRecord *wtx) const
QString TransactionTableModel::formatTxAmount(const TransactionRecord *wtx, bool showUnconfirmed, BitcoinUnits::SeparatorStyle separators) const
{
QString str = BitcoinUnits::format(walletModel->getOptionsModel()->getDisplayUnit(), wtx->credit + wtx->debit, false, separators);
QString str = BitcoinUnits::format(walletModel->getOptionsModel()->getDisplayUnit(), wtx->amount, false, separators);
if(showUnconfirmed)
{
if(!wtx->status.countsForBalance)
@ -546,7 +546,7 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
case ToAddress:
return formatTxToAddress(rec, true);
case Amount:
return qint64(rec->credit + rec->debit);
return qint64(rec->amount);
}
break;
case Qt::ToolTipRole:
@ -564,7 +564,7 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
{
return COLOR_UNCONFIRMED;
}
if(index.column() == Amount && (rec->credit+rec->debit) < 0)
if (index.column() == Amount && rec->amount < 0)
{
return COLOR_NEGATIVE;
}
@ -588,7 +588,7 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
case LabelRole:
return walletModel->getAddressTableModel()->labelForAddress(QString::fromStdString(rec->address));
case AmountRole:
return qint64(rec->credit + rec->debit);
return qint64(rec->amount);
case TxHashRole:
return rec->getTxHash();
case TxHexRole: