upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/db.h
diff options
context:
space:
mode:
authorbitflash <dev@bitflash.network>2026-08-18 16:14:19 -0300
committerbitflash <dev@bitflash.network>2026-08-18 16:14:19 -0300
commit3f94ec0649f935d00de49ad7b55026317dc64a27 (patch)
treee67ff06c8341889cf90cbbc3b835507a90510b64 /src/db.h
parentf3fb7ce6759ac98a7cc39d586fc2824982c74acd (diff)
wallet: make SQLite the default backend for new wallets
A fresh install with no wallet.dat now starts on the SQLite backend and creates wallet.sqlite, instead of a Berkeley DB wallet.dat. The choice is recorded in a plain-text <datadir>/wallet-backend marker so it survives a restart without a command-line flag. Backend resolution when no -walletbackend is given: an existing wallet.sqlite (or a "sqlite" marker) stays on SQLite; an existing wallet.dat stays on Berkeley DB -- nothing is converted behind the user; a fresh datadir starts on SQLite. An explicit -walletbackend=bdb or a "bdb" marker forces Berkeley DB and overrides the default. Adds CreateNewSQLiteWallet() (WalletSQLiteRuntimeOpen gains fMustExist so the create path can make a new file) which mints the first default key straight into the SQLite store via the same FinishLoadedWallet() call the Berkeley DB create path uses, then cleans up on failure. Marker read/write helpers are plain text, hand-editable. New wallet-backend-default self-test proves the resolution in child processes (fresh->SQLite+marker, existing wallet.dat->BDB, "bdb" marker->BDB, explicit flag->wallet.dat). The three wallet.dat-specific suites now ask for -walletbackend=bdb explicitly, since a flagless fresh datadir is SQLite now. All wallet suites pass.
Diffstat (limited to 'src/db.h')
-rw-r--r--src/db.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/db.h b/src/db.h
index 5bc94b1..c50065b 100644
--- a/src/db.h
+++ b/src/db.h
@@ -357,7 +357,7 @@ private:
357// peer discovery is entirely Nostr/.btf-based now. 357// peer discovery is entirely Nostr/.btf-based now.
358 358
359bool WalletSQLiteRuntimeActive(); 359bool WalletSQLiteRuntimeActive();
360bool WalletSQLiteRuntimeOpen(const string& strPath, string& strErrorRet); 360bool WalletSQLiteRuntimeOpen(const string& strPath, string& strErrorRet, bool fMustExist=true);
361void WalletSQLiteRuntimeClose(); 361void WalletSQLiteRuntimeClose();
362bool WalletSQLiteRuntimeReadRecord(const vector<unsigned char>& vchKey, 362bool WalletSQLiteRuntimeReadRecord(const vector<unsigned char>& vchKey,
363 vector<unsigned char>& vchValueRet); 363 vector<unsigned char>& vchValueRet);
@@ -370,6 +370,9 @@ bool WalletSQLiteRuntimeCommitTxn();
370void WalletSQLiteRuntimeRollbackTxn(); 370void WalletSQLiteRuntimeRollbackTxn();
371bool WalletSQLiteRuntimeOpenReadOnly(const string& strPath, string& strErrorRet); 371bool WalletSQLiteRuntimeOpenReadOnly(const string& strPath, string& strErrorRet);
372bool WalletSQLiteRuntimeCheckpoint(string& strErrorRet); 372bool WalletSQLiteRuntimeCheckpoint(string& strErrorRet);
373string ReadWalletBackendMarker();
374bool WriteWalletBackendMarker(const string& strBackend);
375bool CreateNewSQLiteWallet(const string& strPath);
373 376
374 377
375 378