Skip to main content
Code for the arkade:BTC → lightning:BTC and lightning:BTC → arkade:BTC routes.

Setup

Prerequisites:
  • an initialized Arkade WalletCreate Your Wallet; the refund and claim snippets read wallet.arkProvider / wallet.indexerProvider, concrete Wallet fields the IWallet interface does not carry;
  • an Arkade server URL — developer resources lists the networks.
Create the transport, and catch SwapRefusal where you request quotes:
Requests are sealed so only that solver reads them. SwapRefusal is that solver declining instead of quoting — amount outside its bounds, route off, no inventory — and it carries the reason; nothing is committed, so show the reason or re-request. Check quote.pair matches the pair you asked for — no transport does this for you.

Pay an Invoice

Decode the BOLT11 locally, then request a quote:
requestLightningSend rejects expired invoices, unsafe refund windows, and a quoted address that differs from the contract it derives locally. This corridor is exact-out: quote.to_amount is the invoice amount and quote.from_amount is what the lockup must carry — the spread is the fee. requestLightningSend registers the lockup with your wallet’s contract manager and derives the swap secrets from the wallet seed — the covenant is watched, survives restart, and your app stores nothing. Fund it:
Funding accepts the quote; it does not prove the invoice was paid.

Refund a Stalled Send

If the solver never pays, the lockup is yours to reclaim once refund_locktime passes — nothing does this automatically:
Switch on the four RefundOutcome variants: resolved, refunded, nothing_to_refund, and needs_recovery — the last is returned, not retried, and needs the wallet’s VTXO recovery before a refund can be pushed.

Receive a Payment

Claim while your wallet is online. Offline claiming through a daemon is not available yet, and an unclaimed receive stalls both sides until the timeouts fire.
No solver serves this corridor yet. The preview solver refuses every lightning:BTC → arkade:BTC request, so nothing below runs against it today. The code is the released client surface, ready when a solver serves the corridor.
requestLightningReceive derives the preimage and payout key from the wallet seed, seals the claim packet, and verifies the lockup it derives locally. The solver mints a hold invoice on the payment hash and never sees the preimage until you claim. covclaimdPubkey names who may open the sealed claim packet — the party that can claim for you if you go offline. Claiming from this same wallet, as below, means nobody else needs to read it: seal to a key whose secret is discarded on the spot and the preimage provably cannot be read early, by the solver or by anyone else. Claiming through a covclaimd deployment instead means passing that deployment’s own compressed key — ask [email protected] for the key of the one Ark Labs operates. Never seal to a key you invented and then expect a daemon to claim for you: nothing can decrypt it.
The lockup is registered with your wallet’s contract manager, as with a send — nothing to store before you pay. Paying the hold invoice (receive.invoice) is the acceptance — there is no accept message. The solver funds the Arkade lockup once it sees the payment held.

Claim It

Claiming reveals the preimage, which is what lets the solver settle the Lightning payment: the swap completes only when you claim. Wait for the solver’s funding, then push the claim:

Want to learn more?

Markets and Execution

The model underneath: how quotes are requested, priced, and committed.

Corridor Swaps

The underlying contract: paired HTLCs, timeouts, and recovery.

RFQ Protocol

Quote wire family, transport, settlement, and recovery requirements.

Exchange Assets

Exchange BTC and other assets, with both sides settling through Arkade.