This sidecar exposes a small HTTP API for LNbits to talk to the Spark L2 SDK.
cd lnbits/wallets/sidecars/spark
npm install
SPARK_MNEMONIC="bottom bottom bottom bottom bottom bottom bottom bottom bottom bottom bottom bottom" \
SPARK_NETWORK=MAINNET \
SPARK_SIDECAR_PORT=8765 \
SPARK_PAY_WAIT_MS=20000 \
node server.mjs
Optional auth:
SPARK_SIDECAR_API_KEY="mykey"
Set the same key in LNbits as SPARK_L2_API_KEY.
POST /v1/balancePOST /v1/invoicesPOST /v1/paymentsGET /v1/invoices/stream(SSE stream of paid Lightning receive requests)GET /v1/invoices/{id}GET /v1/payments/{id}
The stream endpoint emits Server-Sent Events when a Lightning invoice is paid.
Example:
curl -N http://127.0.0.1:8765/v1/invoices/streamEach event payload is a JSON object:
{"checking_id":"<receive_request_id>","payment_hash":"<hash>","status":"LIGHTNING_PAYMENT_RECEIVED"}Optional tuning:
SPARK_STREAM_KEEPALIVE_MS(default15000)SPARK_STREAM_HEARTBEAT_MS(default30000)SPARK_TRANSFER_LOOKUP_CONCURRENCY(default20)SPARK_TRANSFER_QUEUE_MAX(default5000)SPARK_INVOICE_POLL_MS(default2000)SPARK_INVOICE_POLL_LIMIT(default100)SPARK_INVOICE_CACHE_TTL_MS(default3600000)