diff options
| author | bitflash <admin@bitflash.network> | 2026-08-18 10:16:59 -0300 |
|---|---|---|
| committer | bitflash <admin@bitflash.network> | 2026-08-18 10:16:59 -0300 |
| commit | 00c7aaed74e57da18598faa6751b7720598de3bd (patch) | |
| tree | 914f2851ce35919230c51ca083d3a964d6722408 /src/db.cpp | |
| parent | 2a2b9d74f8fb6b5d86d750e6e5d18c942738f95c (diff) | |
wallet: clearer refusal for an empty or misnamed SQLite backend
Review follow-up on the SQLite activation. Two guards, both fail-closed;
neither is a correctness fix -- FinishLoadedWallet already refuses a
missing default key -- but they make the refusal say what happened:
- an empty or non-wallet wallet.sqlite is refused with "no default key
record; it may be empty or not a wallet export", instead of the generic
"no usable default public key" that reads as corruption;
- a misspelled -walletbackend value (e.g. sqlit) is refused instead of
silently falling through to Berkeley DB; -walletbackend=bdb is accepted
as the explicit default.
Diffstat (limited to 'src/db.cpp')
| -rw-r--r-- | src/db.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
| @@ -1496,6 +1496,22 @@ bool LoadWalletFromSQLiteRuntime(const string& strPath) | |||
| 1496 | return false; | 1496 | return false; |
| 1497 | } | 1497 | } |
| 1498 | 1498 | ||
| 1499 | // Refuse an empty or non-wallet SQLite file up front, with a message that | ||
| 1500 | // names the likely cause. FinishLoadedWallet below already rejects a | ||
| 1501 | // missing default key (it is the fMayCreateDefaultKey=false path), but its | ||
| 1502 | // wording -- "no usable default public key" -- reads as corruption when the | ||
| 1503 | // real story is usually "this file was never an exported wallet". A blank | ||
| 1504 | // wallet.sqlite left by a typo or a half-run export should say so. | ||
| 1505 | if (visitor.vchDefaultKey.empty()) | ||
| 1506 | { | ||
| 1507 | WalletSQLiteRuntimeClose(); | ||
| 1508 | strWalletLoadError = | ||
| 1509 | "SQLite wallet has no default key record; it may be empty or not a " | ||
| 1510 | "wallet export. Create it with -walletsqliteexport."; | ||
| 1511 | printf("LoadWallet: %s\n", strWalletLoadError.c_str()); | ||
| 1512 | return false; | ||
| 1513 | } | ||
| 1514 | |||
| 1499 | if (!ReconcileLoadedWalletMetadata(visitor.fHaveStoredMineMode, | 1515 | if (!ReconcileLoadedWalletMetadata(visitor.fHaveStoredMineMode, |
| 1500 | visitor.fHaveStoredHDCoinType)) | 1516 | visitor.fHaveStoredHDCoinType)) |
| 1501 | { | 1517 | { |