feat(pairing): default seed relay to the nostrclient endpoint + validate relays
Some checks failed
ci.yml / feat(pairing): default seed relay to the nostrclient endpoint + validate relays (pull_request) Failing after 0s
Some checks failed
ci.yml / feat(pairing): default seed relay to the nostrclient endpoint + validate relays (pull_request) Failing after 0s
Two robustness fixes for on-machine pairing (bitspire-#70), after a QR scan silently corrupted a seed's relay (ws://→As://) and crash-looped a machine on an unreachable relay: - Default relays: when the operator omits `relays`, derive the seed's relay from THIS lnbits' own nostrclient proxy endpoint — `<ws(s)>://<host>/nostrclient/api/v1/relay`, built from `lnbits_baseurl` (default_relay_endpoint). Operators configure upstream relays once in the nostrclient extension (public_ws must be on) and every seed points at one stable, operator-independent URL. `relays` is now optional on PairMachineData + the /pair endpoint. - Validate every relay (+ bunker_relay) is a `ws://`/`wss://` URL AND reject loopback hosts (localhost/127.0.0.1/::1/0.0.0.0) — a seed is redeemed by a REMOTE machine, so a localhost relay is exactly the unreachable case. Catches both the ws://→As:// corruption and the localhost /pair gotcha at mint time. Consumer side (bitspire): parseSpireSeed rejects non-ws relays, and the wizard gained a "test relay" reachability button before committing. 223 tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
9dc4d09973
commit
c3791ed6c8
5 changed files with 143 additions and 27 deletions
|
|
@ -315,8 +315,8 @@ async def api_pair_machine(
|
|||
`duration_hours` (optional) time-bounds the token; revoke via the
|
||||
sibling `POST .../revoke` endpoint."""
|
||||
machine = await _machine_owned_by(machine_id, user.id)
|
||||
if not data.relays:
|
||||
raise HTTPException(HTTPStatus.BAD_REQUEST, "at least one relay is required")
|
||||
# relays may be omitted — pair_spire defaults to this lnbits' nostrclient
|
||||
# proxy endpoint and validates reachability (raises PairingError → 502).
|
||||
|
||||
try:
|
||||
async with NsecBunkerAdminClient.from_settings() as client:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue