fix(marmot-interop): parse post-v0.2 \wn --json whoami\ shape
wn now wraps account listings in {"result": [{...}]} so extract_pubkey's
object + array fallbacks both missed it and ensure_identity bailed with
"could not determine \$who npub" immediately after create-identity.
Also: create-identity on a fresh box can exit non-zero with
"failed to connect to any relays" even when the account *was* created
locally. Probe --json whoami afterwards before calling that a fatal.
https://claude.ai/code/session_01M6dCKAF5Y1VyHGZPjzwDXq
This commit is contained in:
@@ -231,9 +231,12 @@ ensure_identity() {
|
||||
raw=$("$cmd" --json whoami 2>/dev/null || true)
|
||||
npub=$(extract_pubkey "$raw")
|
||||
if [[ -z "${npub:-}" ]]; then
|
||||
raw=$("$cmd" create-identity 2>&1 | tee -a "$LOG_FILE")
|
||||
# create-identity sometimes exits non-zero (e.g. transient "failed to
|
||||
# connect to any relays") even though the account was created. Probe
|
||||
# --json whoami afterwards before giving up.
|
||||
"$cmd" create-identity 2>&1 | tee -a "$LOG_FILE" || true
|
||||
raw=$("$cmd" --json whoami 2>/dev/null || true)
|
||||
npub=$(extract_pubkey "$raw")
|
||||
[[ -n "$npub" ]] || npub=$(extract_pubkey "$("$cmd" whoami 2>/dev/null || true)")
|
||||
fi
|
||||
[[ -n "$npub" ]] || { fail_msg "could not determine $who npub"; exit 1; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user