Merge pull request #731 from laanwj/txshowfix

Fix transaction type in UI
This commit is contained in:
Gavin Andresen 2012-01-03 09:24:54 -08:00
commit 96d3bcb996
4 changed files with 32 additions and 34 deletions

View file

@ -64,17 +64,10 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
sub.credit = nUnmatured; 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 else
{ {
bool foundAddress = false;
// Received by Bitcoin Address // Received by Bitcoin Address
sub.type = TransactionRecord::RecvWithAddress;
BOOST_FOREACH(const CTxOut& txout, wtx.vout) BOOST_FOREACH(const CTxOut& txout, wtx.vout)
{ {
if(wallet->IsMine(txout)) if(wallet->IsMine(txout))
@ -82,11 +75,19 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
CBitcoinAddress address; CBitcoinAddress address;
if (ExtractAddress(txout.scriptPubKey, address) && wallet->HaveKey(address)) if (ExtractAddress(txout.scriptPubKey, address) && wallet->HaveKey(address))
{ {
sub.type = TransactionRecord::RecvWithAddress;
sub.address = address.ToString(); 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); parts.append(sub);
} }
@ -127,21 +128,19 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
// from a transaction sent back to our own address. // from a transaction sent back to our own address.
continue; continue;
} }
else if(!mapValue["to"].empty())
{ CBitcoinAddress address;
// Sent to IP if (ExtractAddress(txout.scriptPubKey, address))
sub.type = TransactionRecord::SendToIP;
sub.address = mapValue["to"];
}
else
{ {
// Sent to Bitcoin Address // Sent to Bitcoin Address
sub.type = TransactionRecord::SendToAddress; sub.type = TransactionRecord::SendToAddress;
CBitcoinAddress address; sub.address = address.ToString();
if (ExtractAddress(txout.scriptPubKey, address)) }
{ else
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; int64 nValue = txout.nValue;

View file

@ -65,9 +65,9 @@ public:
Other, Other,
Generated, Generated,
SendToAddress, SendToAddress,
SendToIP, SendToOther,
RecvWithAddress, RecvWithAddress,
RecvFromIP, RecvFromOther,
SendToSelf SendToSelf
}; };

View file

@ -345,12 +345,11 @@ QString TransactionTableModel::formatTxType(const TransactionRecord *wtx) const
{ {
case TransactionRecord::RecvWithAddress: case TransactionRecord::RecvWithAddress:
return tr("Received with"); return tr("Received with");
case TransactionRecord::RecvFromIP: case TransactionRecord::RecvFromOther:
return tr("Received from IP"); return tr("Received from");
case TransactionRecord::SendToAddress: case TransactionRecord::SendToAddress:
case TransactionRecord::SendToOther:
return tr("Sent to"); return tr("Sent to");
case TransactionRecord::SendToIP:
return tr("Sent to IP");
case TransactionRecord::SendToSelf: case TransactionRecord::SendToSelf:
return tr("Payment to yourself"); return tr("Payment to yourself");
case TransactionRecord::Generated: case TransactionRecord::Generated:
@ -367,10 +366,10 @@ QVariant TransactionTableModel::txAddressDecoration(const TransactionRecord *wtx
case TransactionRecord::Generated: case TransactionRecord::Generated:
return QIcon(":/icons/tx_mined"); return QIcon(":/icons/tx_mined");
case TransactionRecord::RecvWithAddress: case TransactionRecord::RecvWithAddress:
case TransactionRecord::RecvFromIP: case TransactionRecord::RecvFromOther:
return QIcon(":/icons/tx_input"); return QIcon(":/icons/tx_input");
case TransactionRecord::SendToAddress: case TransactionRecord::SendToAddress:
case TransactionRecord::SendToIP: case TransactionRecord::SendToOther:
return QIcon(":/icons/tx_output"); return QIcon(":/icons/tx_output");
default: default:
return QIcon(":/icons/tx_inout"); return QIcon(":/icons/tx_inout");
@ -382,12 +381,12 @@ QString TransactionTableModel::formatTxToAddress(const TransactionRecord *wtx, b
{ {
switch(wtx->type) switch(wtx->type)
{ {
case TransactionRecord::RecvFromIP: case TransactionRecord::RecvFromOther:
return QString::fromStdString(wtx->address); return QString::fromStdString(wtx->address);
case TransactionRecord::RecvWithAddress: case TransactionRecord::RecvWithAddress:
case TransactionRecord::SendToAddress: case TransactionRecord::SendToAddress:
return lookupAddress(wtx->address, tooltip); return lookupAddress(wtx->address, tooltip);
case TransactionRecord::SendToIP: case TransactionRecord::SendToOther:
return QString::fromStdString(wtx->address); return QString::fromStdString(wtx->address);
case TransactionRecord::SendToSelf: case TransactionRecord::SendToSelf:
case TransactionRecord::Generated: case TransactionRecord::Generated:
@ -478,7 +477,7 @@ QVariant TransactionTableModel::txStatusDecoration(const TransactionRecord *wtx)
QString TransactionTableModel::formatTooltip(const TransactionRecord *rec) const QString TransactionTableModel::formatTooltip(const TransactionRecord *rec) const
{ {
QString tooltip = formatTxStatus(rec) + QString("\n") + formatTxType(rec); 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) rec->type==TransactionRecord::SendToAddress || rec->type==TransactionRecord::RecvWithAddress)
{ {
tooltip += QString(" ") + formatTxToAddress(rec, true); tooltip += QString(" ") + formatTxToAddress(rec, true);

View file

@ -71,9 +71,9 @@ TransactionView::TransactionView(QWidget *parent) :
typeWidget->addItem(tr("All"), TransactionFilterProxy::ALL_TYPES); typeWidget->addItem(tr("All"), TransactionFilterProxy::ALL_TYPES);
typeWidget->addItem(tr("Received with"), TransactionFilterProxy::TYPE(TransactionRecord::RecvWithAddress) | 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) | 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("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));