-
Notifications
You must be signed in to change notification settings - Fork 0
Usage
This page walks through the main workflows. Every UI action maps to a REST call documented in API.
CLINK communicates over ordinary Nostr relays. The node listener stays subscribed to every enabled relay and answers kind 21001 / 21002 requests.
- Open the CLINK extension.
- Go to the Relays tab and click Add relay.
- Enter a relay URL (
wss://relay.damus.io,wss://relay.primal.net, your ownnostr-rs-relay, …) and enable it.
The status banner in the index page reflects whether the listener has at least one enabled relay.
An offer is a noffer1... string. Anyone with it can request an invoice from your wallet over Nostr.
- Offers tab → New offer.
- Give it a name. Set an amount in sats for a fixed price, or leave it empty for a spontaneous offer.
- Create. The row shows the generated
noffer1...— share it (QR, copy button) or link to the public checkout page.
A fixed offer also gets a checkout page at /clink/checkout/{offer_id} — a self-contained HTML page where anyone can enter/copy the amount and get a BOLT11 invoice. The offer matches kind 21001 requests, validates the requested amount against the offer price, and returns the invoice encrypted with NIP-44.
A debit pointer is an ndebit1... string. When an app sends a kind 21002 request addressed to it, your wallet settles it — subject to the rules you set.
- Debits tab → New debit pointer.
- Optionally set a fixed amount (sats), a budget per period, a frequency (day/week/month), and a rules JSON:
{ "allowed_pubkeys": ["<hex pubkey of the app>"], "min_msat": 1000, "max_msat": 1000000 } - Create and share the
ndebit1...string.
What the node does with an incoming request:
-
Direct payment (
bolt11present): decodes and validates the invoice, checks the fixed amount / min-max rules, deducts from the period budget (clink.debit_usage), pays withpay_invoice, and replies{"res":"ok","preimage":…}. Budget is rolled back if the payment fails. -
Budget request (
frequencypresent): validates frequency and amount against the pointer and acknowledges with{"res":"ok"}. -
Session
k1: if thendebit1...carries a 32-byte session identifier, the request must echo it and it is single-use (tracked inclink.k1s).
Failures are answered with a GFY payload ({"res":"GFY","code":…,"error":…}).
- Open CLINK → Pay (
/clink/pay). - Paste a
noffer1...string and hit Parse — the decoded offer (id, relay, pubkey, price type/price) is shown. - Enter the amount for spontaneous offers and hit Pay.
The payer sends a kind 21001 request signed by a fresh ephemeral keypair (per the CLINK SDK recommendation), waits for the encrypted invoice response, pays it with your LNbits wallet, and reports the payment hash and preimage.
A plan is a recurring price. A subscription links a plan to a payer's ndebit1... pointer.
- Open CLINK → Subscriptions (
/clink/subscriptions). -
Plans tab → New plan: name, amount (sats), frequency number + unit (
day,week,month). -
Subscriptions tab → New subscription: pick the plan and paste the payer's
ndebit1...pointer (their wallet node's static debit pointer, e.g. from ShockWallet / Lightning.Pub).
How billing works:
- When a subscription is created, the first period end is
now + frequency. - A permanent poller (
clink_subscriptions, every 60 s) finds active subscriptions whose period has ended. - For each, the node creates a BOLT11 invoice on your wallet for the plan amount, sends a kind 21002 direct-payment request to the payer's node (via the payer's relay + your enabled relays), and waits for the encrypted response.
- On
{"res":"ok"}the period advances by one frequency and the attempt counter resets. - On GFY or timeout the attempt counter increments; after 3 failed attempts the subscription is cancelled. Manual retry is available from the UI (Bill now) or the API.
Subscription states: active → (renewal) → active or, after max attempts, cancelled. You can also paused/cancelled/active a subscription from the UI; resuming resets the attempt counter.
Note: subscriptions and debit settlement require a real Lightning backend (see Installation).
- Toggle any offer, debit pointer, plan, or relay on/off with its switch.
- Delete removes the record. Deleting a relay just stops listening on it; deleting an offer makes its checkout page and requests fail.
lnbits-clink — CLINK (Nostr-native Lightning) for LNbits.