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
|
else
|
||||||
{
|
{
|
||||||
bool fAllFromMe = true;
|
bool fAllFromMe = true;
|
||||||
|
bool fAllFromMeDenom = true;
|
||||||
|
int nFromMe = 0;
|
||||||
BOOST_FOREACH(const CTxIn& txin, wtx.vin)
|
BOOST_FOREACH(const CTxIn& txin, wtx.vin)
|
||||||
|
{
|
||||||
fAllFromMe = fAllFromMe && wallet->IsMine(txin);
|
fAllFromMe = fAllFromMe && wallet->IsMine(txin);
|
||||||
|
if(wallet->IsMine(txin)) {
|
||||||
|
fAllFromMeDenom = fAllFromMeDenom && wallet->IsDenominated(txin);
|
||||||
|
nFromMe++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool fAllToMe = true;
|
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);
|
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
|
||||||
|
|
||||||
for (unsigned int nOut = 0; nOut < wtx.vout.size(); nOut++)
|
TransactionRecord sub(hash, nTime);
|
||||||
|
// Payment to self by default
|
||||||
|
sub.type = TransactionRecord::SendToSelf;
|
||||||
|
sub.address = "";
|
||||||
|
|
||||||
|
if(mapValue["DS"] == "1")
|
||||||
{
|
{
|
||||||
const CTxOut& txout = wtx.vout[nOut];
|
sub.type = TransactionRecord::Darksent;
|
||||||
TransactionRecord sub(hash, nTime);
|
CTxDestination address;
|
||||||
sub.idx = parts.size();
|
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];
|
||||||
|
sub.idx = parts.size();
|
||||||
|
|
||||||
if(txout.nValue == (DARKSEND_COLLATERAL*2)+DARKSEND_FEE ||
|
if(wallet->IsCollateralAmount(txout.nValue)) sub.type = TransactionRecord::DarksendMakeCollaterals;
|
||||||
txout.nValue == (DARKSEND_COLLATERAL*2)+DARKSEND_FEE ||
|
if(wallet->IsDenominatedAmount(txout.nValue)) sub.type = TransactionRecord::DarksendCreateDenominations;
|
||||||
txout.nValue == (DARKSEND_COLLATERAL*3)+DARKSEND_FEE ||
|
if(nDebit - wtx.GetValueOut() == DARKSEND_COLLATERAL) sub.type = TransactionRecord::DarksendCollateralPayment;
|
||||||
txout.nValue == (DARKSEND_COLLATERAL*4)+DARKSEND_FEE ||
|
|
||||||
txout.nValue == (DARKSEND_COLLATERAL*5)+DARKSEND_FEE
|
|
||||||
) {
|
|
||||||
sub.type = TransactionRecord::DarksendSplitUpLarge;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Payment to self
|
|
||||||
int64_t nChange = wtx.GetChange();
|
int64_t nChange = wtx.GetChange();
|
||||||
|
|
||||||
parts.append(TransactionRecord(hash, nTime, TransactionRecord::SendToSelf, "",
|
sub.debit = -(nDebit - nChange);
|
||||||
-(nDebit - nChange), nCredit - nChange));
|
sub.credit = nCredit - nChange;
|
||||||
|
parts.append(sub);
|
||||||
}
|
}
|
||||||
else if (fAllFromMe)
|
else if (fAllFromMe)
|
||||||
{
|
{
|
||||||
@ -142,17 +181,11 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
|
|||||||
sub.address = mapValue["to"];
|
sub.address = mapValue["to"];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(wtx.IsDenominated()){
|
if(mapValue["DS"] == "1")
|
||||||
|
{
|
||||||
sub.type = TransactionRecord::Darksent;
|
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;
|
int64_t nValue = txout.nValue;
|
||||||
/* Add fee to first output */
|
/* Add fee to first output */
|
||||||
if (nTxFee > 0)
|
if (nTxFee > 0)
|
||||||
@ -170,16 +203,8 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
|
|||||||
//
|
//
|
||||||
// Mixed debit transaction, can't break down payees
|
// Mixed debit transaction, can't break down payees
|
||||||
//
|
//
|
||||||
bool isDarksent = false;
|
|
||||||
|
|
||||||
for (unsigned int nOut = 0; nOut < wtx.vout.size(); nOut++)
|
parts.append(TransactionRecord(hash, nTime, TransactionRecord::Other, "", nNet, 0));
|
||||||
{
|
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,8 @@ public:
|
|||||||
RecvWithDarksend,
|
RecvWithDarksend,
|
||||||
DarksendDenominate,
|
DarksendDenominate,
|
||||||
DarksendCollateralPayment,
|
DarksendCollateralPayment,
|
||||||
DarksendSplitUpLarge,
|
DarksendMakeCollaterals,
|
||||||
|
DarksendCreateDenominations,
|
||||||
Darksent
|
Darksent
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -370,8 +370,10 @@ QString TransactionTableModel::formatTxType(const TransactionRecord *wtx) const
|
|||||||
return tr("Darksend Denominate");
|
return tr("Darksend Denominate");
|
||||||
case TransactionRecord::DarksendCollateralPayment:
|
case TransactionRecord::DarksendCollateralPayment:
|
||||||
return tr("Darksend Collateral Payment");
|
return tr("Darksend Collateral Payment");
|
||||||
case TransactionRecord::DarksendSplitUpLarge:
|
case TransactionRecord::DarksendMakeCollaterals:
|
||||||
return tr("Darksend Split Up Large Inputs");
|
return tr("Darksend Make Collateral Inputs");
|
||||||
|
case TransactionRecord::DarksendCreateDenominations:
|
||||||
|
return tr("Darksend Create Denominations");
|
||||||
case TransactionRecord::Darksent:
|
case TransactionRecord::Darksent:
|
||||||
return tr("Darksent");
|
return tr("Darksent");
|
||||||
|
|
||||||
|
@ -79,7 +79,10 @@ TransactionView::TransactionView(QWidget *parent) :
|
|||||||
typeWidget->addItem(tr("Sent to"), TransactionFilterProxy::TYPE(TransactionRecord::SendToAddress) |
|
typeWidget->addItem(tr("Sent to"), TransactionFilterProxy::TYPE(TransactionRecord::SendToAddress) |
|
||||||
TransactionFilterProxy::TYPE(TransactionRecord::SendToOther));
|
TransactionFilterProxy::TYPE(TransactionRecord::SendToOther));
|
||||||
typeWidget->addItem(tr("Darksent"), TransactionFilterProxy::TYPE(TransactionRecord::Darksent));
|
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 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("To yourself"), TransactionFilterProxy::TYPE(TransactionRecord::SendToSelf));
|
||||||
typeWidget->addItem(tr("Mined"), TransactionFilterProxy::TYPE(TransactionRecord::Generated));
|
typeWidget->addItem(tr("Mined"), TransactionFilterProxy::TYPE(TransactionRecord::Generated));
|
||||||
typeWidget->addItem(tr("Other"), TransactionFilterProxy::TYPE(TransactionRecord::Other));
|
typeWidget->addItem(tr("Other"), TransactionFilterProxy::TYPE(TransactionRecord::Other));
|
||||||
|
Loading…
Reference in New Issue
Block a user