Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #731 from laanwj/txshowfix

Fix transaction type in UI
  • Loading branch information...
commit 96d3bcb99690726d4c0e28355cc87c25e14f4c8d 2 parents af8c56f + 56c6e36
Gavin Andresen authored January 03, 2012
39  src/qt/transactionrecord.cpp
@@ -64,17 +64,10 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
64 64
                     sub.credit = nUnmatured;
65 65
                 }
66 66
             }
67  
-            else if (!mapValue["from"].empty() || !mapValue["message"].empty())
68  
-            {
69  
-                // Received by IP connection
70  
-                sub.type = TransactionRecord::RecvFromIP;
71  
-                if (!mapValue["from"].empty())
72  
-                    sub.address = mapValue["from"];
73  
-            }
74 67
             else
75 68
             {
  69
+                bool foundAddress = false;
76 70
                 // Received by Bitcoin Address
77  
-                sub.type = TransactionRecord::RecvWithAddress;
78 71
                 BOOST_FOREACH(const CTxOut& txout, wtx.vout)
79 72
                 {
80 73
                     if(wallet->IsMine(txout))
@@ -82,11 +75,19 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
82 75
                         CBitcoinAddress address;
83 76
                         if (ExtractAddress(txout.scriptPubKey, address) && wallet->HaveKey(address))
84 77
                         {
  78
+                            sub.type = TransactionRecord::RecvWithAddress;
85 79
                             sub.address = address.ToString();
  80
+                            foundAddress = true;
  81
+                            break;
86 82
                         }
87  
-                        break;
88 83
                     }
89 84
                 }
  85
+                if(!foundAddress)
  86
+                {
  87
+                    // Received by IP connection, or other non-address transaction like OP_EVAL
  88
+                    sub.type = TransactionRecord::RecvFromOther;
  89
+                    sub.address = mapValue["from"];
  90
+                }
90 91
             }
91 92
             parts.append(sub);
92 93
         }
@@ -127,21 +128,19 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
127 128
                         // from a transaction sent back to our own address.
128 129
                         continue;
129 130
                     }
130  
-                    else if(!mapValue["to"].empty())
  131
+
  132
+                    CBitcoinAddress address;
  133
+                    if (ExtractAddress(txout.scriptPubKey, address))
131 134
                     {
132  
-                        // Sent to IP
133  
-                        sub.type = TransactionRecord::SendToIP;
134  
-                        sub.address = mapValue["to"];
  135
+                        // Sent to Bitcoin Address
  136
+                        sub.type = TransactionRecord::SendToAddress;
  137
+                        sub.address = address.ToString();
135 138
                     }
136 139
                     else
137 140
                     {
138  
-                        // Sent to Bitcoin Address
139  
-                        sub.type = TransactionRecord::SendToAddress;
140  
-                        CBitcoinAddress address;
141  
-                        if (ExtractAddress(txout.scriptPubKey, address))
142  
-                        {
143  
-                            sub.address = address.ToString();
144  
-                        }
  141
+                        // Sent to IP, or other non-address transaction like OP_EVAL
  142
+                        sub.type = TransactionRecord::SendToOther;
  143
+                        sub.address = mapValue["to"];
145 144
                     }
146 145
 
147 146
                     int64 nValue = txout.nValue;
4  src/qt/transactionrecord.h
@@ -65,9 +65,9 @@ class TransactionRecord
65 65
         Other,
66 66
         Generated,
67 67
         SendToAddress,
68  
-        SendToIP,
  68
+        SendToOther,
69 69
         RecvWithAddress,
70  
-        RecvFromIP,
  70
+        RecvFromOther,
71 71
         SendToSelf
72 72
     };
73 73
 
17  src/qt/transactiontablemodel.cpp
@@ -345,12 +345,11 @@ QString TransactionTableModel::formatTxType(const TransactionRecord *wtx) const
345 345
     {
346 346
     case TransactionRecord::RecvWithAddress:
347 347
         return tr("Received with");
348  
-    case TransactionRecord::RecvFromIP:
349  
-        return tr("Received from IP");
  348
+    case TransactionRecord::RecvFromOther:
  349
+        return tr("Received from");
350 350
     case TransactionRecord::SendToAddress:
  351
+    case TransactionRecord::SendToOther:
351 352
         return tr("Sent to");
352  
-    case TransactionRecord::SendToIP:
353  
-        return tr("Sent to IP");
354 353
     case TransactionRecord::SendToSelf:
355 354
         return tr("Payment to yourself");
356 355
     case TransactionRecord::Generated:
@@ -367,10 +366,10 @@ QVariant TransactionTableModel::txAddressDecoration(const TransactionRecord *wtx
367 366
     case TransactionRecord::Generated:
368 367
         return QIcon(":/icons/tx_mined");
369 368
     case TransactionRecord::RecvWithAddress:
370  
-    case TransactionRecord::RecvFromIP:
  369
+    case TransactionRecord::RecvFromOther:
371 370
         return QIcon(":/icons/tx_input");
372 371
     case TransactionRecord::SendToAddress:
373  
-    case TransactionRecord::SendToIP:
  372
+    case TransactionRecord::SendToOther:
374 373
         return QIcon(":/icons/tx_output");
375 374
     default:
376 375
         return QIcon(":/icons/tx_inout");
@@ -382,12 +381,12 @@ QString TransactionTableModel::formatTxToAddress(const TransactionRecord *wtx, b
382 381
 {
383 382
     switch(wtx->type)
384 383
     {
385  
-    case TransactionRecord::RecvFromIP:
  384
+    case TransactionRecord::RecvFromOther:
386 385
         return QString::fromStdString(wtx->address);
387 386
     case TransactionRecord::RecvWithAddress:
388 387
     case TransactionRecord::SendToAddress:
389 388
         return lookupAddress(wtx->address, tooltip);
390  
-    case TransactionRecord::SendToIP:
  389
+    case TransactionRecord::SendToOther:
391 390
         return QString::fromStdString(wtx->address);
392 391
     case TransactionRecord::SendToSelf:
393 392
     case TransactionRecord::Generated:
@@ -478,7 +477,7 @@ QVariant TransactionTableModel::txStatusDecoration(const TransactionRecord *wtx)
478 477
 QString TransactionTableModel::formatTooltip(const TransactionRecord *rec) const
479 478
 {
480 479
     QString tooltip = formatTxStatus(rec) + QString("\n") + formatTxType(rec);
481  
-    if(rec->type==TransactionRecord::RecvFromIP || rec->type==TransactionRecord::SendToIP ||
  480
+    if(rec->type==TransactionRecord::RecvFromOther || rec->type==TransactionRecord::SendToOther ||
482 481
        rec->type==TransactionRecord::SendToAddress || rec->type==TransactionRecord::RecvWithAddress)
483 482
     {
484 483
         tooltip += QString(" ") + formatTxToAddress(rec, true);
4  src/qt/transactionview.cpp
@@ -71,9 +71,9 @@ TransactionView::TransactionView(QWidget *parent) :
71 71
 
72 72
     typeWidget->addItem(tr("All"), TransactionFilterProxy::ALL_TYPES);
73 73
     typeWidget->addItem(tr("Received with"), TransactionFilterProxy::TYPE(TransactionRecord::RecvWithAddress) |
74  
-                                        TransactionFilterProxy::TYPE(TransactionRecord::RecvFromIP));
  74
+                                        TransactionFilterProxy::TYPE(TransactionRecord::RecvFromOther));
75 75
     typeWidget->addItem(tr("Sent to"), TransactionFilterProxy::TYPE(TransactionRecord::SendToAddress) |
76  
-                                  TransactionFilterProxy::TYPE(TransactionRecord::SendToIP));
  76
+                                  TransactionFilterProxy::TYPE(TransactionRecord::SendToOther));
77 77
     typeWidget->addItem(tr("To yourself"), TransactionFilterProxy::TYPE(TransactionRecord::SendToSelf));
78 78
     typeWidget->addItem(tr("Mined"), TransactionFilterProxy::TYPE(TransactionRecord::Generated));
79 79
     typeWidget->addItem(tr("Other"), TransactionFilterProxy::TYPE(TransactionRecord::Other));

0 notes on commit 96d3bcb

Please sign in to comment.
Something went wrong with that request. Please try again.