Add more logging to LND and Bitcoin updates

This commit is contained in:
Taylor Helsper 2022-03-20 22:22:08 -05:00
parent 2b02379ac0
commit 72b50d63fc
2 changed files with 14 additions and 3 deletions

View File

@ -72,7 +72,7 @@ def update_bitcoin_main_info():
bitcoin_blockchain_info = info bitcoin_blockchain_info = info
except Exception as e: except Exception as e:
log_message("ERROR: In update_bitcoin_info - {}".format( str(e) )) log_message("ERROR: In update_bitcoin_info - {} DATA: {}".format( str(e), str(info) ))
return False return False
update_bitcoin_json_cache() update_bitcoin_json_cache()
@ -110,6 +110,7 @@ def update_bitcoin_other_info():
bitcoin_recent_blocks_last_cache_height = mynode_block_height bitcoin_recent_blocks_last_cache_height = mynode_block_height
# Get peers and cleanup data # Get peers and cleanup data
log_message("update_bitcoin_other_info - PEERS")
peerdata = rpc_connection.getpeerinfo() peerdata = rpc_connection.getpeerinfo()
peers = [] peers = []
if peerdata != None: if peerdata != None:
@ -127,6 +128,7 @@ def update_bitcoin_other_info():
bitcoin_peers = peers bitcoin_peers = peers
# Get network info # Get network info
log_message("update_bitcoin_other_info - NETWORK")
network_data = rpc_connection.getnetworkinfo() network_data = rpc_connection.getnetworkinfo()
if network_data != None: if network_data != None:
network_data["relayfee"] = str(network_data["relayfee"]) network_data["relayfee"] = str(network_data["relayfee"])
@ -134,6 +136,7 @@ def update_bitcoin_other_info():
bitcoin_network_info = network_data bitcoin_network_info = network_data
# Get mempool # Get mempool
log_message("update_bitcoin_other_info - MEMPOOL")
mempool_data = rpc_connection.getmempoolinfo() mempool_data = rpc_connection.getmempoolinfo()
if mempool_data != None: if mempool_data != None:
mempool_data["total_fee"] = str(mempool_data["total_fee"]) mempool_data["total_fee"] = str(mempool_data["total_fee"])
@ -142,6 +145,7 @@ def update_bitcoin_other_info():
bitcoin_mempool = mempool_data bitcoin_mempool = mempool_data
# Get wallet info # Get wallet info
log_message("update_bitcoin_other_info - WALLETS")
wallets = rpc_connection.listwallets() wallets = rpc_connection.listwallets()
wallet_data = [] wallet_data = []
for w in wallets: for w in wallets:
@ -157,6 +161,7 @@ def update_bitcoin_other_info():
bitcoin_wallets = wallet_data bitcoin_wallets = wallet_data
# Get recommended fee info (from mempool on port 4080) # Get recommended fee info (from mempool on port 4080)
log_message("update_bitcoin_other_info - MEMPOOL")
if is_service_enabled("mempool"): if is_service_enabled("mempool"):
try: try:
r = requests.get("http://localhost:4080/api/v1/fees/recommended", timeout=1) r = requests.get("http://localhost:4080/api/v1/fees/recommended", timeout=1)
@ -172,10 +177,10 @@ def update_bitcoin_other_info():
else: else:
bitcoin_recommended_fees = None bitcoin_recommended_fees = None
except Exception as e1: except Exception as e1:
log_message("ERROR: In update_bitcoin_other_info - {}".format( str(e1) )) log_message("ERROR: In update_bitcoin_other_info (1) - {} DATA: {}".format( str(e1), str() ))
except Exception as e2: except Exception as e2:
log_message("ERROR: In update_bitcoin_other_info - {}".format( str(e2) )) log_message("ERROR: In update_bitcoin_other_info (2) - {} DATA: {}".format( str(e2), str() ))
return False return False
update_bitcoin_json_cache() update_bitcoin_json_cache()

View File

@ -99,16 +99,20 @@ def update_lightning_info():
return True return True
if lnd_ready: if lnd_ready:
log_message("update_lightning_info - LND READY")
if lightning_desync_count > 0: if lightning_desync_count > 0:
os.system("printf \"%s | De-sync greater than 0 (was {}), but now synced! Setting to 0. \\n\" \"$(date)\" >> /tmp/lnd_failures".format(lightning_desync_count)) os.system("printf \"%s | De-sync greater than 0 (was {}), but now synced! Setting to 0. \\n\" \"$(date)\" >> /tmp/lnd_failures".format(lightning_desync_count))
lightning_desync_count = 0 lightning_desync_count = 0
log_message("update_lightning_info - GET PEERS, CHANNELS, BALANCE, WALLET")
lightning_peers = lnd_get("/peers") lightning_peers = lnd_get("/peers")
lightning_channels = lnd_get("/channels") lightning_channels = lnd_get("/channels")
lightning_channel_balance = lnd_get("/balance/channels") lightning_channel_balance = lnd_get("/balance/channels")
lightning_wallet_balance = lnd_get("/balance/blockchain") lightning_wallet_balance = lnd_get("/balance/blockchain")
log_message("update_lightning_info - GET WATCHTOWER")
if is_watchtower_enabled(): if is_watchtower_enabled():
lightning_watchtower_server_info = lnd_get_v2("/watchtower/server") lightning_watchtower_server_info = lnd_get_v2("/watchtower/server")
towers = lnd_get_v2("/watchtower/client?include_sessions=1") towers = lnd_get_v2("/watchtower/client?include_sessions=1")
log_message("update_lightning_info - TOWER DETAILS")
tower_details = [] tower_details = []
if towers != None and "towers" in towers: if towers != None and "towers" in towers:
for tower in towers["towers"]: for tower in towers["towers"]:
@ -118,11 +122,13 @@ def update_lightning_info():
tower["pubkey_b16"] = pubkey_b16 tower["pubkey_b16"] = pubkey_b16
tower_details.append(tower) tower_details.append(tower)
lightning_watchtower_client_towers = tower_details lightning_watchtower_client_towers = tower_details
log_message("update_lightning_info - GET CLIENT STATS, POLICY")
lightning_watchtower_client_stats = lnd_get_v2("/watchtower/client/stats") lightning_watchtower_client_stats = lnd_get_v2("/watchtower/client/stats")
lightning_watchtower_client_policy = lnd_get_v2("/watchtower/client/policy") lightning_watchtower_client_policy = lnd_get_v2("/watchtower/client/policy")
# Poll slower (make sure we gather data early) # Poll slower (make sure we gather data early)
if lightning_update_count < 30 or lightning_update_count % 2 == 0: if lightning_update_count < 30 or lightning_update_count % 2 == 0:
log_message("update_lightning_info - GET TX INFO")
update_lightning_tx_info() update_lightning_tx_info()
update_lightning_json_cache() update_lightning_json_cache()