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.
This commit is contained in:
UdjinM6 2018-09-11 17:31:18 +03:00 committed by GitHub
parent 737353c84c
commit 38ccfef3be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -146,14 +146,24 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
} }
else 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.type = TransactionRecord::PrivateSendCollateralPayment;
sub.idx = parts.size(); } else {
for (const auto& txout : wtx.tx->vout) {
if(txout.nValue == CPrivateSend::GetMaxCollateralAmount()) sub.type = TransactionRecord::PrivateSendMakeCollaterals; if(txout.nValue == CPrivateSend::GetMaxCollateralAmount()) {
if(CPrivateSend::IsDenominatedAmount(txout.nValue)) sub.type = TransactionRecord::PrivateSendCreateDenominations; sub.type = TransactionRecord::PrivateSendMakeCollaterals;
if(nDebit - wtx.tx->GetValueOut() == CPrivateSend::GetCollateralAmount()) sub.type = TransactionRecord::PrivateSendCollateralPayment; break;
}
if(CPrivateSend::IsDenominatedAmount(txout.nValue)) {
sub.type = TransactionRecord::PrivateSendCreateDenominations;
break;
}
}
} }
} }
@ -171,7 +181,21 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
// //
CAmount nTxFee = nDebit - wtx.tx->GetValueOut(); 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]; const CTxOut& txout = wtx.tx->vout[nOut];
TransactionRecord sub(hash, nTime); TransactionRecord sub(hash, nTime);