Skip to content

Commit cba084d

Browse files
authored
Merge pull request #1717 from jamescowens/beaconandvotecategories
Implement beacon, vote, and superblock display categories/icons in UI transaction model
2 parents 5595497 + c1468ea commit cba084d

File tree

9 files changed

+1351
-26
lines changed

9 files changed

+1351
-26
lines changed

src/Makefile.qt.include

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ RES_ICONS = \
266266
qt/res/icons/staking_off.svg \
267267
qt/res/icons/staking_on.svg \
268268
qt/res/icons/staking_unable.svg \
269+
qt/res/icons/superblock.svg \
269270
qt/res/icons/transaction_conflicted.png \
270271
qt/res/icons/transaction0.png \
271272
qt/res/icons/transaction2.png \

src/qt/bitcoin.qrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
<file alias="synced">res/icons/green_check.svg</file>
7373
<file alias="white_and_red_x">res/icons/white_and_red_x.svg</file>
7474
<file alias="staking_unable">res/icons/staking_unable.svg</file>
75+
<file alias="superblock">res/icons/superblock.svg</file>
7576
</qresource>
7677
<qresource prefix="/images">
7778
<file alias="splash">res/images/splash3.png</file>

src/qt/res/icons/superblock.svg

Lines changed: 1241 additions & 0 deletions
Loading

src/qt/transactiondesc.cpp

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,27 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, unsigned int vo
117117

118118
switch (gentype)
119119
{
120-
case MinedType::POS : strHTML += tr("MINED - POS"); break;
121-
case MinedType::POR : strHTML += tr("MINED - POR"); break;
122-
case MinedType::ORPHANED : strHTML += tr("MINED - ORPHANED"); break;
123-
case MinedType::POS_SIDE_STAKE : strHTML += tr("POS SIDE STAKE"); break;
124-
case MinedType::POR_SIDE_STAKE : strHTML += tr("POR SIDE STAKE"); break;
125-
default : strHTML += tr("MINED - UNKNOWN"); break;
120+
case MinedType::POS:
121+
strHTML += tr("MINED - POS");
122+
break;
123+
case MinedType::POR:
124+
strHTML += tr("MINED - POR");
125+
break;
126+
case MinedType::ORPHANED:
127+
strHTML += tr("MINED - ORPHANED");
128+
break;
129+
case MinedType::POS_SIDE_STAKE:
130+
strHTML += tr("POS SIDE STAKE");
131+
break;
132+
case MinedType::POR_SIDE_STAKE:
133+
strHTML += tr("POR SIDE STAKE");
134+
break;
135+
case MinedType::SUPERBLOCK:
136+
strHTML += tr("SUPERBLOCK");
137+
break;
138+
default:
139+
strHTML += tr("MINED - UNKNOWN");
140+
break;
126141
}
127142

128143
strHTML += "<br>";

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: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -366,15 +366,26 @@ QString TransactionTableModel::formatTxType(const TransactionRecord *wtx) const
366366

367367
switch (gentype)
368368
{
369-
case MinedType::POS : return tr("MINED - POS");
370-
case MinedType::POR : return tr("MINED - POR");
371-
case MinedType::ORPHANED : return tr("MINED - ORPHANED");
372-
case MinedType::POS_SIDE_STAKE : return tr("POS SIDE STAKE");
373-
case MinedType::POR_SIDE_STAKE : return tr("POR SIDE STAKE");
374-
default : return tr("MINED - UNKNOWN");
369+
case MinedType::POS:
370+
return tr("MINED - POS");
371+
case MinedType::POR:
372+
return tr("MINED - POR");
373+
case MinedType::ORPHANED:
374+
return tr("MINED - ORPHANED");
375+
case MinedType::POS_SIDE_STAKE:
376+
return tr("POS SIDE STAKE");
377+
case MinedType::POR_SIDE_STAKE:
378+
return tr("POR SIDE STAKE");
379+
case MinedType::SUPERBLOCK:
380+
return tr("MINED - SUPERBLOCK");
381+
default:
382+
return tr("MINED - UNKNOWN");
375383
}
376-
}
377-
384+
}
385+
case TransactionRecord::BeaconAdvertisement:
386+
return tr("Beacon Advertisement");
387+
case TransactionRecord::Vote:
388+
return tr("Vote");
378389
default:
379390
return QString();
380391
}
@@ -392,12 +403,20 @@ QVariant TransactionTableModel::txAddressDecoration(const TransactionRecord *wtx
392403

393404
switch (gentype)
394405
{
395-
case MinedType::POS : return QIcon(":/icons/tx_mined");
396-
case MinedType::POR : return QIcon(":/icons/tx_cpumined");
397-
case MinedType::ORPHANED : return QIcon(":/icons/transaction_conflicted");
398-
case MinedType::POS_SIDE_STAKE : return QIcon(":/icons/tx_mined_ss");
399-
case MinedType::POR_SIDE_STAKE : return QIcon(":/icons/tx_cpumined_ss");
400-
default : return QIcon(":/icons/transaction_0");
406+
case MinedType::POS:
407+
return QIcon(":/icons/tx_mined");
408+
case MinedType::POR:
409+
return QIcon(":/icons/tx_cpumined");
410+
case MinedType::ORPHANED:
411+
return QIcon(":/icons/transaction_conflicted");
412+
case MinedType::POS_SIDE_STAKE:
413+
return QIcon(":/icons/tx_mined_ss");
414+
case MinedType::POR_SIDE_STAKE:
415+
return QIcon(":/icons/tx_cpumined_ss");
416+
case MinedType::SUPERBLOCK:
417+
return QIcon(":/icons/superblock");
418+
default:
419+
return QIcon(":/icons/transaction_0");
401420
}
402421
}
403422
case TransactionRecord::RecvWithAddress:
@@ -406,6 +425,10 @@ QVariant TransactionTableModel::txAddressDecoration(const TransactionRecord *wtx
406425
case TransactionRecord::SendToAddress:
407426
case TransactionRecord::SendToOther:
408427
return QIcon(":/icons/tx_output");
428+
case TransactionRecord::BeaconAdvertisement:
429+
return QIcon(":/icons/beacon_grey");
430+
case TransactionRecord::Vote:
431+
return QIcon(":/icons/voting_native");
409432
default:
410433
return QIcon(":/icons/tx_inout");
411434
}

src/wallet.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2712,6 +2712,16 @@ MinedType GetGeneratedType(const uint256& tx, unsigned int vout)
27122712

27132713
CBlockIndex* blkindex = (*mi).second;
27142714

2715+
// If we are calling GetGeneratedType, this is a transaction
2716+
// that corresponds (is integral to) the block, and it is
2717+
// already IsMine. We check whether the block is a superblock,
2718+
// and if so we set the MinedType to SUPERBLOCK as that should
2719+
// override the others here.
2720+
if (blkindex->nIsSuperBlock)
2721+
{
2722+
return MinedType::SUPERBLOCK;
2723+
}
2724+
27152725
// Basic CoinStake Support
27162726
if (wallettx.vout.size() == 2)
27172727
{
@@ -2725,8 +2735,8 @@ MinedType GetGeneratedType(const uint256& tx, unsigned int vout)
27252735
// Side/Split Stake Support
27262736
else if (wallettx.vout.size() >= 3)
27272737
{
2728-
// Split Stake -- There a better way since you cannot == two scriptPubKeys
2729-
if (wallettx.vout[vout].scriptPubKey.ToString() == wallettx.vout[1].scriptPubKey.ToString())
2738+
// Split Stake
2739+
if (wallettx.vout[vout].scriptPubKey == wallettx.vout[1].scriptPubKey)
27302740
{
27312741
if (blkindex->nResearchSubsidy == 0)
27322742
return MinedType::POS;

src/wallet.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ enum MinedType
4343
POR = 2,
4444
ORPHANED = 3,
4545
POS_SIDE_STAKE = 4,
46-
POR_SIDE_STAKE = 5
46+
POR_SIDE_STAKE = 5,
47+
SUPERBLOCK = 6
4748
};
4849

4950
// CMinerStatus is here to prevent circular include problems.

0 commit comments

Comments
 (0)