Skip to content

Commit

Permalink
Merge #1470: [GUI] Mark delegated UTXOs in CoinControl
Browse files Browse the repository at this point in the history
1ef737b [GUI] coin control: add icon and tooltip for delegated UTXOs (random-zebra)

Pull request description:

  Implemented on top of:
  - [x] #1469

  (only last commit is new)

  **Problem**: As outlined in the description of #1391, delegated outputs are not clearly distinguishable in the coin control dialog.

  **Proposed Solution**: Add a "cold staking icon" (purple snow flake) at the end of delegated utxo rows. Hovering on this icon shows a tooltip with the staker address which has received the delegation.

  ![ccontrol1](https://user-images.githubusercontent.com/18186894/77853074-650b2c00-71e2-11ea-8908-926b39f9e230.png)

  <br>

  ![ccontrol2](https://user-images.githubusercontent.com/18186894/77853078-69374980-71e2-11ea-839a-53a2b0a83d20.png)

ACKs for top commit:
  Fuzzbawls:
    ACK 1ef737b
  furszy:
    utACK 1ef737b .

Tree-SHA512: 4da7c478ef8b2463bc80e002e25f6da4b2e18e47afbb024fa344945dbbe5dfc3b0fb75c6e821d67d19b373cf123aad1c827dfcf37b412d0fda5d8cd279aa5fff
  • Loading branch information
furszy committed Apr 7, 2020
2 parents ca26229 + 1ef737b commit 02ede33
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions src/qt/coincontroldialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,11 @@ void CoinControlDialog::buttonToggleLockClicked()
if (model->isLockedCoin(uint256(item->text(COLUMN_TXHASH).toStdString()), item->text(COLUMN_VOUT_INDEX).toUInt())) {
model->unlockCoin(outpt);
item->setDisabled(false);
item->setIcon(COLUMN_CHECKBOX, QIcon());
// restore cold-stake snowflake icon for P2CS which were previously locked
if (item->data(COLUMN_CHECKBOX, Qt::UserRole) == QString("Delegated"))
item->setIcon(COLUMN_CHECKBOX, QIcon("://ic-check-cold-staking-off"));
else
item->setIcon(COLUMN_CHECKBOX, QIcon());
} else {
model->lockCoin(outpt);
item->setDisabled(true);
Expand Down Expand Up @@ -364,7 +368,11 @@ void CoinControlDialog::unlockCoin()
COutPoint outpt(uint256(contextMenuItem->text(COLUMN_TXHASH).toStdString()), contextMenuItem->text(COLUMN_VOUT_INDEX).toUInt());
model->unlockCoin(outpt);
contextMenuItem->setDisabled(false);
contextMenuItem->setIcon(COLUMN_CHECKBOX, QIcon());
// restore cold-stake snowflake icon for P2CS which were previously locked
if (contextMenuItem->data(COLUMN_CHECKBOX, Qt::UserRole) == QString("Delegated"))
contextMenuItem->setIcon(COLUMN_CHECKBOX, QIcon("://ic-check-cold-staking-off"));
else
contextMenuItem->setIcon(COLUMN_CHECKBOX, QIcon());
updateLabelLocked();
}

Expand Down Expand Up @@ -836,9 +844,23 @@ void CoinControlDialog::updateView()
}

// address
const bool fDelegated = (bool)(mine & ISMINE_SPENDABLE_DELEGATED);
CTxDestination outputAddress;
CTxDestination outputAddressStaker;
QString sAddress = "";
if (ExtractDestination(out.tx->vout[out.i].scriptPubKey, outputAddress)) {
bool haveDest = false;
if (fDelegated) {
txnouttype type; std::vector<CTxDestination> addresses; int nRequired;
haveDest = (ExtractDestinations(out.tx->vout[out.i].scriptPubKey, type, addresses, nRequired)
&& addresses.size() == 2);
if (haveDest) {
outputAddressStaker = addresses[0];
outputAddress = addresses[1];
}
} else {
haveDest = ExtractDestination(out.tx->vout[out.i].scriptPubKey, outputAddress);
}
if (haveDest) {
sAddress = QString::fromStdString(CBitcoinAddress(outputAddress).ToString());

// if listMode or change => show PIVX address. In tree mode, address is not shown again for direct wallet address outputs
Expand Down Expand Up @@ -891,6 +913,16 @@ void CoinControlDialog::updateView()
// vout index
itemOutput->setText(COLUMN_VOUT_INDEX, QString::number(out.i));

// outputs delegated (for cold staking)
if (fDelegated) {
itemOutput->setData(COLUMN_CHECKBOX, Qt::UserRole, QString("Delegated"));
itemOutput->setIcon(COLUMN_CHECKBOX, QIcon("://ic-check-cold-staking-off"));
if (haveDest) {
sAddress = QString::fromStdString(CBitcoinAddress(outputAddressStaker, CChainParams::STAKING_ADDRESS).ToString());
itemOutput->setToolTip(COLUMN_CHECKBOX, tr("delegated to %1 for cold staking").arg(sAddress));
}
}

// disable locked coins
if (model->isLockedCoin(txhash, out.i)) {
COutPoint outpt(txhash, out.i);
Expand Down

0 comments on commit 02ede33

Please sign in to comment.