Merge bitcoin/bitcoin#32620: wallet: Fix wallet interface detection of encrypted wallets

130a922980 wallet, interfaces: Use BERKELEY_RO in isEncrypted (Ava Chow)

Pull request description:

  The GUI uses `WalletLoader::isEncrypted()` to detect whether a wallet file is encrypted so that it knows whether to prompt for a passphrase when migrating a legacy wallet. However, legacy wallets need to be opened with `options.require_format = BERKELEY_RO`. Since this wasn't being provided, following #28710, encrypted legacy wallets could not be migrated.

  This fixes the issue by detecting when a wallet file is for a legacy wallet, and re-attempting with `options.require_format = BERKELEY_RO` in that case.

  Depends on #32449 for `DatabaseStatus::FAILED_LEGACY_DISABLED`

ACKs for top commit:
  davidgumberg:
    Tested ACK 130a922980
  furszy:
    utACK 130a922980
  pablomartin4btc:
    tACK 130a922980
  w0xlt:
    Code review ACK 130a922980
  rkrux:
    utACK 130a922980

Tree-SHA512: aa70defc3b5f41635333a4d83c46ecdb5cd3cb129d590b4c0fe7a5f16e8aeaba1592f932ead242ed5f84524b146d87319154f4a1820bb34d9e80f63d24fc6b20
This commit is contained in:
merge-script
2025-06-13 18:17:24 -04:00

View File

@ -643,6 +643,10 @@ public:
DatabaseStatus status;
bilingual_str error;
auto db = MakeWalletDatabase(wallet_name, options, status, error);
if (!db && status == wallet::DatabaseStatus::FAILED_LEGACY_DISABLED) {
options.require_format = wallet::DatabaseFormat::BERKELEY_RO;
db = MakeWalletDatabase(wallet_name, options, status, error);
}
if (!db) return false;
return WalletBatch(*db).IsEncrypted();
}