Skip to content

Commit 73abc88

Browse files
WarrowsFuzzbawls
authored andcommitted
[Qt] Fix zPIV transactions details
1 parent e365b06 commit 73abc88

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

src/qt/transactiondesc.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,7 @@ QString TransactionDesc::toHTML(CWallet* wallet, CWalletTx& wtx, TransactionReco
9292
strHTML.reserve(4000);
9393
strHTML += "<html><font face='verdana, arial, helvetica, sans-serif'>";
9494

95-
int64_t nTime = wtx.GetTxTime();
96-
CAmount nCredit = wtx.GetCredit(ISMINE_ALL);
97-
CAmount nDebit = wtx.GetDebit(ISMINE_ALL);
98-
CAmount nNet = nCredit - nDebit;
95+
CAmount nNet = rec->credit + rec->debit;
9996

10097
strHTML += "<b>" + tr("Status") + ":</b> " + FormatTxStatus(wtx);
10198
int nRequests = wtx.GetRequestCount();
@@ -107,7 +104,7 @@ QString TransactionDesc::toHTML(CWallet* wallet, CWalletTx& wtx, TransactionReco
107104
}
108105
strHTML += "<br>";
109106

110-
strHTML += "<b>" + tr("Date") + ":</b> " + (nTime ? GUIUtil::dateTimeStr(nTime) : "") + "<br>";
107+
strHTML += "<b>" + tr("Date") + ":</b> " + (rec->time ? GUIUtil::dateTimeStr(rec->time) : "") + "<br>";
111108

112109
//
113110
// From
@@ -154,7 +151,7 @@ QString TransactionDesc::toHTML(CWallet* wallet, CWalletTx& wtx, TransactionReco
154151
//
155152
// Amount
156153
//
157-
if (wtx.IsCoinBase() && nCredit == 0) {
154+
if (wtx.IsCoinBase() && rec->credit == 0) {
158155
//
159156
// Coinbase
160157
//
@@ -222,12 +219,12 @@ QString TransactionDesc::toHTML(CWallet* wallet, CWalletTx& wtx, TransactionReco
222219
if (fAllToMe) {
223220
// Payment to self
224221
CAmount nChange = wtx.GetChange();
225-
CAmount nValue = nCredit - nChange;
222+
CAmount nValue = rec->credit - nChange;
226223
strHTML += "<b>" + tr("Total debit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, -nValue) + "<br>";
227224
strHTML += "<b>" + tr("Total credit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, nValue) + "<br>";
228225
}
229226

230-
CAmount nTxFee = nDebit - wtx.GetValueOut();
227+
CAmount nTxFee = rec->debit - wtx.GetValueOut();
231228
if (nTxFee > 0)
232229
strHTML += "<b>" + tr("Transaction fee") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, -nTxFee) + "<br>";
233230
} else {

src/qt/transactionrecord.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,10 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet*
7474
sub.type = TransactionRecord::StakeZPIV;
7575
sub.address = mapValue["zerocoinmint"];
7676
sub.credit = nNet;
77-
7877
for (const CTxOut& out : wtx.vout) {
7978
if (out.IsZerocoinMint())
80-
sub.debit += out.nValue;
79+
sub.credit += out.nValue;
8180
}
82-
8381
sub.debit -= wtx.vin[0].nSequence * COIN;
8482
} else {
8583
isminetype mine = wallet->IsMine(wtx.vout[1]);
@@ -103,7 +101,6 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet*
103101
TransactionRecord sub(hash, nTime);
104102
sub.type = TransactionRecord::ZerocoinSpend_Change_zPiv;
105103
sub.address = mapValue["zerocoinmint"];
106-
sub.debit = -txout.nValue;
107104
if (!fFeeAssigned) {
108105
sub.debit -= (wtx.GetZerocoinSpent() - wtx.GetValueOut());
109106
fFeeAssigned = true;
@@ -122,8 +119,12 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet*
122119
isminetype mine = wallet->IsMine(txout);
123120
if (mine) {
124121
TransactionRecord sub(hash, nTime);
125-
sub.type = (fZSpendFromMe ? TransactionRecord::ZerocoinSpend_FromMe : TransactionRecord::RecvFromZerocoinSpend);
126-
sub.debit = txout.nValue;
122+
if (fZSpendFromMe) {
123+
sub.type = TransactionRecord::ZerocoinSpend_FromMe;
124+
} else {
125+
sub.type = TransactionRecord::RecvFromZerocoinSpend;
126+
sub.credit = txout.nValue;
127+
}
127128
sub.address = mapValue["recvzerocoinspend"];
128129
if (strAddress != "")
129130
sub.address = strAddress;
@@ -269,6 +270,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet*
269270
} else if (txout.IsZerocoinMint()){
270271
sub.type = TransactionRecord::ZerocoinMint;
271272
sub.address = mapValue["zerocoinmint"];
273+
sub.credit += txout.nValue;
272274
} else {
273275
// Sent to IP, or other non-address transaction like OP_EVAL
274276
sub.type = TransactionRecord::SendToOther;

0 commit comments

Comments
 (0)