@@ -166,11 +166,14 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
166166 sub.credit = nCoinStakeReturnOutput - nDebit;
167167 }
168168 }
169- } else
169+ }
170+ else
171+ {
170172 sub.credit = wtx.vout [t].nValue ;
173+ }
171174
172175 parts.append (sub);
173- }
176+ } // vout for loop
174177 }
175178 }
176179 else
@@ -234,6 +237,34 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
234237 }
235238 sub.debit = -nValue;
236239
240+ // Determine if the transaction is a beacon advertisement or a vote.
241+ // For right now, there should only be one contract in a transaction.
242+ // We will simply select the first and only one. Note that we are
243+ // looping through the outputs one by one in the for loop above this,
244+ // So if we get here, we are not a coinbase or coinstake, and we are on
245+ // an ouput that isn't ours. The worst that can happen from this
246+ // simple approach is to label more than one output with the
247+ // first found contract type. For right now, this is sufficient, because
248+ // the contracts that are sent right now only contain two outputs,
249+ // the burn and the change. We will have to get more sophisticated
250+ // when we allow more than one contract per transaction.
251+
252+ // Notice this doesn't mess with the value or debit, it simply
253+ // overrides the TransactionRecord enum type.
254+ if (!wtx.GetContracts ().empty ())
255+ {
256+ const auto & contract = wtx.GetContracts ().begin ();
257+
258+ if (contract->m_type == NN::ContractType::BEACON)
259+ {
260+ sub.type = TransactionRecord::BeaconAdvertisement;
261+ }
262+ else if (contract->m_type == NN::ContractType::VOTE)
263+ {
264+ sub.type = TransactionRecord::Vote;
265+ }
266+ }
267+
237268 parts.append (sub);
238269 }
239270 }
0 commit comments