diff --git a/pybitblock/PyBlock.py b/pybitblock/PyBlock.py index 85d3d7f..302c9bb 100644 --- a/pybitblock/PyBlock.py +++ b/pybitblock/PyBlock.py @@ -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 diff --git a/pybitblock/SPV/spvblock.py b/pybitblock/SPV/spvblock.py index f6ffce5..a53a881 100644 --- a/pybitblock/SPV/spvblock.py +++ b/pybitblock/SPV/spvblock.py @@ -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