mirror of
https://github.com/curly60e/pyblock.git
synced 2026-08-13 12:33:15 +02:00
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>
This commit is contained in:
parent
04c0e33efc
commit
458b60fbbc
2 changed files with 20 additions and 1 deletions
|
|
@ -67,6 +67,7 @@ from menu import select_color
|
|||
from log import get_logger
|
||||
from shared.display import clear, close, sysinfo, rectangle, delay_print
|
||||
from shared.formatting import get_ansi_color_code, get_color
|
||||
from shared.ui import status_bar, show_error, loading
|
||||
logger = get_logger("PyBlock")
|
||||
|
||||
|
||||
|
|
@ -1807,10 +1808,18 @@ def MainMenu(mode): #Unified Main Menu - mode: "local", "onchain_only", or "remo
|
|||
sysinfo()
|
||||
pathexec()
|
||||
|
||||
# Fetch BTC price for status bar
|
||||
try:
|
||||
_price_r = requests.get("https://mempool.space/api/v1/prices", timeout=3)
|
||||
_btc_price = f"{_price_r.json().get('USD', ''):,}"
|
||||
except Exception:
|
||||
_btc_price = ""
|
||||
|
||||
if mode == "remote":
|
||||
lndconnectexec()
|
||||
path_remote = {"ip_port":"", "rpcuser":"", "rpcpass":"", "bitcoincli":""}
|
||||
pathv = json.load(open("config/bclock.conf", "r"))
|
||||
with open("config/bclock.conf", "r") as f:
|
||||
pathv = json.load(f)
|
||||
path_remote = pathv
|
||||
n = "Local" if path_remote['bitcoincli'] else "Remote"
|
||||
blk = rpc('getblockchaininfo')
|
||||
|
|
@ -1842,6 +1851,9 @@ def MainMenu(mode): #Unified Main Menu - mode: "local", "onchain_only", or "remo
|
|||
d = b
|
||||
alias = None
|
||||
|
||||
# Status bar
|
||||
status_bar(mode=mode, block_height=str(d.get('blocks', '')), btc_price=_btc_price)
|
||||
|
||||
# Build header
|
||||
if alias is not None:
|
||||
header = """\t\t
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ from config import cfg
|
|||
from log import get_logger
|
||||
from shared.display import clear, close, sysinfo, rectangle, delay_print
|
||||
from shared.formatting import get_ansi_color_code, get_color
|
||||
from shared.ui import status_bar, show_error, loading
|
||||
logger = get_logger("SPV")
|
||||
|
||||
|
||||
|
|
@ -4470,6 +4471,12 @@ def MainMenuCROPPED(): #Main Menu
|
|||
di = json.loads(nn)
|
||||
a = di
|
||||
b = str(a)
|
||||
try:
|
||||
_price_r = requests.get("https://mempool.space/api/v1/prices", timeout=3)
|
||||
_btc_price = f"{_price_r.json().get('USD', ''):,}"
|
||||
except Exception:
|
||||
_btc_price = ""
|
||||
status_bar(mode="lite", block_height=b, btc_price=_btc_price)
|
||||
print("""\t\t
|
||||
\033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m
|
||||
\033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m\a
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue