Skip to content

Commit 9defbad

Browse files
committed
[GUI][Model] Cold staking connected to transactionTableModle and dashboard txs list (resources added).
1 parent e1e5481 commit 9defbad

File tree

8 files changed

+132
-1
lines changed

8 files changed

+132
-1
lines changed

src/Makefile.qt.include

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,8 @@ RES_ICONS = \
578578
qt/pivx/res/img/ic-arrow-drop-up-purple.svg \
579579
qt/pivx/res/img/ic-check-liliac-indeterminate.svg \
580580
qt/pivx/res/img/ic-check-box-liliac-indeterminate.svg \
581+
qt/pivx/res/img/ic-transaction-stake-delegated.svg \
582+
qt/pivx/res/img/ic-transaction-stake-hot.svg \
581583
qt/pivx/res/img/ic-check-box-indeterminate.svg \
582584
qt/pivx/res/img/ani-loading-dark.gif \
583585
qt/pivx/res/img/ani-loading.gif

src/qt/pivx.qrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,5 +305,7 @@
305305
<file alias="ani-loading-dark">pivx/res/img/ani-loading-dark.gif</file>
306306
<file alias="ani-loading">pivx/res/img/ani-loading.gif</file>
307307
<file alias="ic-pending">pivx/res/img/ic-pending.svg</file>
308+
<file alias="ic-transaction-stake-delegated">pivx/res/img/ic-transaction-stake-delegated.svg</file>
309+
<file alias="ic-transaction-stake-hot">pivx/res/img/ic-transaction-stake-hot.svg</file>
308310
</qresource>
309311
</RCC>
Lines changed: 41 additions & 0 deletions
Loading
Lines changed: 40 additions & 0 deletions
Loading

src/qt/pivx/txrow.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ void TxRow::setType(bool isLightTheme, int type, bool isConfirmed){
8484
path = "://ic-transaction-mint";
8585
css = "text-list-amount-send";
8686
break;
87+
case TransactionRecord::StakeDelegated:
88+
path = "://ic-transaction-stake-delegated";
89+
css = "text-list-amount-receive";
90+
break;
91+
case TransactionRecord::StakeHot:
92+
path = "://ic-transaction-stake-hot";
93+
css = "text-list-amount-unconfirmed";
94+
break;
8795
default:
8896
path = "://ic-pending";
8997
sameIcon = true;

src/qt/transactionrecord.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet*
5151

5252
if (wtx.IsCoinStake()) {
5353
TransactionRecord sub(hash, nTime, wtx.GetTotalSize());
54+
// Check for cold stakes.
55+
if (wtx.HasP2CSOutputs()) {
56+
loadHotOrColdStake(wallet, wtx, sub);
57+
parts.append(sub);
58+
return parts;
59+
}
60+
5461
CTxDestination address;
5562
if (!wtx.HasZerocoinSpendInputs() && !ExtractDestination(wtx.vout[1].scriptPubKey, address))
5663
return parts;
@@ -315,6 +322,28 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet*
315322
return parts;
316323
}
317324

325+
void TransactionRecord::loadHotOrColdStake(const CWallet* wallet, const CWalletTx& wtx, TransactionRecord& record)
326+
{
327+
record.involvesWatchAddress = false;
328+
CTxOut p2csUtxo = wtx.vout[1];
329+
bool isSpendable = wallet->IsMine(p2csUtxo) & ISMINE_SPENDABLE_DELEGATED;
330+
if (isSpendable) {
331+
record.type = TransactionRecord::StakeDelegated;
332+
record.credit = wtx.nDelegatedCreditCached;
333+
} else {
334+
record.type = TransactionRecord::StakeHot;
335+
record.credit = wtx.nColdCreditCached;
336+
}
337+
338+
CTxDestination address;
339+
if (!ExtractDestination(p2csUtxo.scriptPubKey, address, isSpendable)) {
340+
// this shouldn't happen..
341+
record.address = "No available staking address";
342+
} else {
343+
record.address = CBitcoinAddress(address).ToString();
344+
}
345+
}
346+
318347
bool IsZPIVType(TransactionRecord::Type type)
319348
{
320349
switch (type) {

src/qt/transactionrecord.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ class TransactionRecord
9494
ObfuscationCollateralPayment,
9595
ObfuscationMakeCollaterals,
9696
ObfuscationCreateDenominations,
97-
Obfuscated
97+
Obfuscated,
98+
StakeDelegated, // Received cold stake
99+
StakeHot // Staked via a delegated P2CS.
98100
};
99101

100102
/** Number of confirmation recommended for accepting a transaction */
@@ -164,6 +166,10 @@ class TransactionRecord
164166
/** Return true if the tx hash is null and/or if the size is 0
165167
*/
166168
bool isNull() const;
169+
170+
171+
private:
172+
static void loadHotOrColdStake(const CWallet* wallet, const CWalletTx& wtx, TransactionRecord& record);
167173
};
168174

169175
#endif // BITCOIN_QT_TRANSACTIONRECORD_H

src/qt/transactiontablemodel.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,9 +436,12 @@ QString TransactionTableModel::formatTxType(const TransactionRecord* wtx) const
436436
case TransactionRecord::SendToSelf:
437437
return tr("Payment to yourself");
438438
case TransactionRecord::StakeMint:
439+
case TransactionRecord::StakeDelegated:
439440
return tr("PIV Stake");
440441
case TransactionRecord::StakeZPIV:
441442
return tr("zPIV Stake");
443+
case TransactionRecord::StakeHot:
444+
return tr("PIV Stake in behalf of");
442445
case TransactionRecord::Generated:
443446
return tr("Mined");
444447
case TransactionRecord::ObfuscationDenominate:

0 commit comments

Comments
 (0)