Commit graph

466 commits

Author SHA1 Message Date
Satoshi Nakamoto
b7e88a7f82
Update mining pool URLs in spvblock.py 2026-08-13 02:03:47 +02:00
Satoshi Nakamoto
ab0a6a3489
Update mining pool address and port 2026-08-13 02:02:05 +02:00
GaltRanch
389f6f3497 fix: address 4 security/quality findings from KCode audit
Automated fixes applied by KCode Audit Engine:
- pybitblock/SPV/apisnd.py         | 2 ++
- pybitblock/SPV/nodeconnection.py | 4 ++++
- pybitblock/ppi.py                | 2 ++

Signed-off-by: Astrolexis.space — Kulvex Code
2026-04-06 00:17:24 -03:00
GaltRanch
893aabc85d Security audit round 2: eliminate shell=True, mask secrets, fix race conditions
- Replace all shell=True subprocess calls with Python-native processing
  (nodeconnection.py, SPV/nodeconnection.py, SPV/ppi.py)
- Mask sensitive inputs (private keys, passwords, tokens) with getpass
- Add threading.Lock to block_explorer.py shared state
- Use json.loads() instead of fragile string splitting in apisnd.py
- Add path validation before file open in apisnd.py
- Replace random.randint with secrets.randbelow for mining nonces
- Fix destructive exception handlers in clone.py and feed.py
- Replace bare except clauses with specific exceptions + logging
- Remove unused imports (psutil, xmltodict, block_visualizer, base64, say)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 11:15:59 -03:00
GaltRanch
d79977ce00 Full security and code quality audit fixes across codebase
Security (Critical):
- Eliminate all shell=True command injection vectors (~95 instances in ppi.py, spvblock.py)
- Replace subprocess curl calls with requests library
- Add input validation (fiat code allowlist, IP address validation)
- Replace weak random.randint/choice with secrets module for crypto ops
- Remove token/credential exposure from print statements
- Add path traversal prevention in config.py
- Create .conf.example templates, scrub local credentials

Stability:
- Replace 63 bare except clauses with specific exceptions + logging
- Fix file handle leaks with context managers (lnd.py, apisnd.py)
- Add threading.Lock for race conditions in clock/data.py
- Cap unbounded list growth (MAX_HISTORY_LEN=50)
- Add timeout=10 to ~50 requests calls missing timeouts

Maintainability:
- Extract _load_macaroon() helper (dedup 69 instances in PyBlock.py)
- Extract _load_lnd_config() helper (dedup 33 instances in nodeconnection.py)
- Normalize json import (simplejson with stdlib fallback)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 10:57:20 -03:00
GaltRanch
3498d59214 Merge origin/master: resolve conflicts keeping ColdCore and dynamic paid status
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 17:48:20 -03:00
GaltRanch
dcb1a961d4 Address Sourcery review: subprocess audit, dead code, renderer fix
- clock/data.py: add nosemgrep suppression on audited _cli subprocess call
- clock/renderer.py: remove unreachable zen-mode check in heartbeat()
- nodeconnection.py: extract _run_ln helper with nosemgrep suppression
- SPV/spvblock.py: add nosemgrep suppression on audited subprocess calls

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 17:41:11 -03:00
GaltRanch
68e235f457 Fix dangerous-subprocess-use-audit across codebase
Replace all dynamic .split() patterns in subprocess calls with safe
alternatives: shlex.split(), explicit list args, and _run_btc/_run_ln
helpers in PyBlock.py. Covers PyBlock, block_visualizer, clockscript,
lastblockdetail, mempoolclock, nodeconnection, and ai/context.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 17:35:03 -03:00
GaltRanch
93a87351a3 Fix HIGH severity issues from security audit
#6 Shell injection in SPV/spvblock.py (6 user-input instances):
- OP_RETURN: curl shell command → requests.post()
- BitcoinStrings: validate numeric input + requests.get()
- Ocean hashrate/earnings: requests.get() instead of curl
- Weather v1/v2: requests.get() with HTTPS
- Rate.sx: requests.get() instead of curl shell pipe

#7/#8 File handle leaks in PyBlock.py:
- Replace all json.load(open(...)) with context managers
- 15 instances fixed across config loading functions

#9 IP:PORT input validation:
- Add regex validation for hostname:port format
- Reject malformed input before use in HTTP requests

#10 Invalid escape sequences in SPV/spvblock.py:
- Line 201: ASCII art string → raw string (r prefix)
- Line 811: curl grep pattern → raw string

Also: remove unused imports (Panel, Text) from ai/ui.py

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 14:38:18 -03:00
GaltRanch
cfe4e5c912 Fix 5 critical security issues from audit
1. Shell injection in readHexBlock/readHexTx (PyBlock.py):
   - Validate user input with hex-only regex before use
   - Replace shell=True pipe chain with subprocess list + piped stdin
   - Same fix for OP_RETURN loop TX decoding

2. Shell injection in weather commands (ppi.py):
   - Replace curl shell commands with requests.get()
   - User input (city, lang, unit) no longer touches shell
   - Upgraded from HTTP to HTTPS

3. Runtime crash in SPV/spvblock.py:
   - os.path.isfile() called with 2 args (TypeError)
   - Fixed to use 'and' for two separate checks

4. Config files added to .gitignore:
   - pybitblock/config/*.conf (RPC creds, API keys, tokens)
   - pybitblock/SPV/config/*.conf
   - *.log files

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 14:28:30 -03:00
GaltRanch
09377371af Remove all payment gates — LNBits, LNPay, OpenNode now FREE
Remove 1000-sat Lightning invoice paywalls from LNBits, LNPay, and
OpenNode API integrations. All three now go directly to config setup
(same flow as TippinMe/TallyCoin which were already free).

Changes:
- Replace aaccPPiLNBits/LNPay/OpenNode() payment loops with direct
  config-or-setup logic in both PyBlock.py and SPV/spvblock.py
- Change all menu labels from PAID/PREMIUM/LOCKED to FREE
- Remove LNURL file existence checks (lnbitSN.conf gates)
- Remove ~400 lines of payment invoice generation, QR display,
  and payment polling code

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 09:48:58 -03:00
GaltRanch
8f7ec5e6ad Remove broken ColdCore integration
ColdCore was non-functional due to literal '$HOME' paths that never
expanded, making all file checks always fail. The upstream project
(jamesob/coldcore) is experimental/alpha and requires Coldcard
hardware, limiting its audience.

Removed: callColdCore() function, menu entry "I" (ColdCore), and
handlers from PyBlock.py, SPV/spvblock.py, and umbrel-app.yml.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 09:38:15 -03:00
GaltRanch
e18c0914cd Convert remaining medium menus (5-8 items) to Rich format
PyBlock.py (10 menus):
- nostrConn: 2 columns (Console/Tools)
- APILnbit + OnchainOnly: 2 columns (Invoices/Manage)
- runTheNumbers (3 variants): Rich print with colored keys
- APILnPay + OnchainOnly: Rich print
- APIOpenNode + OnchainOnly: Rich print

SPV/spvblock.py (10 menus):
- nostrConn: 2 columns (Console/Tools)
- PhoenixConn: 2 columns (Install/Manage)
- APILnbit + OnchainOnly: 2 columns (Invoices/Manage)
- runTheNumbers (2 variants): Rich print
- APILnPay + OnchainOnly: Rich print
- APIOpenNode + OnchainOnly: Rich print

All keybindings preserved. Color menus and 2-3 item menus untouched.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 16:22:23 -03:00
GaltRanch
3062a344ec Reorganize all large menus into Rich categorized columns
Convert 7 ANSI menus to Rich Columns with colored category headers:

PyBlock.py (4 menus):
- Lightning Local (21 items): Invoices/Channels/Node/Chat
- Lightning Remote (13 items): Invoices/Channels/Node/LNBits
- API Menu (20 items): Lightning APIs/Payment/Data/Tools
- API Menu OnchainOnly (22 items): same + PhoenixD/Luxor

SPV/spvblock.py (3 menus):
- Bitcoin Core (19 items): Blockchain/Monitoring/Tools/Mining
- Lightning (20 items): Payments/Channels/Node/Tools
- API Menu (24 items): Lightning APIs/Payment/Data/Tools

Each category uses distinct colors (orange/cyan/green/yellow/magenta)
for quick visual scanning. All keybindings preserved.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 16:22:23 -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
42623cfc53 Convert download/install shell chains to list-based subprocess in SPV/spvblock.py
Replace 21 mkdir/cd/wget/tar/unzip/git-clone/chmod shell chains with
os.makedirs() + list-based subprocess.run(cwd=) calls:
- Nostr console 5 platform installers + seed/QR tools
- Mempool-cli x86/ARM installers
- CroppedMiner x86/ARM, Luxor, TinySeed
- Bija, bpytop, Cashu, ColdCore, Warden, Resurrection wallet
- Satellite and terminal_matrix git clones

Replace chmod 777 * with chmod +x on specific binaries.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 12:51:48 -03:00
GaltRanch
757b38d3de Convert curl API calls to requests library in SPV/ppi.py
Replace 30 subprocess curl API calls with native Python requests:
- LNBits: invoice create/check/pay, paywall CRUD, LNURL withdraw (11)
- OpenNode: balance, charges, withdrawals, status RSS (7)
- TallyCoin: payment requests (2)
- LNPay: invoice status and decode (2)
- Simple GETs: PGP key, bwt banner, weather, rate.sx (5+)

9 remaining shell=True are pipe chains requiring shell processing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 12:32:55 -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
935cf809de Eliminate all user-input shell injection vectors in spvblock.py
Convert every remaining subprocess call that interpolates user input
(responseC/D/E, invoice, private keys) from shell=True f-strings to
safe list-based subprocess.run() with cwd parameter:

- Miners (CroppedMiner x86/ARM): user address, password, threads
- Foreman Pickaxe: apiKey and clientId
- LND decodepayreq: invoice string (2 instances)
- TinySeed: seed words
- Nostr console (5 platform variants): private key
- Nostr seed/QR seed: hex input

Zero user-input + shell=True patterns remain in the codebase.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 12:19:36 -03:00
GaltRanch
0a70a7260a Eliminate all star imports across the entire codebase
Replace every `from X import *` with explicit named imports:
- SPV/spvblock.py: 11 star imports resolved
- SPV/ppi.py: 4 star imports resolved, duplicate import removed
- SPV/nodeconnection.py, SPV/sysinf.py, SPV/apisnd.py, SPV/donation.py
- mempoolclock.py, sysinf.py, apisnd.py, donation.py

Removed unused imports (art, nodeconnection in donation, logos in apisnd).
Zero star imports remain in the project.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 12:13:33 -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
00f39014bd Fix unclosed sockets and add __main__ guard in SHS.py
- Wrap socket operations in try/finally to ensure sock.close() on errors
- Add if __name__ == '__main__' guard to prevent execution on import
- Applied to both pybitblock/SHS.py and pybitblock/SPV/SHS.py

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 12:06:00 -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
6304b7a42a Fix shell injection vulnerabilities in spvblock.py
- Replace user input in subprocess f-strings with safe alternatives:
  - Phoenix CLI: use list-based subprocess.run() with cwd parameter
  - PhoenixD API: replace curl shell commands with requests library
  - Bitaxe API: replace curl shell commands with requests library
  - Luxor CLI: use list-based subprocess.run() with cwd parameter
- Convert Phoenix download/install from shell=True to list-based commands
- Add shlex import for safe argument splitting
- Collapse repeated input/subprocess blocks into loops

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 11:54:42 -03:00
GaltRanch
cdfb258e95 Harden file handling, exception specificity, and API key management
- Replace open() without context managers with `with` statements across all modified files
- Change bare `except:` to `except Exception:` for safer exception handling
- Move Whale Alert API key from hardcoded to environment variable
- Use raw strings for ASCII art to prevent escape sequence issues
- Simplify image file handling in nodeconnection.py
- Convert unsafe shell subprocess calls to list-based format

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 11:52:26 -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
75d0843bfb
Update labels for Bitcoin and Lightning Network 2026-03-21 04:20:00 +01:00
Satoshi Nakamoto
0ec47b8a92
Update ppi.py 2026-03-21 04:13:11 +01:00
Satoshi Nakamoto
94c91af01f
Change mining pool port from 3333 to 4444 2025-12-12 20:18:43 +01:00
Satoshi Nakamoto
3c09d96531
Change mining pool port from 3333 to 4444 2025-12-12 20:17:20 +01:00
Satoshi Nakamoto
8960931af9
Remove unused import 'jq' from spvblock.py
Removed unused import statement for 'jq'.
2025-11-28 23:54:12 +01:00
Satoshi Nakamoto
98c079e614
Update spvblock.py 2025-06-21 18:13:28 +02:00
curly60e
907a7f7b21
Update spvblock.py 2025-03-16 00:23:24 -03:00
Satoshi Nakamoto
cb42f52719
Update spvblock.py 2025-01-09 19:59:52 +01:00
Satoshi Nakamoto
460f428c91
Update spvblock.py 2025-01-09 19:57:18 +01:00
Satoshi Nakamoto
79adc7b5f7
Update spvblock.py 2025-01-09 19:24:37 +01:00
Satoshi Nakamoto
b03a44ad1d
Update spvblock.py 2025-01-08 20:07:50 +01:00
Satoshi Nakamoto
12435172ae
Update spvblock.py 2025-01-08 04:44:37 +01:00
Satoshi Nakamoto
b68b21760d
Update spvblock.py 2025-01-08 04:10:20 +01:00
Satoshi Nakamoto
a54bcbe2c4
Update spvblock.py 2024-12-27 16:36:43 +01:00
Satoshi Nakamoto
bc9cb18ee6
Update PyVanityGenerator.py 2024-10-29 01:51:14 +01:00
Satoshi Nakamoto
8ea8fba070
Update PyVanityGenerator.py 2024-10-29 00:00:32 +01:00
Satoshi Nakamoto
7c01518977
Update PyVanityGenerator.py 2024-10-28 23:54:05 +01:00
Satoshi Nakamoto
1cf08b49a4
Create PyVanityGenerator.py 2024-10-28 23:45:40 +01:00
Satoshi Nakamoto
40647fee6a
Delete pybitblock/SPV/PyVanityGen.py 2024-10-28 00:18:45 +01:00