tools docstrings

This commit is contained in:
Sergi Delgado Segura
2019-12-11 13:12:37 +01:00
parent 2eafb644c3
commit b53627aa6d

View File

@@ -1,12 +1,23 @@
import re
from http.client import HTTPException
import pisa.conf as conf
from pisa.utils.auth_proxy import AuthServiceProxy, JSONRPCException
"""
Tools is a module with general methods that can used by different entities in the codebase.
"""
# NOTCOVERED
def bitcoin_cli():
"""
An ``http`` connection with ``bitcoind`` using the ``json-rpc`` interface.
Returns:
``AuthServiceProxy``: An authenticated service proxy to ``bitcoind`` that can be used to send ``json-rpc``
commands.
"""
return AuthServiceProxy(
"http://%s:%s@%s:%d" % (conf.BTC_RPC_USER, conf.BTC_RPC_PASSWD, conf.BTC_RPC_HOST, conf.BTC_RPC_PORT)
)
@@ -14,6 +25,13 @@ def bitcoin_cli():
# NOTCOVERED
def can_connect_to_bitcoind():
"""
Checks if the tower has connection to ``bitcoind``.
Returns:
``bool``: ``True`` if the connection can be established. ``False`` otherwise.
"""
can_connect = True
try:
@@ -25,6 +43,14 @@ def can_connect_to_bitcoind():
def in_correct_network(network):
"""
Checks if ``bitcoind`` and the tower are configured to run in the same network (``mainnet``, ``testnet`` or
``regtest``)
Returns:
``bool``: ``True`` if the network configuration matches. ``False`` otherwise.
"""
mainnet_genesis_block_hash = "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"
testnet3_genesis_block_hash = "000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943"
correct_network = False