From 16ab6dfc1074b43c6fa80181574dc6e77b9aae1c Mon Sep 17 00:00:00 2001 From: Ava Chow Date: Mon, 26 May 2025 14:46:12 -0700 Subject: [PATCH] gui: Move actual migration part of migrate() to its own function We will need to use the same migration code in a later commit, so first move it to a separate function. --- src/qt/walletcontroller.cpp | 35 ++++++++++++++++++++--------------- src/qt/walletcontroller.h | 1 + 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/qt/walletcontroller.cpp b/src/qt/walletcontroller.cpp index b01e60e6a17..51e3b3780ff 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 %1?").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 " - "-.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 %1?").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 " + "-.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 4d2ba435392..a122c2f7183 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(); };