Skip to content

Commit

Permalink
[GUI] TransactionRecord type P2CSDelegationSentOwner and P2CSDelegati…
Browse files Browse the repository at this point in the history
…onSent 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.

Github-Pull: #1263
Rebased-From: 94f78fa
  • Loading branch information
furszy authored and Fuzzbawls committed Jan 16, 2020
1 parent 49de2e4 commit fc766c8
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/qt/pivx/dashboardwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ DashboardWidget::DashboardWidget(PIVXGUI* parent) :
ui->comboBoxSortType->addItem(tr("To yourself"), TransactionFilterProxy::TYPE(TransactionRecord::SendToSelf));
ui->comboBoxSortType->addItem(tr("Cold stakes"), TransactionFilterProxy::TYPE(TransactionRecord::StakeDelegated));
ui->comboBoxSortType->addItem(tr("Hot stakes"), TransactionFilterProxy::TYPE(TransactionRecord::StakeHot));
ui->comboBoxSortType->addItem(tr("Delegated"), TransactionFilterProxy::TYPE(TransactionRecord::P2CSDelegationSent));
ui->comboBoxSortType->addItem(tr("Delegated"), TransactionFilterProxy::TYPE(TransactionRecord::P2CSDelegationSent) | TransactionFilterProxy::TYPE(TransactionRecord::P2CSDelegationSentOwner));
ui->comboBoxSortType->addItem(tr("Delegations"), TransactionFilterProxy::TYPE(TransactionRecord::P2CSDelegation));
ui->comboBoxSortType->setCurrentIndex(0);
connect(ui->comboBoxSortType, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(onSortTypeChanged(const QString&)));
Expand Down
4 changes: 4 additions & 0 deletions src/qt/pivx/txrow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ void TxRow::setType(bool isLightTheme, int type, bool isConfirmed){
css = "text-list-amount-unconfirmed";
break;
case TransactionRecord::P2CSDelegationSent:
case TransactionRecord::P2CSDelegationSentOwner:
path = "://ic-transaction-cs-contract";
css = "text-list-amount-send";
break;
case TransactionRecord::P2CSDelegation:
path = "://ic-transaction-cs-contract";
css = "text-list-amount-unconfirmed";
Expand Down
2 changes: 1 addition & 1 deletion src/qt/transactionfilterproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ bool TransactionFilterProxy::isStakeTx(int type) const {
}

bool TransactionFilterProxy::isColdStake(int type) const {
return (type == TransactionRecord::P2CSDelegation || type == TransactionRecord::P2CSDelegationSent || type == TransactionRecord::StakeDelegated || type == TransactionRecord::StakeHot);
return (type == TransactionRecord::P2CSDelegation || type == TransactionRecord::P2CSDelegationSent || type == TransactionRecord::P2CSDelegationSentOwner || type == TransactionRecord::StakeDelegated || type == TransactionRecord::StakeHot);
}

/*QVariant TransactionFilterProxy::dataFromSourcePos(int sourceRow, int role) const {
Expand Down
14 changes: 10 additions & 4 deletions src/qt/transactionrecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,11 +377,16 @@ void TransactionRecord::loadHotOrColdStakeOrContract(
break;
}
}
bool isSpendable = wallet->IsMine(p2csUtxo) & ISMINE_SPENDABLE_DELEGATED;

bool isSpendable = (wallet->IsMine(p2csUtxo) & ISMINE_SPENDABLE_DELEGATED);
bool isFromMe = wallet->IsFromMe(wtx);

if (isContract) {
if (isSpendable) {
if (isSpendable && isFromMe) {
// Wallet delegating balance
record.type = TransactionRecord::P2CSDelegationSentOwner;
} else if (isFromMe){
// Wallet delegating balance and transfering ownership
record.type = TransactionRecord::P2CSDelegationSent;
} else {
// Wallet receiving a delegation
Expand Down Expand Up @@ -529,8 +534,9 @@ bool TransactionRecord::isCoinStake() const
bool TransactionRecord::isAnyColdStakingType() const
{
return (type == TransactionRecord::P2CSDelegation || type == TransactionRecord::P2CSDelegationSent
|| type == TransactionRecord::StakeDelegated || type == TransactionRecord::StakeHot
|| type == TransactionRecord::P2CSUnlockOwner || type == TransactionRecord::P2CSUnlockStaker);
|| type == TransactionRecord::P2CSDelegationSentOwner
|| type == TransactionRecord::StakeDelegated || type == TransactionRecord::StakeHot
|| type == TransactionRecord::P2CSUnlockOwner || type == TransactionRecord::P2CSUnlockStaker);
}

bool TransactionRecord::isNull() const
Expand Down
3 changes: 2 additions & 1 deletion src/qt/transactionrecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ class TransactionRecord
StakeDelegated, // Received cold stake (owner)
StakeHot, // Staked via a delegated P2CS.
P2CSDelegation, // Non-spendable P2CS, staker side.
P2CSDelegationSent, // Spendable P2CS delegated utxo. (coin-owner)
P2CSDelegationSent, // Non-spendable P2CS delegated utxo. (coin-owner transferred ownership to external wallet)
P2CSDelegationSentOwner, // Spendable P2CS delegated utxo. (coin-owner)
P2CSUnlockOwner, // Coin-owner spent the delegated utxo
P2CSUnlockStaker // Staker watching the owner spent the delegated utxo
};
Expand Down
2 changes: 2 additions & 0 deletions src/qt/transactiontablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ QString TransactionTableModel::formatTxType(const TransactionRecord* wtx) const
case TransactionRecord::StakeHot:
return tr("PIV Stake on behalf of");
case TransactionRecord::P2CSDelegationSent:
case TransactionRecord::P2CSDelegationSentOwner:
case TransactionRecord::P2CSDelegation:
return tr("Stake delegation");
case TransactionRecord::Generated:
Expand Down Expand Up @@ -543,6 +544,7 @@ QString TransactionTableModel::formatTxToAddress(const TransactionRecord* wtx, b
return tr("Anonymous");
case TransactionRecord::P2CSDelegation:
case TransactionRecord::P2CSDelegationSent:
case TransactionRecord::P2CSDelegationSentOwner:
case TransactionRecord::StakeDelegated:
case TransactionRecord::StakeHot:
case TransactionRecord::SendToSelf: {
Expand Down

0 comments on commit fc766c8

Please sign in to comment.