Expand description
Settings key-value store operations.
Functions§
- advance_
u64_ setting - Monotonically advance a numeric setting in ONE statement — the stored value only ever grows. For reconcile cursors and similar floors, where a read-modify-write window would let a stale or concurrent writer regress the value.
- 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. - commit_
nip55_ account_ setup - Atomically commit NIP-55 new-account setup:
encryption_enabled,security_type,signer_type='nip55', and the two plaintext public fields. Nopkeyis written (nothing secret exists), and any stale key material from a prior local/bunker setup on this DB is scrubbed so login can’t mis-route through a leftover pkey/bunker row. Transactional for the same reason as the sibling commits — a half-written account bricks 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_
nip55_ signer_ package - Read the paired signer app’s Android package name. Pinned on every intent + as the ContentResolver authority so a second signer app can’t intercept.
- get_
nip55_ user_ pubkey - Read the cached NIP-55 identity pubkey (hex). Plaintext on disk (public-key material); readable before unlock so the account picker can show the npub.
- 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_
nip55_ signer_ package - Persist the paired signer app’s package name. Updated on re-pair.
- set_
nip55_ user_ pubkey - Persist the NIP-55 identity pubkey (hex).
- 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.