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.
This commit is contained in:
Ava Chow
2025-05-26 14:46:12 -07:00
parent 4ec2d18a07
commit 16ab6dfc10
2 changed files with 21 additions and 15 deletions

View File

@@ -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()) {

View File

@@ -195,6 +195,7 @@ Q_SIGNALS:
private:
QString m_success_message;
void do_migrate(const std::string& name);
void finish();
};