From 38ccfef3bea5950fcb6a7bff41364072379e6139 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Tue, 11 Sep 2018 17:31:18 +0300 Subject: [PATCH] Identify PS collateral payments in transaction list a bit more accurate (#2271) This have to be updated due to new rules for PS collateral - we allow OP_RETURN outputs and "non-exact" inputs (1x<=X<2x) now. --- src/qt/transactionrecord.cpp | 40 ++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp index e616670504..2cea365616 100644 --- a/src/qt/transactionrecord.cpp +++ b/src/qt/transactionrecord.cpp @@ -146,14 +146,24 @@ QList TransactionRecord::decomposeTransaction(const CWallet * } else { - for (unsigned int nOut = 0; nOut < wtx.tx->vout.size(); nOut++) + sub.idx = parts.size(); + if(wtx.tx->vin.size() == 1 && wtx.tx->vout.size() == 1 + && CPrivateSend::IsCollateralAmount(nDebit) + && CPrivateSend::IsCollateralAmount(nCredit) + && CPrivateSend::IsCollateralAmount(-nNet)) { - const CTxOut& txout = wtx.tx->vout[nOut]; - sub.idx = parts.size(); - - if(txout.nValue == CPrivateSend::GetMaxCollateralAmount()) sub.type = TransactionRecord::PrivateSendMakeCollaterals; - if(CPrivateSend::IsDenominatedAmount(txout.nValue)) sub.type = TransactionRecord::PrivateSendCreateDenominations; - if(nDebit - wtx.tx->GetValueOut() == CPrivateSend::GetCollateralAmount()) sub.type = TransactionRecord::PrivateSendCollateralPayment; + sub.type = TransactionRecord::PrivateSendCollateralPayment; + } else { + for (const auto& txout : wtx.tx->vout) { + if(txout.nValue == CPrivateSend::GetMaxCollateralAmount()) { + sub.type = TransactionRecord::PrivateSendMakeCollaterals; + break; + } + if(CPrivateSend::IsDenominatedAmount(txout.nValue)) { + sub.type = TransactionRecord::PrivateSendCreateDenominations; + break; + } + } } } @@ -171,7 +181,21 @@ QList TransactionRecord::decomposeTransaction(const CWallet * // CAmount nTxFee = nDebit - wtx.tx->GetValueOut(); - for (unsigned int nOut = 0; nOut < wtx.tx->vout.size(); nOut++) + bool fDone = false; + if(wtx.tx->vin.size() == 1 && wtx.tx->vout.size() == 1 + && CPrivateSend::IsCollateralAmount(nDebit) + && nCredit == 0 // OP_RETURN + && CPrivateSend::IsCollateralAmount(-nNet)) + { + TransactionRecord sub(hash, nTime); + sub.idx = 0; + sub.type = TransactionRecord::PrivateSendCollateralPayment; + sub.debit = -nDebit; + parts.append(sub); + fDone = true; + } + + for (unsigned int nOut = 0; nOut < wtx.tx->vout.size() && !fDone; nOut++) { const CTxOut& txout = wtx.tx->vout[nOut]; TransactionRecord sub(hash, nTime);