Add enhanced block clock with 12 new features for Menu A
New clock/ package replaces the old design() polling loop with a
flicker-free ANSI cursor-positioned renderer. Features include:
countdown timer, epoch/halving progress bar, fee rate indicator,
hashrate sparkline, matrix mining animation, odometer digit transition,
heartbeat pulse, zen mode, UTC time display, fireworks on milestone
blocks, generative hash art, and configurable sound modes.
All features are toggleable via Settings → D (Clock Display Settings).
Also fixes hardcoded config paths in menuSelection(), menuSelectionLN(),
and TUI startup to use the cfg singleton instead.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 08:35:59 -03:00
|
|
|
"""Block hash generative ASCII art.
|
|
|
|
|
|
|
|
|
|
Uses hash bytes as seeds to create a unique visual pattern per block.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
# Characters ordered by visual density
|
|
|
|
|
GLYPHS = " \u2591\u2592\u2593\u2588\u2580\u2584\u258c\u2590\u256c\u2550\u2551"
|
|
|
|
|
|
|
|
|
|
# 256-color ANSI foreground
|
|
|
|
|
def _color256(n):
|
|
|
|
|
return f"\033[38;5;{n}m"
|
|
|
|
|
|
|
|
|
|
RESET = "\033[0m"
|
|
|
|
|
|
|
|
|
|
|
2026-04-02 09:10:53 -03:00
|
|
|
def hash_art(block_hash, width=40, height=6, term_width=80):
|
Add enhanced block clock with 12 new features for Menu A
New clock/ package replaces the old design() polling loop with a
flicker-free ANSI cursor-positioned renderer. Features include:
countdown timer, epoch/halving progress bar, fee rate indicator,
hashrate sparkline, matrix mining animation, odometer digit transition,
heartbeat pulse, zen mode, UTC time display, fireworks on milestone
blocks, generative hash art, and configurable sound modes.
All features are toggleable via Settings → D (Clock Display Settings).
Also fixes hardcoded config paths in menuSelection(), menuSelectionLN(),
and TUI startup to use the cfg singleton instead.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 08:35:59 -03:00
|
|
|
"""Generate deterministic ASCII art from a block hash string.
|
|
|
|
|
|
|
|
|
|
Each pair of hex digits maps to a glyph and color.
|
|
|
|
|
The pattern is mirrored horizontally for symmetry.
|
|
|
|
|
"""
|
|
|
|
|
# Convert hex hash to bytes
|
|
|
|
|
raw = block_hash.strip()
|
|
|
|
|
hex_pairs = [raw[i:i+2] for i in range(0, len(raw), 2)]
|
|
|
|
|
values = [int(h, 16) for h in hex_pairs if len(h) == 2]
|
|
|
|
|
|
|
|
|
|
if not values:
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
half_w = width // 2
|
|
|
|
|
lines = []
|
2026-04-02 09:10:53 -03:00
|
|
|
pad = max(0, (term_width - width) // 2)
|
Add enhanced block clock with 12 new features for Menu A
New clock/ package replaces the old design() polling loop with a
flicker-free ANSI cursor-positioned renderer. Features include:
countdown timer, epoch/halving progress bar, fee rate indicator,
hashrate sparkline, matrix mining animation, odometer digit transition,
heartbeat pulse, zen mode, UTC time display, fireworks on milestone
blocks, generative hash art, and configurable sound modes.
All features are toggleable via Settings → D (Clock Display Settings).
Also fixes hardcoded config paths in menuSelection(), menuSelectionLN(),
and TUI startup to use the cfg singleton instead.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 08:35:59 -03:00
|
|
|
|
|
|
|
|
for row in range(height):
|
|
|
|
|
left = []
|
|
|
|
|
for col in range(half_w):
|
|
|
|
|
idx = (row * half_w + col) % len(values)
|
|
|
|
|
val = values[idx]
|
|
|
|
|
|
|
|
|
|
# Glyph from lower nibble
|
|
|
|
|
glyph = GLYPHS[val % len(GLYPHS)]
|
|
|
|
|
# Color from upper nibble + row offset (for variety)
|
|
|
|
|
color_idx = 16 + ((val + row * 7) % 216) # 216-color cube
|
|
|
|
|
left.append(f"{_color256(color_idx)}{glyph}")
|
|
|
|
|
|
|
|
|
|
# Mirror for symmetry
|
|
|
|
|
right = list(reversed(left))
|
|
|
|
|
line = ''.join(left) + ''.join(right) + RESET
|
|
|
|
|
lines.append(' ' * pad + line)
|
|
|
|
|
|
|
|
|
|
return '\n'.join(lines)
|