@@ -54,90 +54,36 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const interface
54
54
}
55
55
}
56
56
57
- if (!any_from_me) {
58
- //
59
- // Credit
60
- //
61
- for (unsigned int i = 0 ; i < wtx.tx ->vout .size (); i++)
62
- {
63
- const CTxOut& txout = wtx.tx ->vout [i];
64
- isminetype mine = wtx.txout_is_mine [i];
65
- if (mine)
66
- {
67
- TransactionRecord sub (hash, nTime);
68
- sub.idx = i; // vout index
69
- sub.credit = txout.nValue ;
70
- sub.involvesWatchAddress = mine & ISMINE_WATCH_ONLY;
71
- if (wtx.txout_address_is_mine [i])
72
- {
73
- // Received by Bitcoin Address
74
- sub.type = TransactionRecord::RecvWithAddress;
75
- sub.address = EncodeDestination (wtx.txout_address [i]);
76
- }
77
- else
78
- {
79
- // Received by IP connection (deprecated features), or a multisignature or other non-simple transaction
80
- sub.type = TransactionRecord::RecvFromOther;
81
- sub.address = mapValue[" from" ];
82
- }
83
- if (wtx.is_coinbase )
84
- {
85
- // Generated
86
- sub.type = TransactionRecord::Generated;
87
- }
88
-
89
- parts.append (sub);
90
- }
91
- }
92
- }
93
- else
94
- {
95
- isminetype fAllToMe = ISMINE_SPENDABLE;
57
+ if (fAllFromMe || !any_from_me) {
96
58
for (const isminetype mine : wtx.txout_is_mine )
97
59
{
98
60
if (mine & ISMINE_WATCH_ONLY) involvesWatchAddress = true ;
99
- if (fAllToMe > mine) fAllToMe = mine;
100
61
}
101
62
102
- if (fAllFromMe && fAllToMe )
63
+ CAmount nTxFee = nDebit - wtx.tx ->GetValueOut ();
64
+
65
+ for (unsigned int i = 0 ; i < wtx.tx ->vout .size (); i++)
103
66
{
104
- // Payment to self
105
- std::string address;
106
- for (auto it = wtx.txout_address .begin (); it != wtx.txout_address .end (); ++it) {
107
- if (it != wtx.txout_address .begin ()) address += " , " ;
108
- address += EncodeDestination (*it);
67
+ const CTxOut& txout = wtx.tx ->vout [i];
68
+
69
+ if (wtx.txout_is_change [i]) {
70
+ continue ;
109
71
}
110
72
111
- CAmount nChange = wtx.change ;
112
- parts.append (TransactionRecord (hash, nTime, TransactionRecord::SendToSelf, address, -(nDebit - nChange), nCredit - nChange));
113
- parts.last ().involvesWatchAddress = involvesWatchAddress; // maybe pass to TransactionRecord as constructor argument
114
- }
115
- else if (fAllFromMe )
116
- {
117
- //
118
- // Debit
119
- //
120
- CAmount nTxFee = nDebit - wtx.tx ->GetValueOut ();
73
+ if (fAllFromMe ) {
74
+ //
75
+ // Debit
76
+ //
121
77
122
- for (unsigned int nOut = 0 ; nOut < wtx.tx ->vout .size (); nOut++)
123
- {
124
- const CTxOut& txout = wtx.tx ->vout [nOut];
125
78
TransactionRecord sub (hash, nTime);
126
- sub.idx = nOut ;
79
+ sub.idx = i ;
127
80
sub.involvesWatchAddress = involvesWatchAddress;
128
81
129
- if (wtx.txout_is_mine [nOut])
130
- {
131
- // Ignore parts sent to self, as this is usually the change
132
- // from a transaction sent back to our own address.
133
- continue ;
134
- }
135
-
136
- if (!std::get_if<CNoDestination>(&wtx.txout_address [nOut]))
82
+ if (!std::get_if<CNoDestination>(&wtx.txout_address [i]))
137
83
{
138
84
// Sent to Bitcoin Address
139
85
sub.type = TransactionRecord::SendToAddress;
140
- sub.address = EncodeDestination (wtx.txout_address [nOut ]);
86
+ sub.address = EncodeDestination (wtx.txout_address [i ]);
141
87
}
142
88
else
143
89
{
@@ -157,15 +103,45 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const interface
157
103
158
104
parts.append (sub);
159
105
}
106
+
107
+ isminetype mine = wtx.txout_is_mine [i];
108
+ if (mine)
109
+ {
110
+ //
111
+ // Credit
112
+ //
113
+
114
+ TransactionRecord sub (hash, nTime);
115
+ sub.idx = i; // vout index
116
+ sub.credit = txout.nValue ;
117
+ sub.involvesWatchAddress = mine & ISMINE_WATCH_ONLY;
118
+ if (wtx.txout_address_is_mine [i])
119
+ {
120
+ // Received by Bitcoin Address
121
+ sub.type = TransactionRecord::RecvWithAddress;
122
+ sub.address = EncodeDestination (wtx.txout_address [i]);
123
+ }
124
+ else
125
+ {
126
+ // Received by IP connection (deprecated features), or a multisignature or other non-simple transaction
127
+ sub.type = TransactionRecord::RecvFromOther;
128
+ sub.address = mapValue[" from" ];
129
+ }
130
+ if (wtx.is_coinbase )
131
+ {
132
+ // Generated
133
+ sub.type = TransactionRecord::Generated;
134
+ }
135
+
136
+ parts.append (sub);
137
+ }
160
138
}
161
- else
162
- {
163
- //
164
- // Mixed debit transaction, can't break down payees
165
- //
166
- parts.append (TransactionRecord (hash, nTime, TransactionRecord::Other, " " , nNet, 0 ));
167
- parts.last ().involvesWatchAddress = involvesWatchAddress;
168
- }
139
+ } else {
140
+ //
141
+ // Mixed debit transaction, can't break down payees
142
+ //
143
+ parts.append (TransactionRecord (hash, nTime, TransactionRecord::Other, " " , nNet, 0 ));
144
+ parts.last ().involvesWatchAddress = involvesWatchAddress;
169
145
}
170
146
171
147
return parts;
0 commit comments