From 6c9b342c306b9e17024762c4ba8f1c64e9810ee2 Mon Sep 17 00:00:00 2001 From: furszy Date: Wed, 18 Jan 2023 10:27:16 -0300 Subject: refactor: wallet, remove global 'ArgsManager' access we are not using it anymore --- src/qt/test/addressbooktests.cpp | 2 +- src/qt/test/wallettests.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/qt') diff --git a/src/qt/test/addressbooktests.cpp b/src/qt/test/addressbooktests.cpp index 049326070e..d005e08d14 100644 --- a/src/qt/test/addressbooktests.cpp +++ b/src/qt/test/addressbooktests.cpp @@ -75,7 +75,7 @@ void TestAddAddressesToSendBook(interfaces::Node& node) auto wallet_loader = interfaces::MakeWalletLoader(*test.m_node.chain, *Assert(test.m_node.args)); test.m_node.wallet_loader = wallet_loader.get(); node.setContext(&test.m_node); - const std::shared_ptr wallet = std::make_shared(node.context()->chain.get(), "", gArgs, CreateMockWalletDatabase()); + const std::shared_ptr wallet = std::make_shared(node.context()->chain.get(), "", CreateMockWalletDatabase()); wallet->LoadWallet(); wallet->SetWalletFlag(WALLET_FLAG_DESCRIPTORS); { diff --git a/src/qt/test/wallettests.cpp b/src/qt/test/wallettests.cpp index 15fe37c164..62f2019438 100644 --- a/src/qt/test/wallettests.cpp +++ b/src/qt/test/wallettests.cpp @@ -159,7 +159,7 @@ void TestGUI(interfaces::Node& node) auto wallet_loader = interfaces::MakeWalletLoader(*test.m_node.chain, *Assert(test.m_node.args)); test.m_node.wallet_loader = wallet_loader.get(); node.setContext(&test.m_node); - const std::shared_ptr wallet = std::make_shared(node.context()->chain.get(), "", gArgs, CreateMockWalletDatabase()); + const std::shared_ptr wallet = std::make_shared(node.context()->chain.get(), "", CreateMockWalletDatabase()); wallet->LoadWallet(); wallet->SetWalletFlag(WALLET_FLAG_DESCRIPTORS); { -- cgit v1.2.3 From 52f4d567d69425dfd514489079db80483024a80d Mon Sep 17 00:00:00 2001 From: furszy Date: Wed, 18 Jan 2023 10:40:08 -0300 Subject: refactor: remove include from wallet.h Since we no longer store a ref to the global `ArgsManager` inside the wallet, we can move the util/system.h include to the cpp. This dependency removal opened a can of worms, as few other places were, invalidly, depending on the wallet's header including it. --- src/qt/optionsmodel.cpp | 6 ++++++ src/qt/optionsmodel.h | 3 +++ src/qt/sendcoinsdialog.cpp | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src/qt') diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index 00b7952ca4..68f2139057 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -18,6 +18,7 @@ #include #include // for -dbcache defaults #include +#include #include // For DEFAULT_SCRIPTCHECK_THREADS #include // For DEFAULT_SPEND_ZEROCONF_CHANGE @@ -640,6 +641,11 @@ bool OptionsModel::isRestartRequired() const return settings.value("fRestartRequired", false).toBool(); } +bool OptionsModel::hasSigner() +{ + return gArgs.GetArg("-signer", "") != ""; +} + void OptionsModel::checkAndMigrate() { // Migration of default values diff --git a/src/qt/optionsmodel.h b/src/qt/optionsmodel.h index e36fbc5b31..ccab9c19ad 100644 --- a/src/qt/optionsmodel.h +++ b/src/qt/optionsmodel.h @@ -98,6 +98,9 @@ public: bool getEnablePSBTControls() const { return m_enable_psbt_controls; } const QString& getOverriddenByCommandLine() { return strOverriddenByCommandLine; } + /** Whether -signer was set or not */ + bool hasSigner(); + /* Explicit setters */ void SetPruneTargetGB(int prune_target_gb); diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index 1604cad503..4a50416fc6 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -203,7 +203,7 @@ void SendCoinsDialog::setModel(WalletModel *_model) if (model->wallet().hasExternalSigner()) { //: "device" usually means a hardware wallet. ui->sendButton->setText(tr("Sign on device")); - if (gArgs.GetArg("-signer", "") != "") { + if (model->getOptionsModel()->hasSigner()) { ui->sendButton->setEnabled(true); ui->sendButton->setToolTip(tr("Connect your hardware wallet first.")); } else { -- cgit v1.2.3