Skip to content

Commit ed12fd8

Browse files
committed
Merge bitcoin#13966: gui: When private key is disabled, only show watch-only balance
82d6c5a gui: Show watch-only eye instead of HD disabled (Chun Kuan Lee) fe1ff50 Hide spendable label if priveate key is disabled (Chun Kuan Lee) Pull request description: If a wallet is in private key disabled mode, the spendable balance is always zero, it does not have to show on GUI. Show the watch-only balance at normal balance column if a wallet is in that mode. ![image](https://user-images.githubusercontent.com/11154118/45662527-dfaab400-bb34-11e8-98c8-c06ac5c0b08a.png) Tree-SHA512: 8b535427d26d3f8e61081f50e4773bd25656be042d378fd34cf647e9a0065cb4dfb67a8ab9fb4fbf5f196390df8cb983ebf2f0fa8a6503b7c046c56bec87ba72
2 parents 5ab5341 + 82d6c5a commit ed12fd8

File tree

3 files changed

+25
-17
lines changed

3 files changed

+25
-17
lines changed

src/qt/bitcoingui.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1089,10 +1089,10 @@ bool BitcoinGUI::handlePaymentRequest(const SendCoinsRecipient& recipient)
10891089
return false;
10901090
}
10911091

1092-
void BitcoinGUI::setHDStatus(int hdEnabled)
1092+
void BitcoinGUI::setHDStatus(bool privkeyDisabled, int hdEnabled)
10931093
{
1094-
labelWalletHDStatusIcon->setPixmap(platformStyle->SingleColorIcon(hdEnabled ? ":/icons/hd_enabled" : ":/icons/hd_disabled").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
1095-
labelWalletHDStatusIcon->setToolTip(hdEnabled ? tr("HD key generation is <b>enabled</b>") : tr("HD key generation is <b>disabled</b>"));
1094+
labelWalletHDStatusIcon->setPixmap(platformStyle->SingleColorIcon(privkeyDisabled ? ":/icons/eye" : hdEnabled ? ":/icons/hd_enabled" : ":/icons/hd_disabled").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
1095+
labelWalletHDStatusIcon->setToolTip(privkeyDisabled ? tr("Private key <b>disabled</b>") : hdEnabled ? tr("HD key generation is <b>enabled</b>") : tr("HD key generation is <b>disabled</b>"));
10961096

10971097
// eventually disable the QLabel to set its opacity to 50%
10981098
labelWalletHDStatusIcon->setEnabled(hdEnabled);
@@ -1138,7 +1138,7 @@ void BitcoinGUI::updateWalletStatus()
11381138
}
11391139
WalletModel * const walletModel = walletView->getWalletModel();
11401140
setEncryptionStatus(walletModel->getEncryptionStatus());
1141-
setHDStatus(walletModel->wallet().hdEnabled());
1141+
setHDStatus(walletModel->privateKeysDisabled(), walletModel->wallet().hdEnabled());
11421142
}
11431143
#endif // ENABLE_WALLET
11441144

src/qt/bitcoingui.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ public Q_SLOTS:
223223
@param[in] hdEnabled current hd enabled status
224224
@see WalletModel::EncryptionStatus
225225
*/
226-
void setHDStatus(int hdEnabled);
226+
void setHDStatus(bool privkeyDisabled, int hdEnabled);
227227

228228
public Q_SLOTS:
229229
bool handlePaymentRequest(const SendCoinsRecipient& recipient);

src/qt/overviewpage.cpp

+20-12
Original file line numberDiff line numberDiff line change
@@ -161,15 +161,21 @@ void OverviewPage::setBalance(const interfaces::WalletBalances& balances)
161161
{
162162
int unit = walletModel->getOptionsModel()->getDisplayUnit();
163163
m_balances = balances;
164-
ui->labelBalance->setText(BitcoinUnits::formatWithUnit(unit, balances.balance, false, BitcoinUnits::separatorAlways));
165-
ui->labelUnconfirmed->setText(BitcoinUnits::formatWithUnit(unit, balances.unconfirmed_balance, false, BitcoinUnits::separatorAlways));
166-
ui->labelImmature->setText(BitcoinUnits::formatWithUnit(unit, balances.immature_balance, false, BitcoinUnits::separatorAlways));
167-
ui->labelTotal->setText(BitcoinUnits::formatWithUnit(unit, balances.balance + balances.unconfirmed_balance + balances.immature_balance, false, BitcoinUnits::separatorAlways));
168-
ui->labelWatchAvailable->setText(BitcoinUnits::formatWithUnit(unit, balances.watch_only_balance, false, BitcoinUnits::separatorAlways));
169-
ui->labelWatchPending->setText(BitcoinUnits::formatWithUnit(unit, balances.unconfirmed_watch_only_balance, false, BitcoinUnits::separatorAlways));
170-
ui->labelWatchImmature->setText(BitcoinUnits::formatWithUnit(unit, balances.immature_watch_only_balance, false, BitcoinUnits::separatorAlways));
171-
ui->labelWatchTotal->setText(BitcoinUnits::formatWithUnit(unit, balances.watch_only_balance + balances.unconfirmed_watch_only_balance + balances.immature_watch_only_balance, false, BitcoinUnits::separatorAlways));
172-
164+
if (walletModel->privateKeysDisabled()) {
165+
ui->labelBalance->setText(BitcoinUnits::formatWithUnit(unit, balances.watch_only_balance, false, BitcoinUnits::separatorAlways));
166+
ui->labelUnconfirmed->setText(BitcoinUnits::formatWithUnit(unit, balances.unconfirmed_watch_only_balance, false, BitcoinUnits::separatorAlways));
167+
ui->labelImmature->setText(BitcoinUnits::formatWithUnit(unit, balances.immature_watch_only_balance, false, BitcoinUnits::separatorAlways));
168+
ui->labelTotal->setText(BitcoinUnits::formatWithUnit(unit, balances.watch_only_balance + balances.unconfirmed_watch_only_balance + balances.immature_watch_only_balance, false, BitcoinUnits::separatorAlways));
169+
} else {
170+
ui->labelBalance->setText(BitcoinUnits::formatWithUnit(unit, balances.balance, false, BitcoinUnits::separatorAlways));
171+
ui->labelUnconfirmed->setText(BitcoinUnits::formatWithUnit(unit, balances.unconfirmed_balance, false, BitcoinUnits::separatorAlways));
172+
ui->labelImmature->setText(BitcoinUnits::formatWithUnit(unit, balances.immature_balance, false, BitcoinUnits::separatorAlways));
173+
ui->labelTotal->setText(BitcoinUnits::formatWithUnit(unit, balances.balance + balances.unconfirmed_balance + balances.immature_balance, false, BitcoinUnits::separatorAlways));
174+
ui->labelWatchAvailable->setText(BitcoinUnits::formatWithUnit(unit, balances.watch_only_balance, false, BitcoinUnits::separatorAlways));
175+
ui->labelWatchPending->setText(BitcoinUnits::formatWithUnit(unit, balances.unconfirmed_watch_only_balance, false, BitcoinUnits::separatorAlways));
176+
ui->labelWatchImmature->setText(BitcoinUnits::formatWithUnit(unit, balances.immature_watch_only_balance, false, BitcoinUnits::separatorAlways));
177+
ui->labelWatchTotal->setText(BitcoinUnits::formatWithUnit(unit, balances.watch_only_balance + balances.unconfirmed_watch_only_balance + balances.immature_watch_only_balance, false, BitcoinUnits::separatorAlways));
178+
}
173179
// only show immature (newly mined) balance if it's non-zero, so as not to complicate things
174180
// for the non-mining users
175181
bool showImmature = balances.immature_balance != 0;
@@ -178,7 +184,7 @@ void OverviewPage::setBalance(const interfaces::WalletBalances& balances)
178184
// for symmetry reasons also show immature label when the watch-only one is shown
179185
ui->labelImmature->setVisible(showImmature || showWatchOnlyImmature);
180186
ui->labelImmatureText->setVisible(showImmature || showWatchOnlyImmature);
181-
ui->labelWatchImmature->setVisible(showWatchOnlyImmature); // show watch-only immature balance
187+
ui->labelWatchImmature->setVisible(!walletModel->privateKeysDisabled() && showWatchOnlyImmature); // show watch-only immature balance
182188
}
183189

184190
// show/hide watch-only labels
@@ -231,8 +237,10 @@ void OverviewPage::setWalletModel(WalletModel *model)
231237

232238
connect(model->getOptionsModel(), &OptionsModel::displayUnitChanged, this, &OverviewPage::updateDisplayUnit);
233239

234-
updateWatchOnlyLabels(wallet.haveWatchOnly());
235-
connect(model, &WalletModel::notifyWatchonlyChanged, this, &OverviewPage::updateWatchOnlyLabels);
240+
updateWatchOnlyLabels(wallet.haveWatchOnly() && !model->privateKeysDisabled());
241+
connect(model, &WalletModel::notifyWatchonlyChanged, [this](bool showWatchOnly) {
242+
updateWatchOnlyLabels(showWatchOnly && !walletModel->privateKeysDisabled());
243+
});
236244
}
237245

238246
// update the display unit, to not use the default ("BTC")

0 commit comments

Comments
 (0)