[claude] Re-implement Bitcoin block height counter (#480) (#495)
Some checks failed
Deploy Nexus / deploy (push) Has been cancelled

This commit was merged in pull request #495.
This commit is contained in:
2026-03-25 03:06:48 +00:00
parent 518717f820
commit 6ae5e40cc7
3 changed files with 74 additions and 0 deletions

32
app.js
View File

@@ -1695,4 +1695,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();