wallet, interfaces, gui: Expose load_after_restore parameter
What changed, and why it matters
This commit is a small, non-security code cleanup. It exposes an existing internal option called load_after_restore through the wallet interface so that callers can choose whether a restored wallet should be loaded automatically. The GUI code is updated to pass true, preserving the previous behavior. There is no indication this fixes a vulnerability or introduces a security risk.
No security action required. Review as normal code-quality change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change threads a pre-existing bool parameter through the wallet interface layer. restoreWallet in interfaces/wallet.h gains a load_after_restore argument, the implementation in wallet/interfaces.cpp forwards it to the underlying RestoreWallet helper, and qt/walletcontroller.cpp explicitly passes true. The implementation also changes error handling to return util::Error only when error is non-empty rather than when wallet is null, which is a minor robustness improvement but not a security fix.
Changed components
src/interfaces/wallet.hsrc/wallet/interfaces.cppsrc/qt/walletcontroller.cppInspect captured patch +6 / −7
diff --git a/src/interfaces/wallet.h b/src/interfaces/wallet.h
index 2ccd514d..5a84099c 100644
--- a/src/interfaces/wallet.h
+++ b/src/interfaces/wallet.h
@@ -325,7 +325,7 @@ public:
virtual std::string getWalletDir() = 0;
//! Restore backup wallet
- virtual util::Result<std::unique_ptr<Wallet>> restoreWallet(const fs::path& backup_file, const std::string& wallet_name, std::vector<bilingual_str>& warnings) = 0;
+ virtual util::Result<std::unique_ptr<Wallet>> restoreWallet(const fs::path& backup_file, const std::string& wallet_name, std::vector<bilingual_str>& warnings, bool load_after_restore) = 0;
//! Migrate a wallet
virtual util::Result<WalletMigrationResult> migrateWallet(const std::string& name, const SecureString& passphrase) = 0;
diff --git a/src/qt/walletcontroller.cpp b/src/qt/walletcontroller.cpp
index 869f9614..b01e60e6 100644
--- a/src/qt/walletcontroller.cpp
+++ b/src/qt/walletcontroller.cpp
@@ -409,7 +409,7 @@ void RestoreWalletActivity::restore(const fs::path& backup_file, const std::stri
tr("Restoring Wallet <b>%1</b>…").arg(name.toHtmlEscaped()));
QTimer::singleShot(0, worker(), [this, backup_file, wallet_name] {
- auto wallet{node().walletLoader().restoreWallet(backup_file, wallet_name, m_warning_message)};
+ auto wallet{node().walletLoader().restoreWallet(backup_file, wallet_name, m_warning_message, /*load_after_restore=*/true)};
if (wallet) {
m_wallet_model = m_wallet_controller->getOrCreateWallet(std::move(*wallet));
diff --git a/src/wallet/interfaces.cpp b/src/wallet/interfaces.cpp
index 2cda1ba2..585ed7c7 100644
--- a/src/wallet/interfaces.cpp
+++ b/src/wallet/interfaces.cpp
@@ -597,16 +597,15 @@ public:
return util::Error{error};
}
}
- util::Result<std::unique_ptr<Wallet>> restoreWallet(const fs::path& backup_file, const std::string& wallet_name, std::vector<bilingual_str>& warnings) override
+ util::Result<std::unique_ptr<Wallet>> restoreWallet(const fs::path& backup_file, const std::string& wallet_name, std::vector<bilingual_str>& warnings, bool load_after_restore) override
{
DatabaseStatus status;
bilingual_str error;
- std::unique_ptr<Wallet> wallet{MakeWallet(m_context, RestoreWallet(m_context, backup_file, wallet_name, /*load_on_start=*/true, status, error, warnings))};
- if (wallet) {
- return wallet;
- } else {
+ std::unique_ptr<Wallet> wallet{MakeWallet(m_context, RestoreWallet(m_context, backup_file, wallet_name, /*load_on_start=*/true, status, error, warnings, load_after_restore))};
+ if (!error.empty()) {
return util::Error{error};
}
+ return wallet;
}
util::Result<WalletMigrationResult> migrateWallet(const std::string& name, const SecureString& passphrase) override
{
Why this scored 18/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.