Skip to content

Commit 43d2466

Browse files
UI: Override bitcoin transaction record for Omni transactions
NOTE: The bitcoin transaction model for the UI breaks each transaction down into a series of records based primarily on outputs. For Omni transactions this results in duplicate entries in Bitcoin transaction history, so we will override when decomposing the transaction.
1 parent c9d70e0 commit 43d2466

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/qt/transactionrecord.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

55
#include "transactionrecord.h"
6+
#include "omnicore/omnicore.h"
7+
#include "omnicore/pending.h"
68

79
#include "base58.h"
810
#include "timedata.h"
911
#include "wallet.h"
1012

1113
#include <stdint.h>
1214

15+
using namespace mastercore;
16+
1317
/* Return positive answer if transaction should be shown in list.
1418
*/
1519
bool TransactionRecord::showTransaction(const CWalletTx &wtx)
@@ -38,6 +42,34 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
3842
uint256 hash = wtx.GetHash();
3943
std::map<std::string, std::string> mapValue = wtx.mapValue;
4044

45+
// Omni override - since we use multiple outputs these show up as multiple transaction records
46+
// and cause duplicate entries to be displayed in bitcoin history and overview recent
47+
bool omniOverride = false;
48+
PendingMap::iterator it = my_pending.find(hash);
49+
if (it != my_pending.end()) omniOverride = true;
50+
if (p_txlistdb->exists(hash)) omniOverride = true;
51+
if (omniOverride) {
52+
TransactionRecord sub(hash, nTime);
53+
sub.idx = parts.size();
54+
sub.address = "Omni transaction";
55+
sub.involvesWatchAddress = false; // watch only support for Omni is an ongoing WIP
56+
if (nNet > 0) { // inbound
57+
sub.type = TransactionRecord::RecvWithAddress;
58+
BOOST_FOREACH(const CTxOut& txout, wtx.vout) {
59+
isminetype mine = wallet->IsMine(txout);
60+
if (mine) {
61+
sub.credit += txout.nValue;
62+
if (mine == ISMINE_WATCH_ONLY) sub.involvesWatchAddress = true;
63+
}
64+
}
65+
} else { // outbound
66+
sub.type = TransactionRecord::SendToAddress;
67+
sub.debit = nNet;
68+
}
69+
parts.append(sub);
70+
return parts;
71+
}
72+
4173
if (nNet > 0 || wtx.IsCoinBase())
4274
{
4375
//

0 commit comments

Comments
 (0)