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.
251tr("Create Wallet"),252/*: Descriptive text of the create wallet progress window which indicates253to the user which wallet is currently being created. */254tr("Creating Wallet <b>%1</b>…").arg(m_create_wallet_dialog->walletName().toHtmlEscaped()));256std::string name = m_create_wallet_dialog->walletName().toStdString();257uint64_t flags = 0;258// Enable descriptors by default.259flags |= WALLET_FLAG_DESCRIPTORS;260if (m_create_wallet_dialog->isDisablePrivateKeysChecked()) {261flags |= WALLET_FLAG_DISABLE_PRIVATE_KEYS;262}263if (m_create_wallet_dialog->isMakeBlankWalletChecked()) {264flags |= WALLET_FLAG_BLANK_WALLET;265}266if (m_create_wallet_dialog->isExternalSignerChecked()) {267flags |= WALLET_FLAG_EXTERNAL_SIGNER;268}270QTimer::singleShot(500ms, worker(), [this, name, flags] {271auto wallet{node().walletLoader().createWallet(name, m_passphrase, flags, m_warning_message)};273if (wallet) {274m_wallet_model = m_wallet_controller->getOrCreateWallet(std::move(*wallet));275} else {276m_error_message = util::ErrorString(wallet);277}279QTimer::singleShot(500ms, this, &CreateWalletActivity::finish);280});281}283void CreateWalletActivity::finish()284{285if (!m_error_message.empty()) {286QMessageBox::critical(m_parent_widget, tr("Create wallet failed"), QString::fromStdString(m_error_message.translated));287} else if (!m_warning_message.empty()) {288QMessageBox::warning(m_parent_widget, tr("Create wallet warning"), QString::fromStdString(Join(m_warning_message, Untranslated("\n")).translated));289}291if (m_wallet_model) Q_EMIT created(m_wallet_model);293Q_EMIT finished();294}296void CreateWalletActivity::create()297{298m_create_wallet_dialog = new CreateWalletDialog(m_parent_widget);300std::vector<std::unique_ptr<interfaces::ExternalSigner>> signers;301try {302signers = node().listExternalSigners();303} catch (const std::runtime_error& e) {304QMessageBox::critical(nullptr, tr("Can't list signers"), e.what());305}306if (signers.size() > 1) {307QMessageBox::critical(nullptr, tr("Too many external signers found"), QString::fromStdString("More than one external signer found. Please connect only one at a time."));308signers.clear();309}310m_create_wallet_dialog->setSigners(signers);312m_create_wallet_dialog->setWindowModality(Qt::ApplicationModal);313m_create_wallet_dialog->show();315connect(m_create_wallet_dialog, &QObject::destroyed, [this] {316m_create_wallet_dialog = nullptr;317});318connect(m_create_wallet_dialog, &QDialog::rejected, [this] {319Q_EMIT finished();320});321connect(m_create_wallet_dialog, &QDialog::accepted, [this] {322if (m_create_wallet_dialog->isEncryptWalletChecked()) {323askPassphrase();324} else {325createWallet();326}327});328}330OpenWalletActivity::OpenWalletActivity(WalletController* wallet_controller, QWidget* parent_widget)331: WalletControllerActivity(wallet_controller, parent_widget)332{333}335void OpenWalletActivity::finish()336{337if (!m_error_message.empty()) {338QMessageBox::critical(m_parent_widget, tr("Open wallet failed"), QString::fromStdString(m_error_message.translated));339} else if (!m_warning_message.empty()) {340QMessageBox::warning(m_parent_widget, tr("Open wallet warning"), QString::fromStdString(Join(m_warning_message, Untranslated("\n")).translated));341}343if (m_wallet_model) Q_EMIT opened(m_wallet_model);345Q_EMIT finished();346}348void OpenWalletActivity::open(const std::string& path)349{350QString name = GUIUtil::WalletDisplayName(path);352showProgressDialog(353//: Title of window indicating the progress of opening of a wallet.354tr("Open Wallet"),355/*: Descriptive text of the open wallet progress window which indicates356to the user which wallet is currently being opened. */357tr("Opening Wallet <b>%1</b>…").arg(name.toHtmlEscaped()));359QTimer::singleShot(0, worker(), [this, path] {360auto wallet{node().walletLoader().loadWallet(path, m_warning_message)};362if (wallet) {363m_wallet_model = m_wallet_controller->getOrCreateWallet(std::move(*wallet));364} else {365m_error_message = util::ErrorString(wallet);366}368QTimer::singleShot(0, this, &OpenWalletActivity::finish);369});370}372LoadWalletsActivity::LoadWalletsActivity(WalletController* wallet_controller, QWidget* parent_widget)373: WalletControllerActivity(wallet_controller, parent_widget)374{375}377void LoadWalletsActivity::load(bool show_loading_minimized)378{379showProgressDialog(380//: Title of progress window which is displayed when wallets are being loaded.381tr("Load Wallets"),382/*: Descriptive text of the load wallets progress window which indicates to383the user that wallets are currently being loaded.*/384tr("Loading wallets…"),385/*show_minimized=*/show_loading_minimized);387QTimer::singleShot(0, worker(), [this] {388for (auto& wallet : node().walletLoader().getWallets()) {389m_wallet_controller->getOrCreateWallet(std::move(wallet));390}392QTimer::singleShot(0, this, [this] { Q_EMIT finished(); });393});394}396RestoreWalletActivity::RestoreWalletActivity(WalletController* wallet_controller, QWidget* parent_widget)397: WalletControllerActivity(wallet_controller, parent_widget)398{399}401void RestoreWalletActivity::restore(const fs::path& backup_file, const std::string& wallet_name)402{403QString name = QString::fromStdString(wallet_name);405showProgressDialog(406//: Title of progress window which is displayed when wallets are being restored.407tr("Restore Wallet"),408/*: Descriptive text of the restore wallets progress window which indicates to409the user that wallets are currently being restored.*/410tr("Restoring Wallet <b>%1</b>…").arg(name.toHtmlEscaped()));412QTimer::singleShot(0, worker(), [this, backup_file, wallet_name] {413auto wallet{node().walletLoader().restoreWallet(backup_file, wallet_name, m_warning_message, /*load_after_restore=*/true)};415if (wallet) {416m_wallet_model = m_wallet_controller->getOrCreateWallet(std::move(*wallet));417} else {418m_error_message = util::ErrorString(wallet);419}421QTimer::singleShot(0, this, &RestoreWalletActivity::finish);422});423}425void RestoreWalletActivity::finish()426{427if (!m_error_message.empty()) {428//: Title of message box which is displayed when the wallet could not be restored.429QMessageBox::critical(m_parent_widget, tr("Restore wallet failed"), QString::fromStdString(m_error_message.translated));430} else if (!m_warning_message.empty()) {431//: Title of message box which is displayed when the wallet is restored with some warning.432QMessageBox::warning(m_parent_widget, tr("Restore wallet warning"), QString::fromStdString(Join(m_warning_message, Untranslated("\n")).translated));433} else {434//: Title of message box which is displayed when the wallet is successfully restored.435QMessageBox::information(m_parent_widget, tr("Restore wallet message"), QString::fromStdString(Untranslated("Wallet restored successfully \n").translated));436}438if (m_wallet_model) Q_EMIT restored(m_wallet_model);440Q_EMIT finished();441}443void MigrateWalletActivity::do_migrate(const std::string& name, bool load_wallet)444{445SecureString passphrase;446if (node().walletLoader().isEncrypted(name)) {447// Get the passphrase for the wallet448AskPassphraseDialog dlg(AskPassphraseDialog::UnlockMigration, m_parent_widget, &passphrase);449if (dlg.exec() == QDialog::Rejected) return;450}452showProgressDialog(tr("Migrate Wallet"), tr("Migrating Wallet <b>%1</b>…").arg(GUIUtil::HtmlEscape(name)));454QTimer::singleShot(0, worker(), [this, name, passphrase, load_wallet] {455auto res{node().walletLoader().migrateWallet(name, passphrase, load_wallet)};457if (res) {458m_success_message = tr("The wallet '%1' was migrated successfully.").arg(GUIUtil::HtmlEscape(GUIUtil::WalletDisplayName(name)));459if (res->watchonly_wallet_name) {460m_success_message += QChar(' ') + tr("Watchonly scripts have been migrated to a new wallet named '%1'.").arg(GUIUtil::HtmlEscape(GUIUtil::WalletDisplayName(res->watchonly_wallet_name.value())));461}462if (res->solvables_wallet_name) {463m_success_message += QChar(' ') + tr("Solvable but not watched scripts have been migrated to a new wallet named '%1'.").arg(GUIUtil::HtmlEscape(GUIUtil::WalletDisplayName(res->solvables_wallet_name.value())));464}465if (load_wallet) {466assert(res->wallet);467m_wallet_model = m_wallet_controller->getOrCreateWallet(std::move(res->wallet));468} else {469m_success_message += QChar(' ') + tr("The wallet was not loaded after migration. You can open it from the \"File > Open wallet\" menu.");470}471} else {472m_error_message = util::ErrorString(res);473}475QTimer::singleShot(0, this, &MigrateWalletActivity::finish);476});477}479void MigrateWalletActivity::migrate(const std::string& name)480{481// Warn the user about migration482QMessageBox box(m_parent_widget);483box.setWindowTitle(tr("Migrate wallet"));484box.setText(tr("Are you sure you wish to migrate the wallet <i>%1</i>?").arg(GUIUtil::HtmlEscape(GUIUtil::WalletDisplayName(name))));485box.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"486"If this wallet contains any watchonly scripts, a new wallet will be created which contains those watchonly scripts.\n"487"If this wallet contains any solvable but not watched scripts, a different and new wallet will be created which contains those scripts.\n\n"488"The migration process will create a backup of the wallet before migrating. This backup file will be named "489"<wallet name>-<timestamp>.legacy.bak and can be found in the directory for this wallet. In the event of "490"an incorrect migration, the backup can be restored with the \"Restore Wallet\" functionality."));491auto* load_wallet_checkbox = new QCheckBox(tr("Load wallet after migration"), &box);492load_wallet_checkbox->setToolTip(tr("If the node is pruned and the wallet was created before the pruned height, the migration process may fail trying to load the migrated wallet."));493load_wallet_checkbox->setChecked(true);494box.setCheckBox(load_wallet_checkbox);495box.setStandardButtons(QMessageBox::Yes|QMessageBox::Cancel);496box.setDefaultButton(QMessageBox::Yes);497if (box.exec() != QMessageBox::Yes) return;499do_migrate(name, load_wallet_checkbox->isChecked());500}
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.