diff options
| author | Adam Soltys <[email protected]> | 2026-06-14 23:01:03 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-06-14 23:01:03 -0700 |
| commit | c5443946031ec32a7b3008fa751eb7916654a9f6 (patch) | |
| tree | 372e8d0ccaa2dec58a6bcaaa19d3902b80eb4396 /src/qr.js | |
| parent | 683927e4132651b9198e5421fae16e9c60978fbc (diff) | |
| download | coinosv3-c5443946031ec32a7b3008fa751eb7916654a9f6.tar.gz coinosv3-c5443946031ec32a7b3008fa751eb7916654a9f6.zip | |
Rebuild as single-file offline BIP84 wallet
Replace the SvelteKit/daisyUI prototype with a vanilla JS + hand-rolled CSS
app that Bun bundles (code + scure/noble crypto + QR + CSS) into one
self-contained dist/index.html runnable offline from file://.
Wallet core (src/wallet.js):
- BIP84 native-segwit HD wallet from BIP39 seed (+optional passphrase)
- gap-limit scan of receive/change chains, aggregate balance, tx history
- fresh receive/change addresses; signs with witnessUtxo only (enables
offline signing with no prev-tx fetch)
- coin selection + fee estimation via btc-signer selectUTXO; send-max;
manual coin control
- offline JSON snapshot export/import (keyless) + signed-tx hex/QR export
- realtime mempool.space WebSocket: track-addresses -> debounced auto
refresh of balances/history (no polling); live status badge
UI (src/app.js): clean light paper-wallet; create (with optional, skippable
backup verification) / import flow; receive (QR) / send / history / coins /
tools tabs; clickable logo returns home.
API (src/api.js): mempool.space wrapper with retry/backoff for scan-burst
rate limiting; single network choke-point for offline enforcement.
Verified: BIP84 spec vectors, build/sign/parse for auto/max/manual flows,
snapshot roundtrip, live scan + WebSocket, headless-Chrome UI smoke tests.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Diffstat (limited to 'src/qr.js')
| -rw-r--r-- | src/qr.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/qr.js b/src/qr.js new file mode 100644 index 0000000..eab74a7 --- /dev/null +++ b/src/qr.js @@ -0,0 +1,27 @@ +// QR rendering via the zero-dependency `qrcode-generator` library, output as a +// crisp SVG path (scales perfectly, no canvas, prints well on a paper wallet). + +import qrcode from 'qrcode-generator'; + +export function qrSvg(text, { margin = 2 } = {}) { + const qr = qrcode(0, 'M'); // type 0 = auto-size, error correction M + qr.addData(text); + qr.make(); + + const count = qr.getModuleCount(); + const size = count + margin * 2; + + let path = ''; + for (let r = 0; r < count; r++) { + for (let c = 0; c < count; c++) { + if (qr.isDark(r, c)) { + path += `M${c + margin},${r + margin}h1v1h-1z`; + } + } + } + + return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${size} ${size}" shape-rendering="crispEdges" class="qr"> + <rect width="${size}" height="${size}" fill="#fff"/> + <path d="${path}" fill="#111"/> + </svg>`; +} |
