Exemple #1
0
    def get_network_type(cls):
        """Returns the WAZN network type the faucet is running on.

        :returns: network type (stagenet, testnet)
        :raises RpcConnectionError: no connection could be established
        :raises ValueError: retrieved data could not be processed
        """
        if not cls.network_type:
            rpc_connection = AuthServiceProxy("http://{0}:{1}/json_rpc".format(
                settings.DAEMON_HOST, settings.DAEMON_PORT))

            result = None
            try:
                result = rpc_connection.get_info()
            except (
                    requests.HTTPError,
                    requests.ConnectionError,
                    JSONRPCException,
            ) as e:
                logger.error("RPC Error on getting address" + str(e))
                logger.exception(e)
                raise RpcConnectionError(str(e))
            # Check network type
            network_type = result.get("nettype", None)
            if not network_type:
                raise ValueError("Error with: {0}".format(result))
            cls.network_type = network_type
        return cls.network_type
from monerorpc.authproxy import AuthServiceProxy, JSONRPCException
import logging

logging.basicConfig()
logging.getLogger("MoneroRPC").setLevel(logging.DEBUG)
log = logging.getLogger("wallet-rpc-lib")

rpc = AuthServiceProxy('http://*****:*****@127.0.0.1:18081/json_rpc')
#rpc = AuthServiceProxy('http://127.0.0.1:18081/json_rpc')
try:
    rpc.get_info()
except (JSONRPCException) as e:
    log.error(e)