gui: Move actual migration part of migrate() to its own function
What changed, and why it matters
This commit is a simple code cleanup in the Bitcoin Core graphical wallet. It takes the actual wallet-migration steps out of the user-facing 'migrate' function and puts them into a new internal helper function called 'do_migrate'. The user confirmation dialog and the migration logic itself are unchanged; the code is just reorganized so the same migration steps can be reused later. There is no security issue visible here.
No action needed. Treat as routine refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change refactors MigrateWalletActivity in src/qt/walletcontroller.cpp/h. The original migrate() method combined a QMessageBox confirmation with passphrase collection and the actual walletLoader().migrateWallet() call. This commit extracts the passphrase/migration body into a private do_migrate() method, leaving migrate() to show the dialog and then call do_migrate(name). No logic, ordering, or trust boundaries changed.
Changed components
src/qt/walletcontroller.cppsrc/qt/walletcontroller.hInspect captured patch +21 / −15
diff --git a/src/qt/walletcontroller.cpp b/src/qt/walletcontroller.cpp
index b01e60e6..51e3b378 100644
--- a/src/qt/walletcontroller.cpp
+++ b/src/qt/walletcontroller.cpp
@@ -439,22 +439,8 @@ void RestoreWalletActivity::finish()
Q_EMIT finished();
}
-void MigrateWalletActivity::migrate(const std::string& name)
+void MigrateWalletActivity::do_migrate(const std::string& name)
{
- // Warn the user about migration
- QMessageBox box(m_parent_widget);
- box.setWindowTitle(tr("Migrate wallet"));
- box.setText(tr("Are you sure you wish to migrate the wallet <i>%1</i>?").arg(GUIUtil::HtmlEscape(GUIUtil::WalletDisplayName(name))));
- box.setInformativeText(tr("Migrating the wallet will convert this wallet to one or more descriptor wallets. A new wallet backup will need to be made.\n"
- "If this wallet contains any watchonly scripts, a new wallet will be created which contains those watchonly scripts.\n"
- "If this wallet contains any solvable but not watched scripts, a different and new wallet will be created which contains those scripts.\n\n"
- "The migration process will create a backup of the wallet before migrating. This backup file will be named "
- "<wallet name>-<timestamp>.legacy.bak and can be found in the directory for this wallet. In the event of "
- "an incorrect migration, the backup can be restored with the \"Restore Wallet\" functionality."));
- box.setStandardButtons(QMessageBox::Yes|QMessageBox::Cancel);
- box.setDefaultButton(QMessageBox::Yes);
- if (box.exec() != QMessageBox::Yes) return;
-
SecureString passphrase;
if (node().walletLoader().isEncrypted(name)) {
// Get the passphrase for the wallet
@@ -484,6 +470,25 @@ void MigrateWalletActivity::migrate(const std::string& name)
});
}
+void MigrateWalletActivity::migrate(const std::string& name)
+{
+ // Warn the user about migration
+ QMessageBox box(m_parent_widget);
+ box.setWindowTitle(tr("Migrate wallet"));
+ box.setText(tr("Are you sure you wish to migrate the wallet <i>%1</i>?").arg(GUIUtil::HtmlEscape(GUIUtil::WalletDisplayName(name))));
+ box.setInformativeText(tr("Migrating the wallet will convert this wallet to one or more descriptor wallets. A new wallet backup will need to be made.\n"
+ "If this wallet contains any watchonly scripts, a new wallet will be created which contains those watchonly scripts.\n"
+ "If this wallet contains any solvable but not watched scripts, a different and new wallet will be created which contains those scripts.\n\n"
+ "The migration process will create a backup of the wallet before migrating. This backup file will be named "
+ "<wallet name>-<timestamp>.legacy.bak and can be found in the directory for this wallet. In the event of "
+ "an incorrect migration, the backup can be restored with the \"Restore Wallet\" functionality."));
+ box.setStandardButtons(QMessageBox::Yes|QMessageBox::Cancel);
+ box.setDefaultButton(QMessageBox::Yes);
+ if (box.exec() != QMessageBox::Yes) return;
+
+ do_migrate(name);
+}
+
void MigrateWalletActivity::finish()
{
if (!m_error_message.empty()) {
diff --git a/src/qt/walletcontroller.h b/src/qt/walletcontroller.h
index 4d2ba435..a122c2f7 100644
--- a/src/qt/walletcontroller.h
+++ b/src/qt/walletcontroller.h
@@ -195,6 +195,7 @@ Q_SIGNALS:
private:
QString m_success_message;
+ void do_migrate(const std::string& name);
void finish();
};
Why this scored 15/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.