mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 13:03:17 +01:00
update tx types in UI / fix tx decomposition / use wallet db ds flag in UI
This commit is contained in:
parent
c8c14effff
commit
3a64318bd2
@ -76,37 +76,76 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
|
||||
else
|
||||
{
|
||||
bool fAllFromMe = true;
|
||||
bool fAllFromMeDenom = true;
|
||||
int nFromMe = 0;
|
||||
BOOST_FOREACH(const CTxIn& txin, wtx.vin)
|
||||
{
|
||||
fAllFromMe = fAllFromMe && wallet->IsMine(txin);
|
||||
if(wallet->IsMine(txin)) {
|
||||
fAllFromMeDenom = fAllFromMeDenom && wallet->IsDenominated(txin);
|
||||
nFromMe++;
|
||||
}
|
||||
}
|
||||
|
||||
bool fAllToMe = true;
|
||||
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
|
||||
bool fAllToMeDenom = true;
|
||||
int nToMe = 0;
|
||||
BOOST_FOREACH(const CTxOut& txout, wtx.vout) {
|
||||
fAllToMe = fAllToMe && wallet->IsMine(txout);
|
||||
if(wallet->IsMine(txout)) {
|
||||
fAllToMeDenom = fAllToMeDenom && wallet->IsDenominatedAmount(txout.nValue);
|
||||
nToMe++;
|
||||
}
|
||||
}
|
||||
|
||||
if (fAllFromMe && fAllToMe)
|
||||
if(fAllFromMeDenom && fAllToMeDenom && nFromMe * nToMe) {
|
||||
TransactionRecord sub(hash, nTime);
|
||||
sub.type = TransactionRecord::DarksendDenominate;
|
||||
parts.append(TransactionRecord(hash, nTime, sub.type, "", -nDebit, nCredit));
|
||||
}
|
||||
else if (fAllFromMe && fAllToMe)
|
||||
{
|
||||
// TODO: this section still not accurate but covers most cases,
|
||||
// might need some additional work however
|
||||
|
||||
TransactionRecord sub(hash, nTime);
|
||||
// Payment to self by default
|
||||
sub.type = TransactionRecord::SendToSelf;
|
||||
sub.address = "";
|
||||
|
||||
if(mapValue["DS"] == "1")
|
||||
{
|
||||
sub.type = TransactionRecord::Darksent;
|
||||
CTxDestination address;
|
||||
if (ExtractDestination(wtx.vout[0].scriptPubKey, address))
|
||||
{
|
||||
// Sent to Darkcoin Address
|
||||
sub.address = CBitcoinAddress(address).ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Sent to IP, or other non-address transaction like OP_EVAL
|
||||
sub.address = mapValue["to"];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (unsigned int nOut = 0; nOut < wtx.vout.size(); nOut++)
|
||||
{
|
||||
const CTxOut& txout = wtx.vout[nOut];
|
||||
TransactionRecord sub(hash, nTime);
|
||||
sub.idx = parts.size();
|
||||
|
||||
if(txout.nValue == (DARKSEND_COLLATERAL*2)+DARKSEND_FEE ||
|
||||
txout.nValue == (DARKSEND_COLLATERAL*2)+DARKSEND_FEE ||
|
||||
txout.nValue == (DARKSEND_COLLATERAL*3)+DARKSEND_FEE ||
|
||||
txout.nValue == (DARKSEND_COLLATERAL*4)+DARKSEND_FEE ||
|
||||
txout.nValue == (DARKSEND_COLLATERAL*5)+DARKSEND_FEE
|
||||
) {
|
||||
sub.type = TransactionRecord::DarksendSplitUpLarge;
|
||||
if(wallet->IsCollateralAmount(txout.nValue)) sub.type = TransactionRecord::DarksendMakeCollaterals;
|
||||
if(wallet->IsDenominatedAmount(txout.nValue)) sub.type = TransactionRecord::DarksendCreateDenominations;
|
||||
if(nDebit - wtx.GetValueOut() == DARKSEND_COLLATERAL) sub.type = TransactionRecord::DarksendCollateralPayment;
|
||||
}
|
||||
}
|
||||
|
||||
// Payment to self
|
||||
int64_t nChange = wtx.GetChange();
|
||||
|
||||
parts.append(TransactionRecord(hash, nTime, TransactionRecord::SendToSelf, "",
|
||||
-(nDebit - nChange), nCredit - nChange));
|
||||
sub.debit = -(nDebit - nChange);
|
||||
sub.credit = nCredit - nChange;
|
||||
parts.append(sub);
|
||||
}
|
||||
else if (fAllFromMe)
|
||||
{
|
||||
@ -142,17 +181,11 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
|
||||
sub.address = mapValue["to"];
|
||||
}
|
||||
|
||||
if(wtx.IsDenominated()){
|
||||
if(mapValue["DS"] == "1")
|
||||
{
|
||||
sub.type = TransactionRecord::Darksent;
|
||||
}
|
||||
|
||||
if(txout.nValue == DARKSEND_COLLATERAL){
|
||||
sub.type = TransactionRecord::DarksendCollateralPayment;
|
||||
}
|
||||
if(txout.nValue == DARKSEND_COLLATERAL*5){
|
||||
sub.type = TransactionRecord::DarksendSplitUpLarge;
|
||||
}
|
||||
|
||||
int64_t nValue = txout.nValue;
|
||||
/* Add fee to first output */
|
||||
if (nTxFee > 0)
|
||||
@ -170,16 +203,8 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
|
||||
//
|
||||
// Mixed debit transaction, can't break down payees
|
||||
//
|
||||
bool isDarksent = false;
|
||||
|
||||
for (unsigned int nOut = 0; nOut < wtx.vout.size(); nOut++)
|
||||
{
|
||||
const CTxOut& txout = wtx.vout[nOut];
|
||||
isDarksent = wallet->IsDenominatedAmount(txout.nValue);
|
||||
if(isDarksent) break; // no need to loop more
|
||||
}
|
||||
|
||||
parts.append(TransactionRecord(hash, nTime, isDarksent ? TransactionRecord::DarksendDenominate : TransactionRecord::Other, "", nNet, 0));
|
||||
parts.append(TransactionRecord(hash, nTime, TransactionRecord::Other, "", nNet, 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,8 @@ public:
|
||||
RecvWithDarksend,
|
||||
DarksendDenominate,
|
||||
DarksendCollateralPayment,
|
||||
DarksendSplitUpLarge,
|
||||
DarksendMakeCollaterals,
|
||||
DarksendCreateDenominations,
|
||||
Darksent
|
||||
};
|
||||
|
||||
|
@ -370,8 +370,10 @@ QString TransactionTableModel::formatTxType(const TransactionRecord *wtx) const
|
||||
return tr("Darksend Denominate");
|
||||
case TransactionRecord::DarksendCollateralPayment:
|
||||
return tr("Darksend Collateral Payment");
|
||||
case TransactionRecord::DarksendSplitUpLarge:
|
||||
return tr("Darksend Split Up Large Inputs");
|
||||
case TransactionRecord::DarksendMakeCollaterals:
|
||||
return tr("Darksend Make Collateral Inputs");
|
||||
case TransactionRecord::DarksendCreateDenominations:
|
||||
return tr("Darksend Create Denominations");
|
||||
case TransactionRecord::Darksent:
|
||||
return tr("Darksent");
|
||||
|
||||
|
@ -79,7 +79,10 @@ TransactionView::TransactionView(QWidget *parent) :
|
||||
typeWidget->addItem(tr("Sent to"), TransactionFilterProxy::TYPE(TransactionRecord::SendToAddress) |
|
||||
TransactionFilterProxy::TYPE(TransactionRecord::SendToOther));
|
||||
typeWidget->addItem(tr("Darksent"), TransactionFilterProxy::TYPE(TransactionRecord::Darksent));
|
||||
typeWidget->addItem(tr("Darksend Make Collateral Inputs"), TransactionFilterProxy::TYPE(TransactionRecord::DarksendMakeCollaterals));
|
||||
typeWidget->addItem(tr("Darksend Create Denominations"), TransactionFilterProxy::TYPE(TransactionRecord::DarksendCreateDenominations));
|
||||
typeWidget->addItem(tr("Darksend Denominate"), TransactionFilterProxy::TYPE(TransactionRecord::DarksendDenominate));
|
||||
typeWidget->addItem(tr("Darksend Collateral Payment"), TransactionFilterProxy::TYPE(TransactionRecord::DarksendCollateralPayment));
|
||||
typeWidget->addItem(tr("To yourself"), TransactionFilterProxy::TYPE(TransactionRecord::SendToSelf));
|
||||
typeWidget->addItem(tr("Mined"), TransactionFilterProxy::TYPE(TransactionRecord::Generated));
|
||||
typeWidget->addItem(tr("Other"), TransactionFilterProxy::TYPE(TransactionRecord::Other));
|
||||
|
Loading…
Reference in New Issue
Block a user