The short version, for everyone: Shop no. 5, Mall Café in Kisumu, now takes bitcoin through a printed QR poster. A QR code on a café wall has to survive things a phone screen never meets: a logo stamped in its middle, lamination glare, a customer standing a metre away, and years of wear. This post is about the engineering of that one square: what's encoded in it, how big it has to be, and an experiment that shows how much of it you can cover before it stops working.
This time the QR tells the story.
Shop no. 5 is Mall Café in Kisumu. Its poster came off the printer, went through the hot press so it survives a busy café, crossed town under a moody sky, and went up at the counter.
Contents
- Five shops in five days
- The poster, by the numbers
- What's encoded: a URL that is also a Lightning payment
- LNURL: bech32, and why it's uppercase
- How big is the code? Versions and modules
- Error correction: level H, and why
- The experiment: how much can the logo cover?
- Scan distance and print size
- The physical world: lamination, light and wear
- The checklist before printing
- What it costs, and how to help
Five shops in five days
I set out to onboard one merchant a week. Since 8 November we've onboarded five.
Each shop gets kTown: a QR that takes bitcoin from any Lightning wallet and pays the shop in shillings on M-Pesa. No new app, no exchange account, nothing new at the till. How the payment itself flows is in the $1 QR post. This post is about the square on the wall.
The poster, by the numbers
Every kTown poster follows one template, generated from HTML and printed from a browser:
| Element | Size |
|---|---|
| Sheet | A4, 210 × 297 mm, printed at 100% with background graphics on |
| QR frame | 150 × 150 mm, 2.2 mm orange border, 7 mm white padding inside |
| QR code itself | about 131.6 mm square (150 − 2 × 7 − 2 × 2.2) |
| Centre logo panel | 54 × 22 mm, white, rounded |
| Colours | QR always black on white; orange #F7931A only around it |
Two rules in that table are non-negotiable. The QR is black on white, never orange on white or white on orange: phone decoders threshold on luminance, and low-contrast codes fail first in bad light. And the orange frame sits outside the white padding, so the code keeps a clean quiet zone (QR needs a light margin around it for the scanner to find its edges).
What's encoded: a URL that is also a Lightning payment
The poster's QR does not hold a bare Lightning payment code. It holds this (shop id made up):
https://altradits.com/k/AbCdEfGhIjKl?lightning=LNURL1DP68GURN8GHJ7CTVW3EXZERFW3EJUCM0D5...
That is the LUD-01 "fallback" scheme, and it solves a real problem in a place where most people don't have a Lightning wallet yet:
-
A Lightning wallet that scans it sees the
lightning=parameter, takes the LNURL out, and goes straight to the payment. - A normal phone camera sees a web link and opens kTown's pay page for that shop, in English or Swahili: enter an amount in shillings, get an invoice to scan or an "Open in wallet" button, and see whether the shop's M-Pesa name is confirmed.
One code, two audiences, no dead end. The generator in the admin page builds it like this:
posterQr(`${m.payUrl}?lightning=${m.lnurl}`) // payUrl: `${site}/k/${m.id}`
LNURL: bech32, and why it's uppercase
The LNURL1… part is the shop's payment URL, https://altradits.com/.well-known/lnurlp/k-<id>, encoded with bech32, the same encoding Bitcoin uses for bc1… addresses. kTown's encoder is 40 lines with no dependencies (lib/lnurl.js):
export function encodeLnurl(url) {
const hrp = "lnurl";
const data = toWords(Buffer.from(url, "utf8")); // 8-bit bytes -> 5-bit words
const mod = polymod([...hrpExpand(hrp), ...data, 0, 0, 0, 0, 0, 0]) ^ 1; // BCH checksum
const checksum = [0, 1, 2, 3, 4, 5].map((i) => (mod >>> (5 * (5 - i))) & 31);
return (hrp + "1" + [...data, ...checksum].map((d) => CHARSET[d]).join("")).toUpperCase();
}
The 6-character checksum catches typos and misreads, so a wallet can tell a damaged code from a valid one.
The .toUpperCase() at the end is not cosmetic. QR codes have an alphanumeric mode that packs uppercase letters, digits and a few symbols into 5.5 bits per character, instead of 8 bits in byte mode. Bech32 is case-insensitive, so uppercasing is free. On its own, a 100-character LNURL fits in a smaller QR uppercase than lowercase:
| Encoded | Characters | Level H version | Modules |
|---|---|---|---|
| LNURL, uppercase (alphanumeric mode) | 100 | 8 | 49 × 49 |
| LNURL, lowercase (byte mode) | 100 | 10 | 57 × 57 |
Poster: pay URL + ?lightning= + LNURL |
147 | 12 | 65 × 65 |
The poster pays for its friendlier fallback URL with a bigger code: lowercase letters in the URL force byte mode for the whole string. On a 131.6 mm square that's fine, as the next section shows. On a sticker it might not be.
How big is the code? Versions and modules
A QR version fixes its grid: version v is (17 + 4*v*) modules on a side. More data or more error correction means a higher version, a finer grid, and smaller modules at the same printed size. I measured the real poster data with the same QR library the template uses (qrcode-generator 1.4.4):
import { createRequire } from "node:module";
import { encodeLnurl } from "./lib/lnurl.js";
const require = createRequire(import.meta.url);
const qrcode = require("./qrcode-generator-1.4.4.js");
const id = "AbCdEfGhIjKl"; // made-up shop id
const lnurl = encodeLnurl(`https://altradits.com/.well-known/lnurlp/k-${id}`);
const text = `https://altradits.com/k/${id}?lightning=${lnurl}`;
for (const ec of ["L", "H"]) {
const q = qrcode(0, ec); q.addData(text); q.make();
const n = q.getModuleCount();
console.log(`EC ${ec}: version ${(n - 17) / 4}, ${n}x${n}, module ${(131.6 / n).toFixed(2)} mm`);
}
pay page + ?lightning=LNURL (poster) 147 chars EC L: version 7, 45x45 modules, module at 131.6 mm = 2.92 mm
pay page + ?lightning=LNURL (poster) 147 chars EC H: version 12, 65x65 modules, module at 131.6 mm = 2.02 mm
So each black or white square on the wall is about 2 mm across. That number drives everything about scan distance below.
Error correction: level H, and why
QR codes carry Reed–Solomon error correction at four levels. Roughly, the share of codewords that can be recovered:
| Level | Recovers about |
|---|---|
| L | 7% |
| M | 15% |
| Q | 25% |
| H | 30% |
The template uses the highest:
const q = qrcode(0, "H"); // level H: the centre mark covers part of the code
The reason is the logo. A 54 × 22 mm white panel sits on top of the code's centre, destroying every module under it. On the 65 × 65 grid at 2.02 mm per module, that panel covers about 26.7 × 10.9 modules: about 290 of 4,225 modules, or 6.9% of the area. Error correction is the only reason the code still reads. The cost of level H is the bigger grid (version 12 instead of 7), which the poster's size absorbs easily.
The experiment: how much can the logo cover?
"Level H recovers 30%" is a statement about codewords, not about a rectangle in the middle, so I tested it directly. The script renders the poster's real QR into pixels, blanks a white rectangle with the logo's 54:22 shape in the centre, grows it, and asks jsQR (the decoder used for the template's print check) to read the result:
occlude.mjs (click to expand)
import { createRequire } from "node:module";
import { encodeLnurl } from "./lib/lnurl.js";
const require = createRequire(import.meta.url);
const qrcode = require("./qrcode-generator-1.4.4.js");
const jsQR = require("jsqr"); // npm i jsqr@1.4.0
const id = "AbCdEfGhIjKl";
const text = `https://altradits.com/k/${id}?lightning=${encodeLnurl(`https://altradits.com/.well-known/lnurlp/k-${id}`)}`;
function decodeWithHole(ec, holeFrac, aspect = 54 / 22) {
const q = qrcode(0, ec); q.addData(text); q.make();
const n = q.getModuleCount(), px = 6, quiet = 4, size = (n + 2 * quiet) * px;
const data = new Uint8ClampedArray(size * size * 4).fill(255);
// a white rectangle with the logo's shape, covering holeFrac of the code area
const area = holeFrac * n * n, hh = Math.sqrt(area / aspect), hw = hh * aspect;
const x0 = (n - hw) / 2, y0 = (n - hh) / 2;
for (let r = 0; r < n; r++) for (let c = 0; c < n; c++) {
const inHole = c + 1 > x0 && c < x0 + hw && r + 1 > y0 && r < y0 + hh;
if (!q.isDark(r, c) || inHole) continue;
for (let y = 0; y < px; y++) for (let x = 0; x < px; x++) {
const i = (((quiet + r) * px + y) * size + (quiet + c) * px + x) * 4;
data[i] = data[i + 1] = data[i + 2] = 0;
}
}
const res = jsQR(data, size, size);
return { n, ok: res?.data === text };
}
for (const ec of ["M", "H"]) {
const row = [];
for (const f of [0, 0.03, 0.05, 0.069, 0.09, 0.12, 0.15, 0.18, 0.21, 0.25]) {
const { n, ok } = decodeWithHole(ec, f);
row.push(`${(f * 100).toFixed(1)}%:${ok ? "ok" : "FAIL"}`);
if (f === 0) row.unshift(`EC ${ec} (${n}x${n})`);
}
console.log(row.join(" "));
}
Our run:
EC M (49x49) 0.0%:ok 3.0%:ok 5.0%:ok 6.9%:ok 9.0%:ok 12.0%:ok 15.0%:FAIL 18.0%:FAIL 21.0%:FAIL 25.0%:FAIL
EC H (65x65) 0.0%:ok 3.0%:ok 5.0%:ok 6.9%:ok 9.0%:ok 12.0%:ok 15.0%:ok 18.0%:ok 21.0%:ok 25.0%:FAIL
Three takeaways:
- At level H the poster has roughly three times the margin it needs. The real logo covers 6.9%; the code still reads with 21% covered.
- Level M would have worked too, but barely: it reads at 12% and fails at 15%. That margin is what the wall eats: glare, a scratch, a smudge of flour.
- The limit sits below the textbook figure. H "recovers 30%", but a centre hole fails at 25%. The hole destroys more than whole codewords, and it starts eating into structural parts of the grid (alignment patterns in the middle of larger versions).
This is a best case: a perfect render, no blur, no perspective, no glare. Real phones lose margin to all of those, which is exactly why the margin is worth having. The template's rule is to decode-test every new poster design and have a real phone scan one printout before printing many.
Scan distance and print size
How far away can a customer stand? A practical rule of thumb for printed QR codes is that the code should be about one tenth of the scanning distance wide. Applied to this poster:
code width 131.6 mm
x 10 ≈ 1.3 m comfortable maximum scanning distance
That matches a counter: the customer stands in the queue, phone at chest height. The module size tells the same story from the other side: at 2 mm per module, a phone camera at a metre has plenty of pixels per module. Shrink the same data onto a 3 cm sticker and the modules fall to under half a millimetre, at which point the customer must hold the phone a few centimetres away, and cheap cameras struggle to focus that close.
This is also why the fallback URL design is a trade-off worth naming. It makes the code bigger (version 12 against version 8 for a bare uppercase LNURL). On an A4 poster that costs nothing. On a small sticker it would cost scan distance, and a bare uppercase LNURL would be the better choice.
The physical world: lamination, light and wear
Software people forget that a payment QR is a physical object:
- Lamination protects against rain, flour and busy hands, which is why every poster goes through a hot press. The cost is reflection: a shiny surface under a café's bulb can wash out part of the code. Level H's margin is what absorbs a glare spot.
- Black on white, always. Inverted codes (light modules on dark) are part of the standard, but some phone decoders still refuse them. Branded colours stay in the frame.
- The quiet zone stays empty. The white padding inside the frame is part of the code, not decoration. Text or a border touching the code makes finder patterns harder to locate.
- Print at 100%. "Fit to page" silently shrinks the code and every module with it. The template's print instructions say A4, 100%, background graphics on.
The checklist before printing
From the template's rules, the order I follow for every new design:
- Generate the poster from the shop's real data.
- Decode-test the rendered code (jsQR), and confirm the decoded text is exactly the shop's URL.
- Print one copy at 100% on A4.
- Scan the printout with a real phone, both with a Lightning wallet (should go straight to payment) and with the plain camera app (should open the shop's pay page).
- Only then print and laminate the rest.
Printing a poster also secures the shop in kTown: a shop I've visited can't be taken over by someone else registering its number, so a poster on a wall always points at the right owner.
What it costs, and how to help
Each laminated poster costs me about $1. Merchants pay nothing. I have no sponsor, so I fund it myself, including the sats I spend paying at each shop so the owner sees it work. I've now applied for grants so kTown can keep going without depending on my pocket.
- Run a shop? Register free: https://altradits.com/ktown/
- Sponsor the next shop or donate sats: https://altradits.com/donate.html
- Know work that pays in sats? Kisumu needs people who earn bitcoin, not just shops that accept it.
-
Wallet developers: test your scanner against
https://…?lightning=LNURL1…codes, not only bare LNURLs.
Not sponsored. No paid posts.
Watch and follow
- YouTube Short: https://youtube.com/shorts/m2-UT59vYEQ
- X: https://x.com/altradits/status/2120873144672231705
- LinkedIn: https://www.linkedin.com/posts/stanmobitech_bitcoin-lightning-mpesa-ugcPost-7526639549096206337-XvSh/
- Facebook: https://www.facebook.com/reel/2325100758235989
- Instagram Reel: https://www.instagram.com/reel/DfpL66uSlP_/
- TikTok: https://www.tiktok.com/@altradits/video/7707279854151994637
Top comments (0)