diff --git a/src/interfaces/wallet.h b/src/interfaces/wallet.h
--- a/src/interfaces/wallet.h
+++ b/src/interfaces/wallet.h
@@ -241,8 +241,8 @@
// Return whether the wallet is blank.
virtual bool canGetAddresses() = 0;
- // Check if a certain wallet flag is set.
- virtual bool IsWalletFlagSet(uint64_t flag) = 0;
+ // Return whether private keys enabled.
+ virtual bool privateKeysDisabled() = 0;
// Get default address type.
virtual OutputType getDefaultAddressType() = 0;
diff --git a/src/interfaces/wallet.cpp b/src/interfaces/wallet.cpp
--- a/src/interfaces/wallet.cpp
+++ b/src/interfaces/wallet.cpp
@@ -401,8 +401,8 @@
return m_wallet->m_default_address_type;
}
bool canGetAddresses() override { return m_wallet->CanGetAddresses(); }
- bool IsWalletFlagSet(uint64_t flag) override {
- return m_wallet->IsWalletFlagSet(flag);
+ bool privateKeysDisabled() override {
+ return m_wallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS);
}
OutputType getDefaultChangeType() override {
return m_wallet->m_default_change_type;
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -1409,7 +1409,7 @@
}
WalletModel *const walletModel = walletView->getWalletModel();
setEncryptionStatus(walletModel->getEncryptionStatus());
- setHDStatus(walletModel->privateKeysDisabled(),
+ setHDStatus(walletModel->wallet().privateKeysDisabled(),
walletModel->wallet().hdEnabled());
}
#endif // ENABLE_WALLET
diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp
--- a/src/qt/overviewpage.cpp
+++ b/src/qt/overviewpage.cpp
@@ -165,7 +165,7 @@
void OverviewPage::setBalance(const interfaces::WalletBalances &balances) {
int unit = walletModel->getOptionsModel()->getDisplayUnit();
m_balances = balances;
- if (walletModel->privateKeysDisabled()) {
+ if (walletModel->wallet().privateKeysDisabled()) {
ui->labelBalance->setText(
BitcoinUnits::formatWithUnit(unit, balances.watch_only_balance,
false, BitcoinUnits::separatorAlways));
@@ -223,8 +223,8 @@
ui->labelImmature->setVisible(showImmature || showWatchOnlyImmature);
ui->labelImmatureText->setVisible(showImmature || showWatchOnlyImmature);
// show watch-only immature balance
- ui->labelWatchImmature->setVisible(!walletModel->privateKeysDisabled() &&
- showWatchOnlyImmature);
+ ui->labelWatchImmature->setVisible(
+ !walletModel->wallet().privateKeysDisabled() && showWatchOnlyImmature);
}
// show/hide watch-only labels
@@ -283,11 +283,12 @@
this, &OverviewPage::updateDisplayUnit);
updateWatchOnlyLabels(wallet.haveWatchOnly() &&
- !model->privateKeysDisabled());
+ !model->wallet().privateKeysDisabled());
connect(model, &WalletModel::notifyWatchonlyChanged,
[this](bool showWatchOnly) {
- updateWatchOnlyLabels(showWatchOnly &&
- !walletModel->privateKeysDisabled());
+ updateWatchOnlyLabels(
+ showWatchOnly &&
+ !walletModel->wallet().privateKeysDisabled());
});
}
diff --git a/src/qt/receivecoinsdialog.cpp b/src/qt/receivecoinsdialog.cpp
--- a/src/qt/receivecoinsdialog.cpp
+++ b/src/qt/receivecoinsdialog.cpp
@@ -107,12 +107,12 @@
// Set the button to be enabled or disabled based on whether the wallet
// can give out new addresses.
- ui->receiveButton->setEnabled(model->canGetAddresses());
+ ui->receiveButton->setEnabled(model->wallet().canGetAddresses());
// Enable/disable the receive button if the wallet is now able/unable to
// give out new addresses.
connect(model, &WalletModel::canGetAddressesChanged, [this] {
- ui->receiveButton->setEnabled(model->canGetAddresses());
+ ui->receiveButton->setEnabled(model->wallet().canGetAddresses());
});
}
}
diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp
--- a/src/qt/sendcoinsdialog.cpp
+++ b/src/qt/sendcoinsdialog.cpp
@@ -218,7 +218,7 @@
updateMinFeeLabel();
updateSmartFeeLabel();
- if (model->privateKeysDisabled()) {
+ if (model->wallet().privateKeysDisabled()) {
ui->sendButton->setText(tr("Cr&eate Unsigned"));
ui->sendButton->setToolTip(
tr("Creates a Partially Signed Bitcoin Transaction (PSBT) for "
@@ -349,14 +349,14 @@
}
QString questionString;
- if (model->privateKeysDisabled()) {
+ if (model->wallet().privateKeysDisabled()) {
questionString.append(tr("Do you want to draft this transaction?"));
} else {
questionString.append(tr("Are you sure you want to send?"));
}
questionString.append("
");
- if (model->privateKeysDisabled()) {
+ if (model->wallet().privateKeysDisabled()) {
questionString.append(
tr("Please, review your transaction proposal. This will produce a "
"Partially Signed Bitcoin Transaction (PSBT) which you can copy "
@@ -420,10 +420,10 @@
questionString = questionString.arg("
" + formatted.at(0));
}
- const QString confirmation = model->privateKeysDisabled()
+ const QString confirmation = model->wallet().privateKeysDisabled()
? tr("Confirm transaction proposal")
: tr("Confirm send coins");
- const QString confirmButtonText = model->privateKeysDisabled()
+ const QString confirmButtonText = model->wallet().privateKeysDisabled()
? tr("Copy PSBT to clipboard")
: tr("Send");
SendConfirmationDialog confirmationDialog(
@@ -439,7 +439,7 @@
}
bool send_failure = false;
- if (model->privateKeysDisabled()) {
+ if (model->wallet().privateKeysDisabled()) {
CMutableTransaction mtx =
CMutableTransaction{*(currentTransaction.getWtx())};
PartiallySignedTransaction psbtx(mtx);
@@ -699,7 +699,7 @@
}
// Include watch-only for wallets without private key
- coin_control.fAllowWatchOnly = model->privateKeysDisabled();
+ coin_control.fAllowWatchOnly = model->wallet().privateKeysDisabled();
// Calculate available amount to send.
Amount amount = model->wallet().getAvailableBalance(coin_control);
@@ -771,7 +771,7 @@
ctrl.m_feerate.reset();
}
// Include watch-only for wallets without private key
- ctrl.fAllowWatchOnly = model->privateKeysDisabled();
+ ctrl.fAllowWatchOnly = model->wallet().privateKeysDisabled();
}
void SendCoinsDialog::updateSmartFeeLabel() {
diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h
--- a/src/qt/walletmodel.h
+++ b/src/qt/walletmodel.h
@@ -144,8 +144,6 @@
const std::string &sRequest);
static bool isWalletEnabled();
- bool privateKeysDisabled() const;
- bool canGetAddresses() const;
interfaces::Node &node() const { return m_node; }
interfaces::Wallet &wallet() const { return *m_wallet; }
diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp
--- a/src/qt/walletmodel.cpp
+++ b/src/qt/walletmodel.cpp
@@ -18,7 +18,7 @@
#include // for GetBoolArg
#include
#include
-#include
+#include // for CRecipient
#include
#include
@@ -202,9 +202,9 @@
bilingual_str error;
auto &newTx = transaction.getWtx();
- newTx = m_wallet->createTransaction(vecSend, coinControl,
- !privateKeysDisabled() /* sign */,
- nChangePosRet, nFeeRequired, error);
+ newTx = m_wallet->createTransaction(
+ vecSend, coinControl, !wallet().privateKeysDisabled() /* sign */,
+ nChangePosRet, nFeeRequired, error);
transaction.setTransactionFee(nFeeRequired);
if (fSubtractFeeFromAmount && newTx) {
transaction.reassignAmounts(nChangePosRet);
@@ -504,14 +504,6 @@
return !gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET);
}
-bool WalletModel::privateKeysDisabled() const {
- return m_wallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS);
-}
-
-bool WalletModel::canGetAddresses() const {
- return m_wallet->canGetAddresses();
-}
-
QString WalletModel::getWalletName() const {
return QString::fromStdString(m_wallet->getWalletName());
}