diff --git a/tools/marmot-interop/headless/setup.sh b/tools/marmot-interop/headless/setup.sh index 5999b50c4..635e10de1 100644 --- a/tools/marmot-interop/headless/setup.sh +++ b/tools/marmot-interop/headless/setup.sh @@ -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; } diff --git a/tools/marmot-interop/lib.sh b/tools/marmot-interop/lib.sh index 4194d3e24..744e9ff95 100644 --- a/tools/marmot-interop/lib.sh +++ b/tools/marmot-interop/lib.sh @@ -271,6 +271,9 @@ extract_pubkey() { # JSON: single object v=$(printf '%s' "$raw" | jq -r '.pubkey // .npub // .public_key // empty' 2>/dev/null || true) if [[ -n "$v" && "$v" != "null" ]]; then printf '%s' "$v"; return; fi + # JSON: {"result": [ {"pubkey": …}, … ]} — post-v0.2 `wn --json whoami` shape + v=$(printf '%s' "$raw" | jq -r '.result[0].pubkey // .result[0].npub // .result[0].public_key // empty' 2>/dev/null || true) + if [[ -n "$v" && "$v" != "null" ]]; then printf '%s' "$v"; return; fi # JSON: array of accounts (whoami may return a list) v=$(printf '%s' "$raw" | jq -r '.[0].pubkey // .[0].npub // .[0].public_key // empty' 2>/dev/null || true) if [[ -n "$v" && "$v" != "null" ]]; then printf '%s' "$v"; return; fi