Skip to content

Commit c7b8f34

Browse files
committed
[Qt] Disable creating receive addresses when private keys are disabled
1 parent 2f15c2b commit c7b8f34

File tree

5 files changed

+13
-0
lines changed

5 files changed

+13
-0
lines changed

src/interfaces/wallet.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ class WalletImpl : public Wallet
426426
}
427427
unsigned int getConfirmTarget() override { return m_wallet.m_confirm_target; }
428428
bool hdEnabled() override { return m_wallet.IsHDEnabled(); }
429+
bool IsWalletFlagSet(uint64_t flag) override { return m_wallet.IsWalletFlagSet(flag); }
429430
OutputType getDefaultAddressType() override { return m_wallet.m_default_address_type; }
430431
OutputType getDefaultChangeType() override { return m_wallet.m_default_change_type; }
431432
std::unique_ptr<Handler> handleUnload(UnloadFn fn) override

src/interfaces/wallet.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,9 @@ class Wallet
236236
// Return whether HD enabled.
237237
virtual bool hdEnabled() = 0;
238238

239+
// check if a certain wallet flag is set.
240+
virtual bool IsWalletFlagSet(uint64_t flag) = 0;
241+
239242
// Get default address type.
240243
virtual OutputType getDefaultAddressType() = 0;
241244

src/qt/receivecoinsdialog.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ void ReceiveCoinsDialog::setModel(WalletModel *_model)
9999
} else {
100100
ui->useBech32->setCheckState(Qt::Unchecked);
101101
}
102+
103+
// eventually disable the main receive button if private key operations are disabled
104+
ui->receiveButton->setEnabled(!model->privateKeysDisabled());
102105
}
103106
}
104107

src/qt/walletmodel.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,11 @@ bool WalletModel::isWalletEnabled()
558558
return !gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET);
559559
}
560560

561+
bool WalletModel::privateKeysDisabled() const
562+
{
563+
return m_wallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS);
564+
}
565+
561566
QString WalletModel::getWalletName() const
562567
{
563568
return QString::fromStdString(m_wallet->getWalletName());

src/qt/walletmodel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ class WalletModel : public QObject
197197
bool bumpFee(uint256 hash);
198198

199199
static bool isWalletEnabled();
200+
bool privateKeysDisabled() const;
200201

201202
interfaces::Node& node() const { return m_node; }
202203
interfaces::Wallet& wallet() const { return *m_wallet; }

0 commit comments

Comments
 (0)