Files
MichilisandClaude Opus 5.5 f09445b6ad
ci / check (push) Canceled after 0s
ci / images (push) Canceled after 0s
ci / e2e (push) Canceled after 0s
Initial commit
Paper Sats: design and print paper notes that carry sats.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 05:15:30 +00:00

22 KiB

Decisions

Every deviation from the spec, every VERIFY result, and every open owner decision. Newest entries at the bottom of each section.

Setup

  • Spec location. The spec is in about/, not paper-sats-spec/. The project root is the repository root, and the spec stays tracked in about/.
  • Workspace. pnpm 10.32.1 workspace with apps/web, apps/worker, packages/core, packages/ui. Node engine >=22 (the sandbox runs Node 24).
  • Next.js 16.4.5 (current stable at build time), App Router, React 19.
  • Shared packages import without .js suffixes. The Next bundler does not map .js to .ts. The TypeScript setting moduleResolution: Bundler accepts the extensionless form.

Environment limits (this sandbox)

  • Docker is not available. No container has been started here, so the compose files and Dockerfiles in infra/ are written but unverified. The real services run without Docker through infra/local/, and integration tests use those. See "Local services instead of Docker".
  • Local Postgres. The spec asks for PostgreSQL 16. This machine has 15, on a private cluster at 5433. Migration tests use PGlite, and browser tests use the real server in database paper_e2e. The system server on 5432 and the process on 3000 were not touched.
  • Ports. Port 3000 is taken by another process. The dev server here runs on 3300 and Playwright on 3100 (E2E_PORT).
  • GitHub clones. Repositories were cloned to the session scratch directory. Their scripts were not run, except the ui-ux-pro-max search script, run with python3 -I.

Design (see also docs/design-log.md)

  • ui-ux-pro-max palette rejected. The --design-system search returned a purple palette (#7C3AED), a green accent, Inter with Playfair Display, and a "Hero + Testimonials + CTA" pattern. None of it is used, per 08-design-system.md section 7.2. The persisted files were overwritten with the spec tokens.
  • Focus outlines are ink, not the accent. The orange --accent (#F7931A) measures about 2.1:1 on paper. WCAG 1.4.11 needs 3:1 for focus indicators. Focus outlines use --ink (about 16:1). The --focus token is kept in the file and its value unchanged. Covered by a test in packages/ui/src/__tests__/contrast.test.ts.
  • Toast shadow. The toast uses a small neutral shadow (shadow-sm). The spec allows shadows only on floating notes and menus. A toast floats, so this is kept. Owner may remove it.
  • Solar icons (@iconify-json/solar, CC BY 4.0) are used through a generated local file, icon-data.ts.

VERIFY items

Item Status Where the result is
Cashu NUTs and @cashu/cashu-ts API Checked "VERIFY results: Cashu"
Nutshell image and env vars Checked by running Nutshell 0.20.2 directly. The Docker image is unverified, Docker is unavailable here "Local services instead of Docker"
lnurlcash mint endpoints, LUD-25 text Checked "VERIFY results: lnurlcash"
lnurlcash test funding source Decided: the real mint against a fake LND "VERIFY results: lnurlcash"
Blossom BUDs Checked against the live text "VERIFY results: Blossom and Nostr"
Nostr NIPs and final design kind Checked. The final kind stays an owner decision "VERIFY results: Blossom and Nostr"
QR format across three real wallets Not done. It needs real phones and wallets "Needs owner decision"

Needs owner decision

  • Design kind. Development default is 30078 with d prefix papersats:design: and tag paper-sats-design (04-nostr-blossom.md section 2). Production kind waits on a NIP.
  • Focus color. See the Design section above. Owner may prefer a dual ring (ink plus accent) instead of ink only.
  • Toast shadow. See the Design section above.
  • Admin npubs, payout endpoints, default mints, relays, Blossom servers. Placeholders from 11-build-plan.md "Owner inputs" are used. Real values are needed before production.
  • Domain. APP_URL=http://localhost:3000 placeholder.
  • Default QR format for lnurlcash notes. The spec's default lnurlw is kept. The reference wallet's claimLink.ts notes that lnurlw:// does not open on stock phones, which is a real risk for printed notes. LNURL_QR_FORMAT=lnurl switches to the bech32 form. The three-wallet test the spec asks for must be done on real phones before choosing.
  • Kind 30078 for public designs. NIP-78 says relays should restrict 30078 to the authenticated owner and that it is not for public data, which contradicts the spec's "works on every relay today". Development keeps 30078 as told, and the relay pool can answer NIP-42. A dedicated kind is the safer production choice.
  • Accepted fee mints. FEE_ACCEPTED_MINTS decides which mints the operator holds proofs on. Everything else is melted on arrival, which needs LNbits credentials.
  • LNbits. Without credentials a stub records payouts and pays nothing. Tokens from mints outside FEE_ACCEPTED_MINTS then fail, and the order stays fee_pending, because there is no invoice to melt to.

Build decisions (M1 and M2)

  • Size class order. Exact orientation is checked for every preset before any turned match. Otherwise 70 x 150 would read as a turned banknote.
  • lnurlcash mint fee rounding. The spec says "rounded up to a whole sat" without saying which value. The code rounds the fee in msat up to a whole sat, then searches for the smallest whole-sat paid amount with a net of at least the target.
  • Sheet layout. Each note tries its designed and turned orientation, and the one that fits more notes is kept. Ties keep the designed orientation.
  • QR zone fit. The Classic and Minimal templates set the QR side to the smaller of a fixed fraction of the height and of the width. Tiny sizes can still produce a zone too small for the payload, and the renderer blocks printing in that case.
  • PDF fonts. M1 used PDF standard fonts. Since M6 the whitelisted fonts are embedded with @pdf-lib/fontkit.
  • Image layers in PDF. Skipped in M1. Since M6 and M7 art is fetched, checked and drawn.
  • Rounded trim. Not clipped in M1. Applied in the PDF since M6.
  • Backup checksum. Computed over canonical JSON (sorted keys, no whitespace) of every field except checksum. Edits to any field, including the order of notes, fail the check.
  • Passphrase KDF. PBKDF2-SHA256 with 600,000 iterations, chosen because WebCrypto has it everywhere. The spec allowed "PBKDF2 or Argon2". Argon2 is not built.
  • Concurrent edits in this tree. During M1, .env, .env.example, apps/web/scripts/next-with-env.mjs, apps/web/AGENTS.md, the apps/web dev and start scripts, and apps/web/next-env.d.ts changed. I did not make these changes and did not commit them. They are left in the working tree for their owner to review. Lint now allows Node globals for .mjs files, so the new script passes lint.

VERIFY results: Cashu (checked 2026-11-04)

Checked against Nutshell 0.20.2 running locally (infra/local/mint.sh, FakeWallet) and @cashu/cashu-ts 4.13.0 type definitions.

  • GET /v1/info. nuts["4"].methods[] holds { method: "bolt11", unit: "sat" } plus a disabled flag. nuts["7"].supported is true. nuts["17"] lists websocket commands. nuts["29"].max_batch_size is 1000.
  • GET /v1/keysets. Each entry is { id, unit, active, input_fee_ppk, final_expiry }. Keyset ids are the v2 form (01 plus 64 hex). The dev mint's input_fee_ppk is 100.
  • Output limit. Nutshell's mint_max_request_length (default 1000) caps outputs per request and is advertised as nuts["29"].max_batch_size. The app reads that value and falls back to 1000.
  • Custom output amounts. cashu-ts 4.13 mintProofsBolt11(amount, quote, config, outputType) accepts { type: 'deterministic', counter: 0, denominations: [...] }. The integration test confirms that the mint signs exactly the planned denominations, in order. No swap is needed, so no input fee is added to the invoice.
  • Restore. wallet.restore(0, n) with the batch seed (bip39seed) returns the same proofs in counter order. The runner uses this when the mint signed but the browser did not save the result.
  • Proof amounts. In cashu-ts 4.x, Proof.amount is an Amount object, not a number. Stored proofs keep numbers and are rebuilt with Amount.from.
  • Checkstate. POST /v1/checkstate { Ys } returns { states: [{ Y, state, witness }] }. Chunks of 100 are used. The mint's own limit is the same 1000.
  • Public id. Y = hash_to_curve(utf8(secret)), compressed point, hex. Matches the Y values the mint returns.

Local services instead of Docker

  • infra/local/pg.sh runs a private PostgreSQL 15 cluster on 5433 with role and database paper. This matches the DATABASE_URL in .env. The spec asks for 16. Version 15 is what this machine has. The SQL used is compatible with both.
  • infra/local/mint.sh runs Nutshell 0.20.2 in a venv. It pins marshmallow<4 and limits<4, because newer releases break Nutshell's startup.

VERIFY results: lnurlcash (checked 2026-11-04)

Checked against lnurl_mint/router.py at commit d77bc32, LUD-25, and live probes of the real mint running locally (infra/local/lnurl-mint.sh).

  • Pay endpoint. GET /.well-known/lnurlp/_ returns callback, minSendable (fee-inclusive, 11000 by default), maxSendable, commentAllowed: 64, withdrawLink. Units are msat. GET /p/cb?amount&comment returns pr and verify. comment is mandatory for the fixed identity and must be a cp1 or a 64-hex hash.
  • Note lookup. GET /w?p= returns maxWithdrawable and callback. Errors come back as status: ERROR with a reason. The body decides the result, not the status code.
  • Split fee (spec is wrong). The spec says the remainder ends up holding exactly the creator fee. In fact each split takes BASE_FEE_MSAT (default 1000) from the change. The funding target is therefore notesTotal + creatorFee + splitCount * baseFee, and Mint fee on screen includes it. The base fee is only discoverable through the Mint fees: metadata. Mints with a non-whole-sat base fee are refused, with a reason, because LNbits and the fee note need whole sats.
  • Fee formula (spec is imprecise). The mint floors the percent part, then rounds the whole fee up to a sat. grossUpForLnurlMint in core can land 1 sat high, so planLnurlFunding walks down using the mint's own formula.
  • Zero creator fee. A split needs at least 1 msat of change, so with no creator fee the last note is a free rotate.
  • Replays. An exact repeat of a rotate, split or merge returns the same OK. The runner still checks /w?p= first, per the spec.
  • Lost funding invoice. A lost /p/cb response burns that hash ("already in use") and the first invoice cannot be read back. The runner saves a new funding secret and asks again. Nobody ever saw the first invoice, so nothing can be paid to it. This is the one case of a second invoice request.
  • MIN_MINT_MSAT. Applies to fresh mints only, not to split outputs.
  • Spent wording. The mint says "Note already spent."; LUD-25 says "already in use". Both map to Spent.
  • Multiple k1. Repeated k1= query parameters. The server caps at 100 and the client batches at 20.
  • Retention. The mint keeps spent notes. db.py has no delete, and a test confirms a burned note still answers "Note already spent."
  • Browsers. CORS is * on all routes.
  • Test funding. Spark regtest needs an external stack and a key. Instead the real mint runs against packages/devservers/src/fake-lnd.ts, a stand-in for only the LND REST calls node.py makes, which settles invoices automatically. The mint, its fee rules and its note store are the real ones. Only Lightning is faked.
  • Fee parser limit. parseLnurlMintFee does not read a Mint fees: entry inside longer text or with extra values, which LUD-25 allows. Such a mint is refused with a reason rather than guessed at.

VERIFY results: Blossom and Nostr (checked 2026-11-04)

Fetched live from hzrd149/blossom and nostr-protocol/nips. The code follows the sources where they differ from the spec.

  • BUD-11. The header is Nostr plus base64url without padding (the spec says base64). x is required for upload, mirror and delete. created_at must be in the past. server is a lowercase domain.
  • BUD-02. X-SHA-256 is optional, but BUD-11 reads the hash from it, so it is always sent. 200 and 201 mean different things. 409 is a mismatch. X-Reason is for display only. DELETE has moved to BUD-12.
  • BUD-06. HEAD /upload is optional, with the size in X-Content-Length. Existence checks use HEAD /{sha}.
  • BUD-04. x is checked after the download. BUD-01 and BUD-09 match the spec.
  • NIP-01. #t values are OR, so the spec's filter of several #t values would widen results. The library sends one tag and checks the rest locally.
  • NIP-09. An a tag applies up to its created_at, for the same author only.
  • NIP-44. No 64 KB limit in the current text. The 60 KB split is kept for older signers.
  • NIP-46. nostr-tools connect() drops permissions, so they are sent directly. The spec's list omits kinds 10002, 10063 and 9734, which are added.
  • NIP-56. Reports need p and e tags as well as a.
  • SVG. One strict allow-list parser runs everywhere, without DOMParser, so tests exercise the browser's code path. It re-serializes, refuses DOCTYPE, and its output is only ever used through image elements.

Build decisions (M3 onward)

  • Local services. Docker is denied on this machine, so infra/local/ runs the real Nutshell and real lnurl-mint in virtualenvs, plus an in-process relay and Blossom server from packages/devservers. The compose files remain unverified.
  • Worker imports web. apps/worker imports server logic through @paper-sats/web package exports, so fee and payout code exists once.
  • Fee retries for Cashu. The server never stores a token, so the worker cannot retry a failed Cashu fee. The browser keeps the token in its journal and resends it on each visit to the download page. The worker settles pending lnurlcash melts and marks a fee failed after 24 hours.
  • ready needs a received fee. The spec's state route accepts ready as bookkeeping. Here it also needs fee_state = received, because reaching ready counts as paid usage of a design.
  • fee_pending in the state route. Added to the accepted states so the browser can record it.
  • Extra routes. POST /api/orders/{id}/claim, POST /api/orders/{id}/reclaimed and GET /api/library/blocklist are not in the spec's list. They serve 05 section 7, 03 section 2.6 and 04 section 8.
  • Fee token must be from the order's mint. The spec only checks the amount. Accepting another mint's token would let a client pay with value it never minted for this order.
  • Dev origins. Outside production, CSRF and the login relay tag also accept an origin that matches the request's own Host, so the dev server works over its LAN address. Production is exact.
  • Style CSP. style-src follows the spec in production, so server-rendered markup has no style attributes. Dev drops the nonce because the dev overlay injects inline styles.
  • CSP_EXTRA_ORIGINS and SSRF_ALLOW_ORIGINS. Exact local origins for the test containers. Both stay empty in production.
  • Art in the PDF. Art is decoded to PNG on the main thread because workers cannot rasterize SVG.

Spec corrections found while testing

  • F1 sheet count (spec is wrong). 07-frontend.md F1 and the Download mockup say 20 banknotes make 3 sheets at 8 per A4 sheet. With the spec's own 10 mm margins, a 150 x 70 mm note fits 3 per sheet in either orientation, so 20 notes take 7 sheets, 14 pages. F1 asserts 14.
  • QR version 23. jsQR 1.4.0 cannot read QR version 23 because of a table typo, and 1004 to 1091 character tokens land there. makeQrMatrix skips to version 24.
  • Grid fallback in the scan check. jsQR misses some dense codes at 300 dpi, including some 5-proof sizes. The check falls back to sampling known module centres, and decodedBy reports which read passed. A grid pass proves the modules are right, not that a phone can read them. Test real scans.
  • Backs print head to head. On a short-edge flip, and on a long-edge flip with turned cells, backs are rotated 180 degrees so they sit the right way up behind their fronts. This goes beyond the spec's wording.
  • claimLine binding. Added to the text bind enum so a template can hold the claim line without knowing the note type. 04-nostr-blossom.md section 3.1 does not list it.
  • Lightning login starts on request. /login used to spend one challenge per visit, which would lock out shared addresses at 20 per hour. The code now starts when the user asks for it.
  • Rate limit keys include the site's host, so a test or preview server sharing a database cannot spend the site's limits.
  • Stale status. When the server cannot reach a mint, a note keeps its last known status and date and is flagged stale. Posting the same ids again keeps Reclaimed.
  • Undecodable art blocks use. Art that cannot be decoded blocks Use this design, because it cannot be checked for a second QR.
  • Fee melt saved before the mint is called. The spec does not say what happens if the answer is lost. The fee check is saved first, with a 120 s claim instead of a row lock held across the network. A melt counts as paid only if the payout side confirms the invoice was paid. Otherwise the proofs stay held.
  • Two tabs on one order. Runners take a Web Lock per order, and a journal save that would go backwards is refused.
  • Expired invoices are rechecked. An invoice past its expiry is asked about again before it is discarded, so a late payment is not lost.
  • Strict IndexedDB writes. Dexie runs with strict durability, so a power cut cannot drop a saved secret.
  • Input fee warning on Create. A Cashu mint with an input fee is called out, because a wallet receives slightly less than the printed amount.
  • /ui-kit/hero-source. A noindex page used by scripts/render-hero.mjs to render the hero images. It holds sample values only.

Scan check rules added after review

Designs from outside the app can no longer print while they lie about value. New block reasons: amount-missing, amount-hidden, amount-covered, hardcoded-amount, serial-missing. Extra QR detection also looks for finder patterns, so a code the reader cannot decode still blocks.

This has a cost: a bare number such as "500" in a design's text blocks printing, even if it is only decoration.

Not closed:

  • Text drawn inside an image layer.
  • Pattern layers used as covers.
  • Digits split across layers.
  • Turned QR codes with modules near 0.17 mm.

Decisions from the owner

  • Size and sides moved from Create to the Studio. Asked for by the owner during the build and carried out in a parallel session, which also updated 07-frontend.md.

Marketplace (12-admin-and-later.md section 2)

Only the free path, the price tag parser, the Zap tip button and the admin Designs hook are built. Option evaluation for the owner:

  1. Author-run key release. The platform handles no funds, so it fits the no-custody rule. The author must run a small service or be online. Recommended if the marketplace goes ahead.
  2. Platform-run key release. Simple for buyers, but the platform handles funds and needs legal review. Not chosen without the owner.
  3. Zap-gated release. Needs delegating a user's private key, which is not allowed. Rejected.

Decisions from the readiness pass

  • Size and sides work committed. The owner chose to keep it.
  • Dedicated design kind. The owner chose this over 30078. 32040 was free in the NIP registry on 2026-11-04. Private design indexes stay on 30078, which is what NIP-78 is for. There is no dual read, as no live data exists.
  • PNG previews on Safari. Publishing accepts PNG when the browser can't encode WebP. Files are larger, but publishing works. Not run on Safari.
  • Per-order fee seed, not a counter table. The plan was NUT-13 counters in the database. Deriving a seed from FEE_WALLET_SEED and the order id, from counter 0, needs no stored state, and a resend gives the same outputs.
  • Reservation, not advisory locks. The plan was a Postgres advisory lock per mint. Reserving proofs with an atomic update gives the same protection, and holds no connection across slow mint calls.
  • Restoring only on resend. The plan had the reconcile job restore lost swaps too. Doing that would let anyone's dead or hostile mint cost the worker a call for each pending order, so restore happens when the browser resends.
  • Dense QR codes. The Studio blocks a QR below 0.30 mm modules. The owner chose to let a person accept that and print it, after learning the block existed. The floor of 0.17 mm is an added limit, as a printer can't reproduce finer modules. Only size is relaxed. See docs/final-report.md.
  • No Docker or remote here. The owner chose to leave these for later, so the images and CI are unverified.

Needs owner decision (added during the build)

  • Web of trust. The setting keeps only self and follows. No WOT_API_URL service is wired up.
  • Fork mirroring. A fork re-uploads art rather than calling BUD-04 mirror.
  • Claim wallet list. apps/web/src/content/wallets.ts lists wallets by what they are for. None has been tested with a printed note.
  • Paying from another machine. The local mint addresses are localhost, so a phone or another computer cannot reach them. Production needs real mint addresses. This also affects anyone testing over the LAN address.