Skip to content

Commit c13f1fb

Browse files
committed
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.
1 parent 2acf773 commit c13f1fb

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

src/qt/walletcontroller.cpp

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -439,22 +439,8 @@ void RestoreWalletActivity::finish()
439439
Q_EMIT finished();
440440
}
441441

442-
void MigrateWalletActivity::migrate(const std::string& name)
442+
void MigrateWalletActivity::do_migrate(const std::string& name)
443443
{
444-
// Warn the user about migration
445-
QMessageBox box(m_parent_widget);
446-
box.setWindowTitle(tr("Migrate wallet"));
447-
box.setText(tr("Are you sure you wish to migrate the wallet <i>%1</i>?").arg(GUIUtil::HtmlEscape(GUIUtil::WalletDisplayName(name))));
448-
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"
449-
"If this wallet contains any watchonly scripts, a new wallet will be created which contains those watchonly scripts.\n"
450-
"If this wallet contains any solvable but not watched scripts, a different and new wallet will be created which contains those scripts.\n\n"
451-
"The migration process will create a backup of the wallet before migrating. This backup file will be named "
452-
"<wallet name>-<timestamp>.legacy.bak and can be found in the directory for this wallet. In the event of "
453-
"an incorrect migration, the backup can be restored with the \"Restore Wallet\" functionality."));
454-
box.setStandardButtons(QMessageBox::Yes|QMessageBox::Cancel);
455-
box.setDefaultButton(QMessageBox::Yes);
456-
if (box.exec() != QMessageBox::Yes) return;
457-
458444
SecureString passphrase;
459445
if (node().walletLoader().isEncrypted(name)) {
460446
// Get the passphrase for the wallet
@@ -484,6 +470,25 @@ void MigrateWalletActivity::migrate(const std::string& name)
484470
});
485471
}
486472

473+
void MigrateWalletActivity::migrate(const std::string& name)
474+
{
475+
// Warn the user about migration
476+
QMessageBox box(m_parent_widget);
477+
box.setWindowTitle(tr("Migrate wallet"));
478+
box.setText(tr("Are you sure you wish to migrate the wallet <i>%1</i>?").arg(GUIUtil::HtmlEscape(GUIUtil::WalletDisplayName(name))));
479+
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"
480+
"If this wallet contains any watchonly scripts, a new wallet will be created which contains those watchonly scripts.\n"
481+
"If this wallet contains any solvable but not watched scripts, a different and new wallet will be created which contains those scripts.\n\n"
482+
"The migration process will create a backup of the wallet before migrating. This backup file will be named "
483+
"<wallet name>-<timestamp>.legacy.bak and can be found in the directory for this wallet. In the event of "
484+
"an incorrect migration, the backup can be restored with the \"Restore Wallet\" functionality."));
485+
box.setStandardButtons(QMessageBox::Yes|QMessageBox::Cancel);
486+
box.setDefaultButton(QMessageBox::Yes);
487+
if (box.exec() != QMessageBox::Yes) return;
488+
489+
do_migrate(name);
490+
}
491+
487492
void MigrateWalletActivity::finish()
488493
{
489494
if (!m_error_message.empty()) {

src/qt/walletcontroller.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ class MigrateWalletActivity : public WalletControllerActivity
195195
private:
196196
QString m_success_message;
197197

198+
void do_migrate(const std::string& name);
198199
void finish();
199200
};
200201

0 commit comments

Comments
 (0)