# Browser wallet through the live rendezvous relay The wallet page pointed at the public relay instead of a gateway key: ``` http://127.0.0.1:8080/?chains=btc&network=btc gateway uri: wss://swaprelay.smesh.lol profile: (empty: the built-in Bitcoin mainnet profile) ``` The channel is handed a bare `wss://` and discovers the gateway from the relay's listing, so nothing on the page names Gary's key. Everything below is a real mainnet run: a real gateway, the real network, the real relay. ## Result: BTC syncs from the relay in the browser | step | result | | --- | --- | | connect (discovery + tunnel) | 0.2 s, `connected: the wallet drives btc` | | channel | `nostrino channel: btc syncing from genesis` | | peer (from the gateway's node) | `protocol=70016 services=0xc49 tip=972919 user=/Satoshi:29.3.0/Knots:20260507/` | | 152 s of sync, then Pause | `paused at tip 170000 (filters 0)` | | what pause leaves | `status-btc.json`: `tip 170000`, `hasWallet true`, `unlocked true`, `running false` | | address format | `profile btc · account 0 · hrp bc` (mainnet) | Screenshots: `01-relay-set.png`, `02-connected.png`, `03-wallet.png`, `04-paused.png`. Runner: `run.py`; console log: `run-btc.log`. So: the browser discovers the gateway from the relay alone, opens the NIP-44 tunnel, verifies 170,000 mainnet headers from genesis, and a pause keeps every verified height for the next run. The wallet itself is created before the sync and survives the pause. ### Throughput, measured 170,000 headers in 152 s is **1,118 headers/s ≈ 89 kB/s** (13.6 MB). That is 45× under the gateway's 4 MiB/s per-stream cap, and it matches what Gary measured on his side (11,289 checkpointed headers in 9 s ≈ 100 kB/s). At 10–15 GB of filters, the current rate is tens of hours, not the 3–4 h a 1 MiB/s line would give, so throughput is the next thing to profile. The two candidates are the per-header store write (both clients write one height at a time) and per-batch round trips on the tunnel; a native run with `-memory -headers-only` failed on a read timeout while reading a 162,003-byte headers payload, which points at latency per batch rather than at raw bandwidth. ## BLAKE: blocked on the fork's header format, not on the relay Without a chain profile the channel answers `chain: unknown profile "blake"` — expected, the kernel carries no XBT parameters. With a profile it reaches the gateway and the handshake completes (Gary confirms this), but the header sync stops at: ``` btcwire: invalid payload: headers entry 8 has 132 transactions ``` That is the v2 header. The fork's `CompressedHeader` (bitcoinknots `src/primitives/block.h`) sets `VERSION_HEADER_V2_FLAG = 0x80000000` and appends, after the usual 80 bytes: `nonce2`, `nonce3`, `extranonce` (16), `time_offset`, `txcount`, `flags`, `xor_key_mask_clear_bits`, `xor_key` (16), `height`, `mm_rhs` (32) — 164 bytes per header, and an 80-byte header in the same message has no extras at all. Our decoder assumes 80 bytes everywhere, so it reads the extras as the next header's transaction count. The hash is fork-specific too: `CBlockHeader::GetHash` runs a `TaggedHash("Bitcoin block header 1")`/`TaggedHash("Merge-mining hook")` construction, a first keyed-by-nonce BLAKE2b over the reconstructed Sv1/ASIC byte stream, a second BLAKE2b that depends on `m_flags & 3`, and an XOR mask derived from `m_xor_key`. Difficulty also shifts once at the BLAKE2b deployment height (`ApplyBlake2bTargetShift`, `params.Blake2bTargetShift`). ## Evidence notes - The listing's `tip` for btc (978,767) disagrees with the tip the gateway's node reports (972,919), and blake's listing is 978,768. Worth a look on the gateway side: the per-chain tips in the presence event look swapped or stale. - `chromium-profile-btc/` is the browser profile the run created; it is not evidence and is listed in `.gitignore` below. ## BLAKE: the browser syncs the fork from its checkpoint The fork's checkpoint (961,631) is in the xbt chain profile, and the page pointed at the same bare relay with `?chains=blake&network=xbt`: | step | result | | --- | --- | | connect | 0.1 s | | channel | `blake syncing from the checkpoint at 961631` | | peer | `protocol=70016 services=0x10000c49 tip=978786 user=/Satoshi:29.4.2/Knots:20260508/` | | sync | `961631..978786: 16155 filters, 26.4 MiB in 9m59s` (45 KiB/s through the relay) | | result | the wallet matched a filter at 962,619 and failed fetching that block | The header and filter sync is correct end to end for the fork — 164-byte headers, the BLAKE2b proof-of-work, the one-off target shift at 961,640, and a store that reloads and resumes. The block fetch is where it stops: ``` domain: "blake": fetching block 962619: chainsource: neutrino: the block is larger than the cap: the peer sent f8cb343e61399f82c0718699d60d2fd9420f38454b3b5c6a8cb4782e8d925b38, not 00000000000000860da6e00cf4e6fc4ac619d2885db86712981a75436ff69dac ``` The returned block was hashed wrongly: the block decoder assumed an 80-byte header, and on the fork the hash of the first 80 bytes is not the block's hash. Fixed in `pkg/block` and in the fetch path. The same run with the fixed wasm (a stale cached worker was masking it): ``` from 962632 to tip 978786 (filters 978786) 201 scripts matched · 6 new height(s): 962619, 964279, 966617, 968795, 972014, 974954 ``` Six blocks out of sixteen thousand matched the wallet's 201 scripts and none contained a coin: that is the expected compact-filter false positive rate, and each one was fetched and its block hash checked against the header chain before being read. The fork chain is now synced and scanned end to end in the browser through the public relay. One gotcha for anyone repeating this: Chromium caches the worker wasm across runs, so the evidence runner now clears the browser cache before loading the page.