From e71be20047a2fa74cf61b3a99796dad758f88ef8 Mon Sep 17 00:00:00 2001 From: Alexander Whitestone Date: Tue, 24 Mar 2026 23:05:59 -0400 Subject: [PATCH] feat: re-implement Bitcoin block height counter Adds the Bitcoin block height HUD element from reference/v2-modular back into the main codebase. Fetches from blockstream.info API every 60 seconds and flashes on new block discovery. Fixes #480 --- app.js | 32 ++++++++++++++++++++++++++++++++ index.html | 6 ++++++ style.css | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+) diff --git a/app.js b/app.js index 9a03e40..ea33a58 100644 --- a/app.js +++ b/app.js @@ -1692,4 +1692,36 @@ function triggerHarnessPulse() { } } +// === BITCOIN BLOCK HEIGHT === +(function initBitcoin() { + const blockHeightDisplay = document.getElementById('block-height-display'); + const blockHeightValue = document.getElementById('block-height-value'); + if (!blockHeightDisplay || !blockHeightValue) return; + + let lastKnownBlockHeight = null; + + async function fetchBlockHeight() { + try { + const res = await fetch('https://blockstream.info/api/blocks/tip/height'); + if (!res.ok) return; + const height = parseInt(await res.text(), 10); + if (isNaN(height)) return; + + if (lastKnownBlockHeight !== null && height !== lastKnownBlockHeight) { + blockHeightDisplay.classList.remove('fresh'); + void blockHeightDisplay.offsetWidth; + blockHeightDisplay.classList.add('fresh'); + } + + lastKnownBlockHeight = height; + blockHeightValue.textContent = height.toLocaleString(); + } catch (_) { + // Network unavailable + } + } + + fetchBlockHeight(); + setInterval(fetchBlockHeight, 60000); +})(); + init(); diff --git a/index.html b/index.html index dd4d42d..15fbe56 100644 --- a/index.html +++ b/index.html @@ -154,6 +154,12 @@ + +
+ ⛏ BLOCK + +
+