Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
502void MigrateWalletActivity::restore_and_migrate(const fs::path& path, const std::string& wallet_name)503{504// Warn the user about migration505QMessageBox box(m_parent_widget);506box.setWindowTitle(tr("Restore and Migrate wallet"));507box.setText(tr("Are you sure you wish to restore the wallet file <i>%1</i> to <i>%2</i> and migrate it?").arg(GUIUtil::HtmlEscape(fs::PathToString(path)), GUIUtil::HtmlEscape(GUIUtil::WalletDisplayName(wallet_name))));508box.setInformativeText(tr("Restoring the wallet will copy the backup file to the wallets directory and place it in the standard "509"wallet directory layout. The original file will not be modified.\n\n"510"Migrating the wallet will convert the restored wallet to one or more descriptor wallets. A new wallet backup will need to be made.\n"511"If this wallet contains any watchonly scripts, a new wallet will be created which contains those watchonly scripts.\n"512"If this wallet contains any solvable but not watched scripts, a different and new wallet will be created which contains those scripts.\n\n"513"The migration process will create a backup of the wallet before migrating. This backup file will be named "514"<wallet name>-<timestamp>.legacy.bak and can be found in the directory for this wallet. In the event of "515"an incorrect migration, the backup can be restored with the \"Restore Wallet\" functionality."));516box.setStandardButtons(QMessageBox::Yes|QMessageBox::Cancel);517box.setDefaultButton(QMessageBox::Yes);518if (box.exec() != QMessageBox::Yes) return;520showProgressDialog(521//: Title of progress window which is displayed when wallets are being restored.522tr("Restore Wallet"),523/*: Descriptive text of the restore wallets progress window which indicates to524the user that wallets are currently being restored.*/525tr("Restoring Wallet <b>%1</b>…").arg(GUIUtil::HtmlEscape(GUIUtil::WalletDisplayName(wallet_name))));527QTimer::singleShot(0, worker(), [this, path, wallet_name] {528auto res{node().walletLoader().restoreWallet(path, wallet_name, m_warning_message, /*load_after_restore=*/false)};530if (!res) {531m_error_message = util::ErrorString(res);532QTimer::singleShot(0, this, &MigrateWalletActivity::finish);533return;534}535QTimer::singleShot(0, this, [this, wallet_name] {536do_migrate(wallet_name, /*load_wallet=*/true);537});538});539}541void MigrateWalletActivity::finish()542{543if (!m_error_message.empty()) {544QMessageBox::critical(m_parent_widget, tr("Migration failed"), QString::fromStdString(m_error_message.translated));545} else {546QMessageBox::information(m_parent_widget, tr("Migration Successful"), m_success_message);547}549if (m_wallet_model) Q_EMIT migrated(m_wallet_model);551Q_EMIT finished();552}
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.