Concepts
Invoices and webhooks
Invoice links
An invoice is a payment request whose note reads INV-0042 · due 2026-12-01. The link format doesn't change, so any Batin wallet can pay one. In the app, open Receive, tick This is an invoice, and add a reference and a due date. The payer sees the reference and the due date, and an overdue invoice says so. Your phone marks it paid when a note of exactly that amount arrives.
The SDK writes and reads the same note: invoiceLabel({ ref, due }) and parseInvoiceLabel(label).
Knowing which invoice was paid, from a server
Every request to one wallet pays the same address, so a backend can't always tell which invoice a payment settles. invoiceKeys(seed, ref) gives each invoice its own receiving address, derived from your seed. A payment to that address settles that invoice and nothing else. The payer learns nothing extra, and on-chain the addresses can't be linked to each other or to your main one.
npx batin-mcp invoice new --ref INV-0042 --asset USDC --amount 25 --due 2026-12-01
npx batin-mcp invoice sweep # move paid invoice money into the main wallet
Webhooks
BATIN_WEBHOOK_SECRET=… npx batin-mcp watch --webhook https://your.app/hooks/batin
The watcher runs next to your backend, with your seed. It scans the pool every 30 seconds and POSTs:
invoice.paid:{ ref, asset, amount, received, due, address }payment.received:{ address, asset, amount, leafIndex }
Each POST carries batin-signature: t=<unix>,v1=<hex HMAC-SHA256(secret, "<t>.<body>")> and a batin-event-id. Check it with verifySignature(secret, rawBody, header) from batin-mcp, and reject anything older than five minutes. Failed deliveries are retried four times with backoff.
Why not from Batin's servers? Only the holder of the view key can see what arrived. Batin's servers don't have yours, by design, so they can't tell you when you've been paid.
Source: apps/web/content/docs/invoices.md