Expand description
Settings key-value store operations.
Functions§
- commit_
account_ setup - Atomically commit the four settings written during new-account setup:
the (possibly-encrypted) pkey, the
encryption_enabledflag, thesecurity_type(only when encrypted), and the (already-encrypted) seed phrase. Wrapping these in a single transaction makes the new-account flow crash-safe: either all four land or none do. The previous design wrote them through four separateset_sql_settingcalls, which left a window where pkey was persisted butencryption_enabledwas not — the next boot would then mis-interpret the encrypted blob as plaintext nsec and brick the account. - commit_
bunker_ account_ setup - Atomically commit the four settings written during bunker new-account
setup: the (possibly-encrypted) client keypair pkey,
encryption_enabled,security_type, plussigner_type='bunker', the (possibly-encrypted)bunker_url, and the plaintextbunker_remote_pubkey. Wraps the whole commit in a transaction for the same reason ascommit_account_setup— a half-written bunker account would brick login. - get_
bunker_ remote_ pubkey - Read the cached remote signer pubkey (hex). Plaintext on disk — it’s
public-key material with no secrecy implications, and keeping it readable
before unlock lets the UI display “Connected to
” on the locked account picker without prompting for a password. - get_
bunker_ url - Read the
bunker://URL, decrypting it if the account uses encryption. ReturnsOk(None)for local accounts (no row), or when decryption fails against an obviously-encrypted blob (likely the user hasn’t unlocked yet). - get_
pkey - Get the stored private key (bech32 nsec).
- get_
seed - Get the stored seed phrase (may be encrypted).
- get_
signer_ type - Read the active signer kind from settings. Missing rows pre-date migration
27 and are treated as
"local"so pre-NIP-46 accounts behave unchanged. - get_
sql_ setting - Get a SQL setting by key.
- remove_
setting - Remove a setting by key.
- set_
bunker_ remote_ pubkey - Persist the cached remote signer pubkey (hex form). Updated after each successful bunker bootstrap — the bootstrap response carries the canonical pubkey, which may differ from any user-supplied form.
- set_
bunker_ url - Persist the
bunker://URL, encrypting if the account uses encryption. The plaintext form is never written to disk for encrypted accounts. - set_
pkey - Set the stored private key.
- set_
seed - Set the seed phrase (should be encrypted before calling).
- set_
signer_ type - Persist the signer kind. Accepts the discriminator’s
as_setting_str()form (“local” or “bunker”); other values are accepted butget_signer_typewill treat them aslocaldownstream. - set_
sql_ setting - Set a SQL setting key-value pair.