Skip to content

Commit c89cf64

Browse files
committed
Implement beacon and vote display categories in UI transaction model
1 parent 28a7fd9 commit c89cf64

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

src/qt/transactionrecord.cpp

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

src/qt/transactionrecord.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ class TransactionRecord
7070
SendToOther,
7171
RecvWithAddress,
7272
RecvFromOther,
73-
SendToSelf
73+
SendToSelf,
74+
BeaconAdvertisement,
75+
Vote
7476
};
7577

7678
/** Number of confirmation recommended for accepting a transaction */

src/qt/transactiontablemodel.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,10 @@ QVariant TransactionTableModel::txAddressDecoration(const TransactionRecord *wtx
406406
case TransactionRecord::SendToAddress:
407407
case TransactionRecord::SendToOther:
408408
return QIcon(":/icons/tx_output");
409+
case TransactionRecord::BeaconAdvertisement:
410+
return QIcon(":/icons/beacon_grey");
411+
case TransactionRecord::Vote:
412+
return QIcon(":/icons/voting_native");
409413
default:
410414
return QIcon(":/icons/tx_inout");
411415
}

0 commit comments

Comments
 (0)