From 2f4ed4aa88f843b683b34f05ae45aef3926c8e38 Mon Sep 17 00:00:00 2001 From: satoshi Date: Sun, 26 Apr 2026 18:41:05 +0300 Subject: [PATCH] Fix BTC-vs-source-IP confusion; redesign user page; OSS + TLS icons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ckpool's stratum_instance.address (exposed as the "address" field in the runtime JSON) is the SOURCE IP of the connection — set from inet_ntop in connector.c — not the BTC payout address. The miner's BTC payout comes from the stratum username, which ckpool stores in worker.user (and in the dotted prefix of worker.workername). Every "user" reference in the dashboard was reading c.address and treating it as the BTC. Effects: • clicking an online miner navigated to #/user/; the UserDetailPage filters never matched and the page rendered with junk values (or the user struct's stale residual hashrate when the BTC happened to come from a sibling row). • offline-miner clicks worked, but totals came from user.dsps* which decay slowly inside ckpool, so a miner that had just disconnected still showed positive hashrate for several minutes. • the "Best (ever)" tile fell back to bestdiff (session) when bestever was zero, so it lied about its semantics. Fixes: • Add btcAddressOf() helper and use w.user (or it) when extracting the BTC for the user-link button. The source IP gets its own sub-line under the worker name, clearly labelled. • Redesign UserDetailPage: filter clients by workername prefix against the BTC, never by c.address; compute hashrate totals by SUMMING the user's currently-connected clients (so 0 online clients => 0 hashrate, no stale decay artifacts); compute best_ever as max across the user's worker.bestever values; show online/total worker counts and a per-worker status pill. • Add an explorer link (mempool.space) for the user's BTC. TLS detection moves to a clean signal: ckpool now binds two stratum sockets — public plaintext and loopback-only. stunnel forwards to the loopback bind, so TLS clients arrive with c.server == 1. The dashboard reads that and renders a green TLS pill next to the worker name. No source-IP heuristics needed. Open-source mark: new isOpenSource() heuristic over the stratum useragent matches Bitaxe family (NerdAxe / NerdQAxe / NerdMiner / NerdOctaxe / Lucky / QAxe / MCCM), Braiins OS, cgminer / bfgminer / ckminer, and ESP32 builds. Renders as an orange ★ next to the hardware label, matching public-pool's convention. types.ts: document StratumClient.address (source IP, not BTC) and add the previously-undeclared `server` field. Surfacing the runtime value that has been there all along since cfb0f83. --- ckpool/config/ckpool.conf.template | 3 +- ui/src/format.ts | 19 +++ ui/src/lib/MinersTable.svelte | 112 ++++++++---- ui/src/lib/UserDetailPage.svelte | 265 ++++++++++++++++++++++------- ui/src/types.ts | 8 + 5 files changed, 312 insertions(+), 95 deletions(-) diff --git a/ckpool/config/ckpool.conf.template b/ckpool/config/ckpool.conf.template index f9d0334..a32feeb 100644 --- a/ckpool/config/ckpool.conf.template +++ b/ckpool/config/ckpool.conf.template @@ -12,7 +12,8 @@ "blockpoll": ${BLOCKPOLL_MS}, "update_interval": ${UPDATE_INTERVAL_S}, "serverurl": [ - "0.0.0.0:${STRATUM_PORT}" + "0.0.0.0:${STRATUM_PORT}", + "127.0.0.1:${TLS_INTERNAL_PORT}" ], "mindiff": ${MINDIFF}, "startdiff": ${STARTDIFF}, diff --git a/ui/src/format.ts b/ui/src/format.ts index f9e394d..249d8f5 100644 --- a/ui/src/format.ts +++ b/ui/src/format.ts @@ -63,6 +63,25 @@ export function formatAgo(unixSeconds: number): string { return `${Math.floor(ageSec / 86400)}d ago`; } +// Open-source ASIC hardware (Bitaxe family, NerdMiner, etc.) and +// open-source firmware projects (Braiins OS, cgminer/bfgminer/ +// ckminer). Used to render a star next to the hardware label, like +// public-pool does, so visitors can spot DIY / OSS rigs at a glance. +export function isOpenSource(ua: string): boolean { + if (!ua) return false; + const s = ua.toLowerCase(); + return /bitaxe|nerdaxe|nerdqaxe|nerdoctaxe|nerdminer|qaxe|mccm|lucky|braiins|cgminer|bfgminer|ckminer|esp32/.test(s); +} + +// Extract the BTC payout address from a stratum username. Stratum +// usernames in solo mode are "" or ".label". +// ckpool stores this verbatim in the worker name. +export function btcAddressOf(workername: string): string { + if (!workername) return ""; + const dot = workername.indexOf("."); + return dot < 0 ? workername : workername.slice(0, dot); +} + // Detect common Bitcoin mining hardware from the stratum useragent // string. This is a best-effort heuristic; unknown agents fall back // to a stripped version of the raw string. Order matters — check diff --git a/ui/src/lib/MinersTable.svelte b/ui/src/lib/MinersTable.svelte index a887904..826aedb 100644 --- a/ui/src/lib/MinersTable.svelte +++ b/ui/src/lib/MinersTable.svelte @@ -1,27 +1,43 @@