Skip to content

Commit

Permalink
Merge pull request #731 from laanwj/txshowfix
Browse files Browse the repository at this point in the history
Fix transaction type in UI
  • Loading branch information
gavinandresen committed Jan 3, 2012
2 parents af8c56f + 56c6e36 commit 96d3bcb
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 33 deletions.
39 changes: 19 additions & 20 deletions src/qt/transactionrecord.cpp
Expand Up @@ -64,29 +64,30 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
sub.credit = nUnmatured;
}
}
else if (!mapValue["from"].empty() || !mapValue["message"].empty())
{
// Received by IP connection
sub.type = TransactionRecord::RecvFromIP;
if (!mapValue["from"].empty())
sub.address = mapValue["from"];
}
else
{
bool foundAddress = false;
// Received by Bitcoin Address
sub.type = TransactionRecord::RecvWithAddress;
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
{
if(wallet->IsMine(txout))
{
CBitcoinAddress address;
if (ExtractAddress(txout.scriptPubKey, address) && wallet->HaveKey(address))
{
sub.type = TransactionRecord::RecvWithAddress;
sub.address = address.ToString();
foundAddress = true;
break;
}
break;
}
}
if(!foundAddress)
{
// Received by IP connection, or other non-address transaction like OP_EVAL
sub.type = TransactionRecord::RecvFromOther;
sub.address = mapValue["from"];
}
}
parts.append(sub);
}
Expand Down Expand Up @@ -127,21 +128,19 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
// from a transaction sent back to our own address.
continue;
}
else if(!mapValue["to"].empty())

CBitcoinAddress address;
if (ExtractAddress(txout.scriptPubKey, address))
{
// Sent to IP
sub.type = TransactionRecord::SendToIP;
sub.address = mapValue["to"];
// Sent to Bitcoin Address
sub.type = TransactionRecord::SendToAddress;
sub.address = address.ToString();
}
else
{
// Sent to Bitcoin Address
sub.type = TransactionRecord::SendToAddress;
CBitcoinAddress address;
if (ExtractAddress(txout.scriptPubKey, address))
{
sub.address = address.ToString();
}
// Sent to IP, or other non-address transaction like OP_EVAL
sub.type = TransactionRecord::SendToOther;
sub.address = mapValue["to"];
}

int64 nValue = txout.nValue;
Expand Down
4 changes: 2 additions & 2 deletions src/qt/transactionrecord.h
Expand Up @@ -65,9 +65,9 @@ class TransactionRecord
Other,
Generated,
SendToAddress,
SendToIP,
SendToOther,
RecvWithAddress,
RecvFromIP,
RecvFromOther,
SendToSelf
};

Expand Down
17 changes: 8 additions & 9 deletions src/qt/transactiontablemodel.cpp
Expand Up @@ -345,12 +345,11 @@ QString TransactionTableModel::formatTxType(const TransactionRecord *wtx) const
{
case TransactionRecord::RecvWithAddress:
return tr("Received with");
case TransactionRecord::RecvFromIP:
return tr("Received from IP");
case TransactionRecord::RecvFromOther:
return tr("Received from");
case TransactionRecord::SendToAddress:
case TransactionRecord::SendToOther:
return tr("Sent to");
case TransactionRecord::SendToIP:
return tr("Sent to IP");
case TransactionRecord::SendToSelf:
return tr("Payment to yourself");
case TransactionRecord::Generated:
Expand All @@ -367,10 +366,10 @@ QVariant TransactionTableModel::txAddressDecoration(const TransactionRecord *wtx
case TransactionRecord::Generated:
return QIcon(":/icons/tx_mined");
case TransactionRecord::RecvWithAddress:
case TransactionRecord::RecvFromIP:
case TransactionRecord::RecvFromOther:
return QIcon(":/icons/tx_input");
case TransactionRecord::SendToAddress:
case TransactionRecord::SendToIP:
case TransactionRecord::SendToOther:
return QIcon(":/icons/tx_output");
default:
return QIcon(":/icons/tx_inout");
Expand All @@ -382,12 +381,12 @@ QString TransactionTableModel::formatTxToAddress(const TransactionRecord *wtx, b
{
switch(wtx->type)
{
case TransactionRecord::RecvFromIP:
case TransactionRecord::RecvFromOther:
return QString::fromStdString(wtx->address);
case TransactionRecord::RecvWithAddress:
case TransactionRecord::SendToAddress:
return lookupAddress(wtx->address, tooltip);
case TransactionRecord::SendToIP:
case TransactionRecord::SendToOther:
return QString::fromStdString(wtx->address);
case TransactionRecord::SendToSelf:
case TransactionRecord::Generated:
Expand Down Expand Up @@ -478,7 +477,7 @@ QVariant TransactionTableModel::txStatusDecoration(const TransactionRecord *wtx)
QString TransactionTableModel::formatTooltip(const TransactionRecord *rec) const
{
QString tooltip = formatTxStatus(rec) + QString("\n") + formatTxType(rec);
if(rec->type==TransactionRecord::RecvFromIP || rec->type==TransactionRecord::SendToIP ||
if(rec->type==TransactionRecord::RecvFromOther || rec->type==TransactionRecord::SendToOther ||
rec->type==TransactionRecord::SendToAddress || rec->type==TransactionRecord::RecvWithAddress)
{
tooltip += QString(" ") + formatTxToAddress(rec, true);
Expand Down
4 changes: 2 additions & 2 deletions src/qt/transactionview.cpp
Expand Up @@ -71,9 +71,9 @@ TransactionView::TransactionView(QWidget *parent) :

typeWidget->addItem(tr("All"), TransactionFilterProxy::ALL_TYPES);
typeWidget->addItem(tr("Received with"), TransactionFilterProxy::TYPE(TransactionRecord::RecvWithAddress) |
TransactionFilterProxy::TYPE(TransactionRecord::RecvFromIP));
TransactionFilterProxy::TYPE(TransactionRecord::RecvFromOther));
typeWidget->addItem(tr("Sent to"), TransactionFilterProxy::TYPE(TransactionRecord::SendToAddress) |
TransactionFilterProxy::TYPE(TransactionRecord::SendToIP));
TransactionFilterProxy::TYPE(TransactionRecord::SendToOther));
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));
Expand Down

0 comments on commit 96d3bcb

Please sign in to comment.