mirror of
https://github.com/aljazceru/python-teos.git
synced 2026-01-26 09:44:21 +01:00
Adds sanity checks to make sure pisad and bitcoind are configured in the same way
This commit is contained in:
@@ -25,3 +25,32 @@ def check_tx_in_chain(bitcoin_cli, tx_id, debug, logging, parent='', tx_label='t
|
||||
logging.error("[{}] JSONRPCException. Error code {}".format(parent, e))
|
||||
|
||||
return tx_in_chain, confirmations
|
||||
|
||||
|
||||
def can_connect_to_bitcoind(bitcoin_cli):
|
||||
can_connect = True
|
||||
|
||||
try:
|
||||
bitcoin_cli.help()
|
||||
except ConnectionRefusedError:
|
||||
can_connect = False
|
||||
|
||||
return can_connect
|
||||
|
||||
|
||||
def in_correct_network(bitcoin_cli, network):
|
||||
mainnet_genesis_block_hash = "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"
|
||||
testnet3_genesis_block_hash = "000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943"
|
||||
correct_network = False
|
||||
|
||||
genesis_block_hash = bitcoin_cli.getblockhash(0)
|
||||
|
||||
if network == 'mainnet' and genesis_block_hash == mainnet_genesis_block_hash:
|
||||
correct_network = True
|
||||
elif network == 'testnet' and genesis_block_hash == testnet3_genesis_block_hash:
|
||||
correct_network = True
|
||||
elif network == 'regtest' and genesis_block_hash not in [mainnet_genesis_block_hash, testnet3_genesis_block_hash]:
|
||||
correct_network = True
|
||||
|
||||
return correct_network
|
||||
|
||||
|
||||
Reference in New Issue
Block a user