Skip to main content
Code for the arkade:BTC → lightning:BTC and lightning:BTC → arkade:BTC routes. For the model underneath, see Markets and Execution and the protocol reference.

Setup

Prerequisites: 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.
Not available in the developer preview. The preview solver does not serve lightning:BTC → arkade:BTC yet. The API below is the released 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.
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. claimReceiveLockup waits for the solver’s funding, then pushes the claim:

Arkade Assets

Swap BTC against an Arkade Asset.

RFQ Protocol

Review quote, transport, settlement, and recovery requirements.