Skip to content

Commit 94f78fa

Browse files
committed
[GUI] TransactionRecord type P2CSDelegationSentOwner and P2CSDelegationSent distinction.
* P2CSDelegationSentOwner: Is the wallet who delegated the coins and kept the ownership. * P2CSDelegationSent: Is the wallet who delegated the coins and transferred the coin's ownership to a remote address.
1 parent 441d790 commit 94f78fa

File tree

6 files changed

+20
-7
lines changed

6 files changed

+20
-7
lines changed

src/qt/pivx/dashboardwidget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ DashboardWidget::DashboardWidget(PIVXGUI* parent) :
112112
ui->comboBoxSortType->addItem(tr("To yourself"), TransactionFilterProxy::TYPE(TransactionRecord::SendToSelf));
113113
ui->comboBoxSortType->addItem(tr("Cold stakes"), TransactionFilterProxy::TYPE(TransactionRecord::StakeDelegated));
114114
ui->comboBoxSortType->addItem(tr("Hot stakes"), TransactionFilterProxy::TYPE(TransactionRecord::StakeHot));
115-
ui->comboBoxSortType->addItem(tr("Delegated"), TransactionFilterProxy::TYPE(TransactionRecord::P2CSDelegationSent));
115+
ui->comboBoxSortType->addItem(tr("Delegated"), TransactionFilterProxy::TYPE(TransactionRecord::P2CSDelegationSent) | TransactionFilterProxy::TYPE(TransactionRecord::P2CSDelegationSentOwner));
116116
ui->comboBoxSortType->addItem(tr("Delegations"), TransactionFilterProxy::TYPE(TransactionRecord::P2CSDelegation));
117117
ui->comboBoxSortType->setCurrentIndex(0);
118118
connect(ui->comboBoxSortType, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(onSortTypeChanged(const QString&)));

src/qt/pivx/txrow.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ void TxRow::setType(bool isLightTheme, int type, bool isConfirmed){
9393
css = "text-list-amount-unconfirmed";
9494
break;
9595
case TransactionRecord::P2CSDelegationSent:
96+
case TransactionRecord::P2CSDelegationSentOwner:
97+
path = "://ic-transaction-cs-contract";
98+
css = "text-list-amount-send";
99+
break;
96100
case TransactionRecord::P2CSDelegation:
97101
path = "://ic-transaction-cs-contract";
98102
css = "text-list-amount-unconfirmed";

src/qt/transactionfilterproxy.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ bool TransactionFilterProxy::isStakeTx(int type) const {
166166
}
167167

168168
bool TransactionFilterProxy::isColdStake(int type) const {
169-
return (type == TransactionRecord::P2CSDelegation || type == TransactionRecord::P2CSDelegationSent || type == TransactionRecord::StakeDelegated || type == TransactionRecord::StakeHot);
169+
return (type == TransactionRecord::P2CSDelegation || type == TransactionRecord::P2CSDelegationSent || type == TransactionRecord::P2CSDelegationSentOwner || type == TransactionRecord::StakeDelegated || type == TransactionRecord::StakeHot);
170170
}
171171

172172
/*QVariant TransactionFilterProxy::dataFromSourcePos(int sourceRow, int role) const {

src/qt/transactionrecord.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,11 +377,16 @@ void TransactionRecord::loadHotOrColdStakeOrContract(
377377
break;
378378
}
379379
}
380-
bool isSpendable = wallet->IsMine(p2csUtxo) & ISMINE_SPENDABLE_DELEGATED;
380+
381+
bool isSpendable = (wallet->IsMine(p2csUtxo) & ISMINE_SPENDABLE_DELEGATED);
382+
bool isFromMe = wallet->IsFromMe(wtx);
381383

382384
if (isContract) {
383-
if (isSpendable) {
385+
if (isSpendable && isFromMe) {
384386
// Wallet delegating balance
387+
record.type = TransactionRecord::P2CSDelegationSentOwner;
388+
} else if (isFromMe){
389+
// Wallet delegating balance and transfering ownership
385390
record.type = TransactionRecord::P2CSDelegationSent;
386391
} else {
387392
// Wallet receiving a delegation
@@ -529,8 +534,9 @@ bool TransactionRecord::isCoinStake() const
529534
bool TransactionRecord::isAnyColdStakingType() const
530535
{
531536
return (type == TransactionRecord::P2CSDelegation || type == TransactionRecord::P2CSDelegationSent
532-
|| type == TransactionRecord::StakeDelegated || type == TransactionRecord::StakeHot
533-
|| type == TransactionRecord::P2CSUnlockOwner || type == TransactionRecord::P2CSUnlockStaker);
537+
|| type == TransactionRecord::P2CSDelegationSentOwner
538+
|| type == TransactionRecord::StakeDelegated || type == TransactionRecord::StakeHot
539+
|| type == TransactionRecord::P2CSUnlockOwner || type == TransactionRecord::P2CSUnlockStaker);
534540
}
535541

536542
bool TransactionRecord::isNull() const

src/qt/transactionrecord.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ class TransactionRecord
9898
StakeDelegated, // Received cold stake (owner)
9999
StakeHot, // Staked via a delegated P2CS.
100100
P2CSDelegation, // Non-spendable P2CS, staker side.
101-
P2CSDelegationSent, // Spendable P2CS delegated utxo. (coin-owner)
101+
P2CSDelegationSent, // Non-spendable P2CS delegated utxo. (coin-owner transferred ownership to external wallet)
102+
P2CSDelegationSentOwner, // Spendable P2CS delegated utxo. (coin-owner)
102103
P2CSUnlockOwner, // Coin-owner spent the delegated utxo
103104
P2CSUnlockStaker // Staker watching the owner spent the delegated utxo
104105
};

src/qt/transactiontablemodel.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@ QString TransactionTableModel::formatTxType(const TransactionRecord* wtx) const
461461
case TransactionRecord::StakeHot:
462462
return tr("PIV Stake on behalf of");
463463
case TransactionRecord::P2CSDelegationSent:
464+
case TransactionRecord::P2CSDelegationSentOwner:
464465
case TransactionRecord::P2CSDelegation:
465466
return tr("Stake delegation");
466467
case TransactionRecord::Generated:
@@ -543,6 +544,7 @@ QString TransactionTableModel::formatTxToAddress(const TransactionRecord* wtx, b
543544
return tr("Anonymous");
544545
case TransactionRecord::P2CSDelegation:
545546
case TransactionRecord::P2CSDelegationSent:
547+
case TransactionRecord::P2CSDelegationSentOwner:
546548
case TransactionRecord::StakeDelegated:
547549
case TransactionRecord::StakeHot:
548550
case TransactionRecord::SendToSelf: {

0 commit comments

Comments
 (0)