Skip to content

Commit

Permalink
Merge pull request #52 from zcoinofficial/fix-mintspend-output-gui
Browse files Browse the repository at this point in the history
Fix mint/spend transaction view
  • Loading branch information
martun authored Mar 24, 2019
2 parents 8a7159c + 42aa155 commit f676ffd
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 7 deletions.
40 changes: 36 additions & 4 deletions src/qt/transactionrecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,51 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
uint256 hash = wtx.GetHash();
std::map<std::string, std::string> mapValue = wtx.mapValue;

if (nNet > 0 || wtx.IsCoinBase())
if(wtx.IsZerocoinSpend() || wtx.IsZerocoinSpendV3())
{
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
{
isminetype mine = wallet->IsMine(txout);

TransactionRecord sub(hash, nTime);
CTxDestination address;
sub.credit = txout.nValue;

if (mine)
{
sub.involvesWatchAddress = mine & ISMINE_WATCH_ONLY;
if (ExtractDestination(txout.scriptPubKey, address) && IsMine(*wallet, address))
{
sub.type = TransactionRecord::SpendToSelf;
sub.address = CBitcoinAddress(address).ToString();
}
}
else
{
ExtractDestination(txout.scriptPubKey, address);
sub.type = TransactionRecord::SpendToAddress;
sub.address = CBitcoinAddress(address).ToString();
}
parts.append(sub);
}
}
else if (nNet > 0 || wtx.IsCoinBase())
{
//
// Credit
//
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
{
isminetype mine = wallet->IsMine(txout);
if(mine)
if (mine)
{
TransactionRecord sub(hash, nTime);
CTxDestination address;
sub.idx = parts.size(); // sequence number
sub.credit = txout.nValue;
sub.involvesWatchAddress = mine & ISMINE_WATCH_ONLY;
if (ExtractDestination(txout.scriptPubKey, address) && IsMine(*wallet, address))

if(ExtractDestination(txout.scriptPubKey, address) && IsMine(*wallet, address))
{
// Received by Bitcoin Address
sub.type = TransactionRecord::RecvWithAddress;
Expand All @@ -74,7 +103,6 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
// Generated
sub.type = TransactionRecord::Generated;
}

parts.append(sub);
}
}
Expand Down Expand Up @@ -135,6 +163,10 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
sub.type = TransactionRecord::SendToAddress;
sub.address = CBitcoinAddress(address).ToString();
}
else if(wtx.IsZerocoinMint() || wtx.IsZerocoinMintV3())
{
sub.type = TransactionRecord::Mint;
}
else
{
// Sent to IP, or other non-address transaction like OP_EVAL
Expand Down
5 changes: 4 additions & 1 deletion src/qt/transactionrecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ class TransactionRecord
SendToOther,
RecvWithAddress,
RecvFromOther,
SendToSelf
SendToSelf,
SpendToAddress,
SpendToSelf,
Mint,
};

/** Number of confirmation recommended for accepting a transaction */
Expand Down
21 changes: 19 additions & 2 deletions src/qt/transactiontablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,12 @@ QString TransactionTableModel::formatTxType(const TransactionRecord *wtx) const
return tr("Payment to yourself");
case TransactionRecord::Generated:
return tr("Mined");
case TransactionRecord::SpendToAddress:
return tr("Spend to");
case TransactionRecord::SpendToSelf:
return tr("Spend to yourself");
case TransactionRecord::Mint:
return tr("Mint");
default:
return QString();
}
Expand All @@ -393,9 +399,12 @@ QVariant TransactionTableModel::txAddressDecoration(const TransactionRecord *wtx
return QIcon(":/icons/tx_mined");
case TransactionRecord::RecvWithAddress:
case TransactionRecord::RecvFromOther:
case TransactionRecord::SpendToSelf:
return QIcon(":/icons/tx_input");
case TransactionRecord::SendToAddress:
case TransactionRecord::SendToOther:
case TransactionRecord::SpendToAddress:
case TransactionRecord::Mint:
return QIcon(":/icons/tx_output");
default:
return QIcon(":/icons/tx_inout");
Expand All @@ -416,10 +425,14 @@ QString TransactionTableModel::formatTxToAddress(const TransactionRecord *wtx, b
return QString::fromStdString(wtx->address) + watchAddress;
case TransactionRecord::RecvWithAddress:
case TransactionRecord::SendToAddress:
case TransactionRecord::SpendToAddress:
case TransactionRecord::SpendToSelf:
case TransactionRecord::Generated:
return lookupAddress(wtx->address, tooltip) + watchAddress;
case TransactionRecord::SendToOther:
return QString::fromStdString(wtx->address) + watchAddress;
case TransactionRecord::Mint:
return tr("Anonymized");
case TransactionRecord::SendToSelf:
default:
return tr("(n/a)") + watchAddress;
Expand All @@ -433,13 +446,16 @@ QVariant TransactionTableModel::addressColor(const TransactionRecord *wtx) const
{
case TransactionRecord::RecvWithAddress:
case TransactionRecord::SendToAddress:
case TransactionRecord::SpendToAddress:
case TransactionRecord::Generated:
{
QString label = walletModel->getAddressTableModel()->labelForAddress(QString::fromStdString(wtx->address));
if(label.isEmpty())
return COLOR_BAREADDRESS;
} break;
case TransactionRecord::SendToSelf:
case TransactionRecord::SpendToSelf:
case TransactionRecord::Mint:
return COLOR_BAREADDRESS;
default:
break;
Expand Down Expand Up @@ -510,8 +526,9 @@ QVariant TransactionTableModel::txWatchonlyDecoration(const TransactionRecord *w
QString TransactionTableModel::formatTooltip(const TransactionRecord *rec) const
{
QString tooltip = formatTxStatus(rec) + QString("\n") + formatTxType(rec);
if(rec->type==TransactionRecord::RecvFromOther || rec->type==TransactionRecord::SendToOther ||
rec->type==TransactionRecord::SendToAddress || rec->type==TransactionRecord::RecvWithAddress)
if(rec->type==TransactionRecord::RecvFromOther || rec->type==TransactionRecord::RecvWithAddress ||
rec->type==TransactionRecord::SendToAddress || rec->type==TransactionRecord::SpendToSelf ||
rec->type==TransactionRecord::SpendToAddress || rec->type==TransactionRecord::SendToOther)
{
tooltip += QString(" ") + formatTxToAddress(rec, true);
}
Expand Down
3 changes: 3 additions & 0 deletions src/qt/transactionview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
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));
typeWidget->addItem(tr("Spend to"), TransactionFilterProxy::TYPE(TransactionRecord::SpendToAddress));
typeWidget->addItem(tr("Spend to yourself"), TransactionFilterProxy::TYPE(TransactionRecord::SpendToSelf));
typeWidget->addItem(tr("Mint"), TransactionFilterProxy::TYPE(TransactionRecord::Mint));

hlayout->addWidget(typeWidget);

Expand Down

0 comments on commit f676ffd

Please sign in to comment.