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 @@ + +