From f410d08bbadde5b32c59992e4314b334e37a3d9c Mon Sep 17 00:00:00 2001 From: WakiyamaP Date: Mon, 25 Sep 2023 00:58:26 +0900 Subject: [PATCH] Use getbestblockhash --- UTXOracle.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/UTXOracle.py b/UTXOracle.py index 2421743..9afff13 100644 --- a/UTXOracle.py +++ b/UTXOracle.py @@ -132,16 +132,15 @@ def Ask_Node(command): # header, so we ask for the header only when we just need to know the time. -#get current block height from local node and exit if connection not made -block_count_b = Ask_Node(['getblockcount']) -block_count = int(block_count_b) #convert text to integer - #get block header from current block height -block_hash_b = Ask_Node(['getblockhash',block_count_b]) +block_hash_b = Ask_Node(['getbestblockhash']) block_header_b = Ask_Node(['getblockheader',block_hash_b[:64],'true']) import json #a built in tool for deciphering lists of embedded lists block_header = json.loads(block_header_b) +#get current block height +block_count = block_header['height'] + #get the date and time of the current block height from datetime import datetime, timezone #built in tools for dates/times latest_time_in_seconds = block_header['time'] @@ -741,4 +740,4 @@ def Ask_Node(command): - \ No newline at end of file +