Documentation
Cassis Order Protocol (COP)
A wallet-native protocol for buying, subscribing, pricing in fiat, and ordering from menus without web technologies.
Specification v1.0 (Draft). The full specification is at cop.cassis.cash.
The Cassis Order Protocol (COP) lets Bitcoin wallets handle real-world commerce directly inside the wallet.
Scan a QR code (or paste an address) and the merchant's order page opens in the wallet, rendered with the wallet's own native buttons, lists and form inputs. Pick what you want, fill in any details, and pay on the wallet's own payment screen.
- No browser in the wallet — the wallet renders a small set of native UI components instead of embedding a webview, JavaScript engine or cookies.
- No website for the merchant — the merchant needs no web server, domain name or TLS certificate. An Iroh public key is the address, and a server can run on a VPS, a vending machine, or a phone.
- Two-way payments — a merchant can also send money back to the customer (for refunds, cashback or withdrawals) in the same flow.
- Persistent sessions — the wallet can reconnect to a past order later to view a receipt, check delivery status, ask for a refund, or pay the next month of a subscription.
Architecture & roles
COP is built on hypereffect, a small JSON-line protocol for server-driven UI, carried over an encrypted Iroh peer-to-peer stream (cassis-order ALPN).
The page itself — framing, elements, reactive signals, CEL expressions and actions — is standard hypereffect. COP adds three things:
- Transport & discovery: an Iroh connection opened from a
cop://connection URI or an HTTPS URL that publishes one. - Session resumption: a client-generated
sessionstring in thehellohandshake so a flow can be reopened later. - Two messages for money:
invoice(asking the wallet to pay a Cassis invoice) andinvoicerequest(offering the wallet money and asking it to issue an invoice).
Each flow has two sides:
- Server (merchant): a shop, restaurant, vending machine, online service, or person selling something. It sends the UI, handles user actions, prices the order, and issues invoices or invoice requests.
- Client (wallet): the payer's Bitcoin wallet. It opens the connection, renders the page with native components, sends user actions back, and shows its own payment screen when an invoice arrives.
Try it
The demo below runs a toy wallet and restaurant server in your browser. The left side is what the payer sees; the right side logs every line on the cassis-order stream (a tag, a space, and a JSON object).
Drag the camera view to scan one of the two QR codes on the table:
- The menu flyer (
cop://…#name=Luigi%27s%20Pizza) opens the full ordering flow: pick a pizza and topping, enter a delivery address, and pay. - The checkout terminal (
cop://…#register=2) skips straight to payment for two slices already rung up on register 2.
Both codes dial the same server; the fragment after # tells it what to show.
As you click through:
- Connect. The wallet sends
hellowith the URI parameters and a randomsessionstring. The server replies withmetadataand the page'selements. - Order. Tapping an item sends an
actionwith what was chosen, never a price. The server prices it and updates the page withelementandremove. - Local state. Typing an address sends nothing yet. The input updates a local
signal, and the wallet evaluates a CEL expression locally to enable the pay button. Signals are sent along with the nextaction. - Pay. The server prices the order in sats and sends an
invoice. The amount you confirm comes from the cryptographic invoice on the wallet's own payment screen, not from text on the page. - Money back. Cancel order & refund triggers an
invoicerequestfrom the server. If you accept, the wallet signs a freshinvoiceand sends it back for the server to pay. - No UI at all. The checkout terminal sends an
invoiceright away with no page ormetadata, so the wallet shows only the endpoint ID it dialed. - Come back later. Close an order and reopen it under Recent orders. The wallet reconnects with the same
sessionstring, and the server resumes the order or shows the receipt.
Connection URIs and web addresses
A merchant publishes an order endpoint as a cop:// URI, usually in a QR code:
.onion Tor hidden service. Only the wallet's transport uses it. It is never sent to the server.&-separated key=value pairs handed to the server in hello, such as a table or register number.Web address discovery
Wherever a wallet accepts a cop:// URI, it can also take an HTTPS URL like example.com/order/123. The wallet fetches the URL (GET) and looks in the HTML <head> for:
<link rel="cassis-order" href="cop://5f1c9d0a27e4b6c38d2f71a09e4b5c6d8a3f2e1b0c9d8e7f6a5b4c3d2e1f0a9b#table=12">
The HTML is only used to discover the cop:// URI. The wallet never renders the page, runs scripts, or follows links, and the server is still authenticated by the Iroh endpoint ID in the URI.
Sessions and identity
Every hello includes a session token generated by the wallet with at least 128 bits of randomness:
- The wallet saves each session locally (endpoint ID, relay, URI parameters,
sessionstring, and invoices paid or issued). - Tapping a past order reconnects with the same
sessionand parameters, so the server can resume checkout, show a receipt or delivery status, offer a refund, or renew a subscription.
The server also sees the wallet's Iroh endpoint public key. A wallet can manage this key depending on the privacy tradeoff it wants:
- A new key per order so orders cannot be linked by endpoint ID.
- One key per merchant so a service recognises a returning customer without cross-merchant tracking.
- A single key if the user wants a portable identity across servers.
Security model
- Only the wallet's payment screen is trusted. The server draws the entire order page, including any prices shown as text. When an
invoicearrives, the wallet ignores page text and builds its payment sheet strictly from the signed invoice (amount_msat,payee,expires_at). - Money only moves through
invoiceandinvoicerequest. Hypereffect has no payment component, and links opened from a page must never triggerbitcoin:,lightning:orcassis:URI handlers. - Actions are untrusted input. A client can put arbitrary values in
actionpayloads and signals. Servers should only take item IDs and quantities from the client and compute all prices and totals themselves. - Remote media privacy. Remote
imageURLs leak the customer's IP address to the image host. Wallets should let users block remote images, and must never load them when connected through a.onionTor relay.