getKeys throws on passphrase-encrypted entries — nip19.decode({iv, data}) fails #5
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Symptom
After successfully calling
create_new_key(keyName, passphrase)once, every subsequentget_keysadmin RPC times out from the client side (no response event arrives). Verified against a freshly-built bunker via Python admin-RPC harness over the same relay channel —pingworks,create_new_keyworks, butget_keysafter a create silently fails.Root cause
The bug is in the bunker source, not in NDK or the relay. Trace:
src/commands/add.ts:saveEncryptedwrites:So
config.keys[name]becomes a plain object of shape{iv: string, data: string}.src/daemon/run.ts:getKeysreads:nip19.decode({iv, data})throws because it expects a bech32 string. The exception propagates up throughhandleRequest's catch, which callssendResponse(... "error", NDKKind.NostrConnectAdmin, err?.message).The error response is published but apparently doesn't reach the client subscription — same shape as the NDK echo issue in #4. Hard to confirm without instrumenting NDK directly.
Reproduction
Real fix
getKeysshould only iterate keys that are actually plaintext nsecs:This matches the existing semantics — encrypted-but-locked keys go into
lockedKeyNamesand get returned as{name}(no npub), unlocked keys go in with{name, npub, userCount, tokenCount}. The bug is just that the type guard is missing.Impact
For our use case (LNbits-as-IdP): does not block us. LNbits stores the target pubkey at
create_new_keytime and never asks the bunker for "what keys do you have." Soget_keysis never called on the steady-state hot path.For interactive admin via Pablo's web UI: probably blocks the UI from showing the post-create state of the keystore. nsecbunker.com might have a different code path that hides this.
Acceptance
getKeysto skip non-string entries.Cross-refs
aiolabs/lnbits#18phase 2 spike (see Follow-up #3 in~/dev/lnbits/nsec-bunker-spike-findings.md).startKeypasses bech32 nsec to NDKPrivateKeySigner — every newly-created key fails to load #8