Skip to main content

Module relay

Module relay 

Source
Expand description

bsv-wallet-relay — store-and-forward ARC/Arcade callback receiver.

ONE public callback receiver on a box; multiple wallet daemons (which may be localhost-only) drain their own queue OUTBOUND by callback token:

Arcade ──POST /arc-callback (Bearer <token>)──▶ relay (sqlite queue, per token)
wallet ──GET  /pull?token=<token>&after=<id>──▶ relay (returns queued payloads)
wallet ──GET  /pull?token=..&after=N&ack=N   ─▶ relay (deletes acked rows)

§Token registration (simpler-but-safe design, documented trade-off)

A token is auto-registered the first time a wallet pulls with it — wallets start polling at daemon boot, before any submit, so the token is always registered before Arcade can call back. Callbacks with unknown tokens are rejected (401) so the relay never stores unsolicited data. Tokens are high-entropy (32 hex), so pulling with a guessed token yields nothing (an empty, freshly-registered queue) and cannot read another wallet’s payloads. Optionally, POST /register {"token": "..."} with Authorization: Bearer <RELAY_ADMIN_TOKEN> pre-registers tokens and RELAY_REQUIRE_REGISTER=1 disables auto-registration entirely.

§Endpoints

RouteAuthBehavior
GET /healthnone{"healthy":true}
POST /arc-callbackcallback token (Bearer or X-CallbackToken)queue payload for that token
GET /pull?token=&after=&ack=token in queryreturn payloads with id > after (max 100); delete id <= ack first
POST /registerRELAY_ADMIN_TOKEN bearerregister {"token": "..."}

Structs§

RelayState
Shared relay state.

Functions§

make_relay_router
Build the relay router.
open_relay_db
Open (and migrate) the relay sqlite database.