Skip to content

Commit 563b2a6

Browse files
committed
wallet: Better error message when missing LegacySPKM during migration
1 parent b1d2c77 commit 563b2a6

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/wallet/wallet.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3862,7 +3862,11 @@ std::optional<MigrationData> CWallet::GetDescriptorsForLegacy(bilingual_str& err
38623862
AssertLockHeld(cs_wallet);
38633863

38643864
LegacyScriptPubKeyMan* legacy_spkm = GetLegacyScriptPubKeyMan();
3865-
assert(legacy_spkm);
3865+
if (!Assume(legacy_spkm)) {
3866+
// This shouldn't happen
3867+
error = Untranslated(STR_INTERNAL_BUG("Error: Legacy wallet data missing"));
3868+
return std::nullopt;
3869+
}
38663870

38673871
std::optional<MigrationData> res = legacy_spkm->MigrateToDescriptor();
38683872
if (res == std::nullopt) {
@@ -3877,8 +3881,9 @@ bool CWallet::ApplyMigrationData(MigrationData& data, bilingual_str& error)
38773881
AssertLockHeld(cs_wallet);
38783882

38793883
LegacyScriptPubKeyMan* legacy_spkm = GetLegacyScriptPubKeyMan();
3880-
if (!legacy_spkm) {
3881-
error = _("Error: This wallet is already a descriptor wallet");
3884+
if (!Assume(legacy_spkm)) {
3885+
// This shouldn't happen
3886+
error = Untranslated(STR_INTERNAL_BUG("Error: Legacy wallet data missing"));
38823887
return false;
38833888
}
38843889

0 commit comments

Comments
 (0)