Skip to content

Commit b9765ba

Browse files
committed
GUI: TransactionRecord: Use "any from me" as the criteria for deciding whether a transaction is a send or receive
This changes behaviour (IMO for the better) in the case where some but not all inputs are from us, and the net amount is positive.
1 parent 2529007 commit b9765ba

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

src/qt/transactionrecord.cpp

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#include <QDateTime>
1515

16+
using wallet::ISMINE_NO;
1617
using wallet::ISMINE_SPENDABLE;
1718
using wallet::ISMINE_WATCH_ONLY;
1819
using wallet::isminetype;
@@ -39,8 +40,21 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const interface
3940
uint256 hash = wtx.tx->GetHash();
4041
std::map<std::string, std::string> mapValue = wtx.value_map;
4142

42-
if (nNet > 0 || wtx.is_coinbase)
43-
{
43+
bool involvesWatchAddress = false;
44+
isminetype fAllFromMe = ISMINE_SPENDABLE;
45+
bool any_from_me = false;
46+
if (wtx.is_coinbase) {
47+
fAllFromMe = ISMINE_NO;
48+
} else {
49+
for (const isminetype mine : wtx.txin_is_mine)
50+
{
51+
if(mine & ISMINE_WATCH_ONLY) involvesWatchAddress = true;
52+
if(fAllFromMe > mine) fAllFromMe = mine;
53+
if (mine) any_from_me = true;
54+
}
55+
}
56+
57+
if (!any_from_me) {
4458
//
4559
// Credit
4660
//
@@ -78,14 +92,6 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const interface
7892
}
7993
else
8094
{
81-
bool involvesWatchAddress = false;
82-
isminetype fAllFromMe = ISMINE_SPENDABLE;
83-
for (const isminetype mine : wtx.txin_is_mine)
84-
{
85-
if(mine & ISMINE_WATCH_ONLY) involvesWatchAddress = true;
86-
if(fAllFromMe > mine) fAllFromMe = mine;
87-
}
88-
8995
isminetype fAllToMe = ISMINE_SPENDABLE;
9096
for (const isminetype mine : wtx.txout_is_mine)
9197
{

0 commit comments

Comments
 (0)