Commit graph

349 commits

Author SHA1 Message Date
GaltRanch
cc9a5e236e Handle empty bitcoincli path gracefully instead of crashing
When bclock.conf has an empty bitcoincli path, catch the PermissionError
and redirect to introINIT() with a helpful error message instead of
crashing with 'Fatal error: Permission denied'.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 13:47:26 -03:00
GaltRanch
b6540b059b Add Textual TUI dashboard (Level 3) with --tui launch flag
New pybitblock/tui/ package providing a modern terminal UI:

Structure:
  tui/app.py           - Main Textual App with CSS layout, auto-refresh
  tui/screens/         - Screen classes (main_menu.py with keybindings)
  tui/widgets/         - StatusBar widget with reactive block/price data
  tui/workers/         - Async data fetchers (block height, price, fees, mempool)

Features:
  - Persistent status bar with mode, block height, BTC price
  - Side panel showing live fee estimates (fast/medium/slow)
  - Keyboard navigation (A=PyBLOCK, B=Bitcoin, L=Lightning, etc.)
  - Auto-refresh every 30 seconds via async workers
  - Dark theme with Bitcoin-inspired color scheme
  - CSS-based responsive layout

Launch: python3 PyBlock.py --tui
Fallback: python3 PyBlock.py (original CLI mode)

Added textual>=0.89 to requirements.txt.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 13:35:04 -03:00
GaltRanch
f30ba8ea04 Integrate Rich panels, headers, and menus in main menu screens
Replace ANSI escape code menus with Rich-styled components:
- PyBlock.py MainMenu(): Rich status bar, header panel with node info,
  table-based menu with colored keys
- SPV/spvblock.py MainMenuCROPPED(): same Rich integration
- Use rich_prompt() for styled input

The main menu now renders with bordered panels, consistent styling,
and proper terminal-width adaptation via Rich.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 13:29:40 -03:00
GaltRanch
d9b0862a1b Add invalid option feedback to main menu controllers
When users type an unrecognized option, they now see a yellow
"Invalid option 'X'. Try again." message instead of silent no-op.

Applied to:
- PyBlock.py mainmenuControl() and bitcoincoremenuLocalControl()
- SPV/spvblock.py mainmenuLOCALcontrol()

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 13:15:20 -03:00
GaltRanch
a2c31cd41a Add visible error messages to user instead of silent logging
Add show_error(str(e)) before every logger.debug() call so users see
a red error message when operations fail, instead of silent failures:
- PyBlock.py: 31 instances of "Suppressed error" pattern
- SPV/spvblock.py: 186 instances of "spvblock" error pattern

Users now see "! Error: <message>" in red text before being returned
to the menu, while errors still log to pyblock.log for debugging.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 13:13:16 -03:00
GaltRanch
458b60fbbc Add status bar with mode, block height, and BTC price to main menus
- PyBlock.py MainMenu(): fetch BTC price from mempool.space API,
  display status_bar() showing mode/block/price before menu header
- SPV/spvblock.py MainMenuCROPPED(): same status_bar integration
- Import shared.ui utilities in both files

The status bar shows at a glance: active mode (Local/Remote/Lite),
current block height, and USD price of Bitcoin.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 13:09:21 -03:00
GaltRanch
04c0e33efc Rename 'Cropped' mode to 'Lite Mode' in user-facing text
- PyBlock.py: Update intro screen text and option label
- SPV/spvblock.py: Change all n="CROPPED" display labels to "LITE MODE"
- Internal config value 'cropped' in intro.conf unchanged for backward compat

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 13:07:21 -03:00
GaltRanch
455cb986ce Convert download/install shell chains to list-based subprocess in PyBlock.py
Replace 27 mkdir/cd/wget/tar/unzip/git-clone/chmod shell chains with
os.makedirs() + list-based subprocess.run(cwd=) calls:
- Mempool-cli x86/ARM installers
- Phoenix wallet 4 platform installers
- Nostr console 5 platform installers + seed tools
- SatSale, Warden, Bija, Coldcore, Cashu, bpytop, Luxor, UTXOracle

4 remaining shell=True are legitimate pipe chains (bitcoincli|xxd, jq).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 12:51:41 -03:00
GaltRanch
c0b40e91f7 Convert simple subprocess shell=True to list format with cwd
Replace cd-and-run shell patterns with list-based subprocess.run()
using cwd parameter for directory context:

- Phoenix macOS ARM installer
- Luxor CLI help
- Mempool CLI (2 instances)
- SatSale, Cashu, Warden, bpytop launchers
- Bija docker-compose
- Both SPV/spvblock.py and PyBlock.py

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 12:21:08 -03:00
GaltRanch
273d806d37 Rename shadowed builtin 'list' variable to 'cmd'
Replace all uses of 'list' as a variable name for shell command strings
with 'cmd' to avoid shadowing Python's built-in list type.
Affects ppi.py, PyBlock.py, SPV/ppi.py, and SPV/spvblock.py.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 12:10:49 -03:00
GaltRanch
a746b36420 Replace star imports with explicit imports in core files
- PyBlock.py: Replace 14 star imports with explicit named imports,
  remove unused `from art import *` and `from SPV.spvblock import *`
- ppi.py: Replace star imports, remove unused art/nodeconnection imports,
  remove duplicate `import requests` and dead lnpay_py comments
- nodeconnection.py: Replace star imports, remove unused art import

This improves code clarity, prevents namespace pollution, and makes
dependencies between modules explicit and traceable.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 12:03:52 -03:00
GaltRanch
3c7eb44030 Fix mutable default argument bug in all rpc() functions
Replace params=[] with params=None pattern to prevent shared state
between calls. Affects PyBlock.py, nodeconnection.py,
SPV/nodeconnection.py, and clockscriptREMOTE.py.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 11:59:22 -03:00
GaltRanch
7366e9fe9c Refactor architecture: config singleton, logging, menu system, dependencies
Major improvements across 7 areas:

- Add centralized Config singleton (config.py) replacing ~176 config
  reloads per session with a single cached load
- Add logging framework (log.py) with RotatingFileHandler, replacing
  silent except Exception: pass blocks with structured logging
- Refactor menu system (menu.py) with data-driven color selection,
  eliminating ~1,370 lines of duplicate menu functions
- Create shared/ modules extracting 7 utility functions duplicated
  between PyBlock.py and SPV/spvblock.py
- Clean dependencies: pin all versions, remove stdlib packages
  (asyncio, threading), remove unused imports
- Improve Docker: pin ubuntu:24.04, add non-root user, use venv
- Improve CI: update to actions v4/v5, add test job before publish
- Fix entry point: wrap main loop in def main(), proper module import

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 10:58:24 -03:00
GaltRanch
0224cfe230 Fix critical security vulnerabilities across the codebase
Replace insecure patterns that exposed the application to command injection,
arbitrary code execution, and data interception attacks.

- Replace os.popen/os.system with subprocess.run using argument lists
- Migrate pickle config serialization to JSON format
- Replace bare except: blocks with specific exception types
- Fix insecure HTTP URLs to HTTPS (opreturnbot.com, ascii.live)
- Replace shell curl commands with requests library calls
- Add migrate_config.py script for pickle-to-JSON config migration
- Convert existing SPV config files to JSON format

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 10:24:47 -03:00
Satoshi Nakamoto
db8a30f584
Update menu options for Bitcoin and Lightning 2026-03-21 04:18:19 +01:00
Satoshi Nakamoto
e775426be3
Remove unused import for jq in PyBlock.py 2025-11-28 23:53:34 +01:00
Satoshi Nakamoto
2675d92c52
Update PyBlock.py 2025-06-22 19:03:58 +02:00
curly60e
9c37b04deb
Update PyBlock.py 2025-03-16 00:23:02 -03:00
Satoshi Nakamoto
9ddd808a3a
Update PyBlock.py 2024-12-27 16:33:54 +01:00
Satoshi Nakamoto
551ab4d2cb
Update PyBlock.py 2024-10-28 00:15:36 +01:00
Satoshi Nakamoto
c6e95ea947
Update PyBlock.py 2024-10-23 01:45:05 +02:00
Satoshi Nakamoto
56fd5b0a1b
Update PyBlock.py 2024-10-22 19:15:04 +02:00
Satoshi Nakamoto
b98cba242b
Update PyBlock.py 2024-10-22 00:50:59 +02:00
Satoshi Nakamoto
3363b47155
Update PyBlock.py 2024-10-22 00:47:34 +02:00
Satoshi Nakamoto
c09c3bf4b2
Update PyBlock.py 2024-10-22 00:24:42 +02:00
Satoshi Nakamoto
83fde9a9e0
Update PyBlock.py 2024-10-22 00:07:20 +02:00
Satoshi Nakamoto
54c0da9e25
Update PyBlock.py 2024-10-17 20:53:48 +02:00
Satoshi Nakamoto
a947365469
Update PyBlock.py 2024-10-17 20:46:40 +02:00
Satoshi Nakamoto
2c30aa07ae
Update PyBlock.py 2024-10-04 15:43:18 +02:00
Satoshi Nakamoto
60a3e329f7
Update PyBlock.py 2024-10-02 19:19:37 +02:00
Satoshi Nakamoto
06d528612f
Update PyBlock.py 2024-09-27 00:01:38 +02:00
Satoshi Nakamoto
fdc83a0d2d
Update PyBlock.py 2024-09-26 23:53:52 +02:00
Satoshi Nakamoto
4e44e0aa48
Update PyBlock.py 2024-09-20 00:56:05 +02:00
Satoshi Nakamoto
7c3b7decdd
Update PyBlock.py 2024-08-15 02:07:08 +02:00
Satoshi Nakamoto
ec9df19319
Update PyBlock.py 2024-08-14 23:23:39 +02:00
Satoshi Nakamoto
7157cf2a7a
Update PyBlock.py 2024-07-30 22:53:16 +02:00
curly60e
5af6a355c4
Add files via upload 2024-07-30 14:49:21 -03:00
Satoshi Nakamoto
361faf130d
Update PyBlock.py 2024-07-30 19:11:08 +02:00
curly60e
e93b9243fa
Update PyBlock.py 2024-07-29 18:22:11 -03:00
curly60e
7981cf9dc1
Add files via upload 2024-07-29 18:21:21 -03:00
curly60e
920cfa13ff
Update PyBlock.py 2024-07-26 19:15:10 -03:00
curly60e
0189756514
Add files via upload 2024-07-26 19:07:59 -03:00
Satoshi Nakamoto
27adf61819
Update PyBlock.py 2024-07-26 23:19:24 +02:00
curly60e
0d6ea3fdf7
Add files via upload 2024-07-26 17:06:38 -03:00
Satoshi Nakamoto
e589f3f48e
Update PyBlock.py 2024-07-26 21:29:15 +02:00
curly60e
640e366290
Add files via upload 2024-07-26 14:39:30 -03:00
curly60e
88f42da9a3
Add files via upload 2024-07-26 11:44:48 -03:00
curly60e
f161997004
Add files via upload 2024-07-26 11:39:24 -03:00
curly60e
391554c05a
Update PyBlock.py 2024-07-26 10:49:52 -03:00
curly60e
3df93ef809
Add files via upload 2024-07-26 10:47:28 -03:00