Note source of XMR rpc error messages.
This commit is contained in:
parent
7c0ea36e37
commit
3b6f72c084
@ -114,9 +114,9 @@ class XMRInterface(CoinInterface):
|
|||||||
self._walletrpctimeout = coin_settings.get('walletrpctimeout', 120)
|
self._walletrpctimeout = coin_settings.get('walletrpctimeout', 120)
|
||||||
self._walletrpctimeoutlong = coin_settings.get('walletrpctimeoutlong', 600)
|
self._walletrpctimeoutlong = coin_settings.get('walletrpctimeoutlong', 600)
|
||||||
|
|
||||||
self.rpc = make_xmr_rpc_func(coin_settings['rpcport'], daemon_login, host=rpchost, proxy_host=proxy_host, proxy_port=proxy_port, default_timeout=self._rpctimeout)
|
self.rpc = make_xmr_rpc_func(coin_settings['rpcport'], daemon_login, host=rpchost, proxy_host=proxy_host, proxy_port=proxy_port, default_timeout=self._rpctimeout, tag='Node(j) ')
|
||||||
self.rpc2 = make_xmr_rpc2_func(coin_settings['rpcport'], daemon_login, host=rpchost, proxy_host=proxy_host, proxy_port=proxy_port, default_timeout=self._rpctimeout) # non-json endpoint
|
self.rpc2 = make_xmr_rpc2_func(coin_settings['rpcport'], daemon_login, host=rpchost, proxy_host=proxy_host, proxy_port=proxy_port, default_timeout=self._rpctimeout, tag='Node ') # non-json endpoint
|
||||||
self.rpc_wallet = make_xmr_rpc_func(coin_settings['walletrpcport'], coin_settings['walletrpcauth'], host=coin_settings.get('walletrpchost', '127.0.0.1'), default_timeout=self._walletrpctimeout)
|
self.rpc_wallet = make_xmr_rpc_func(coin_settings['walletrpcport'], coin_settings['walletrpcauth'], host=coin_settings.get('walletrpchost', '127.0.0.1'), default_timeout=self._walletrpctimeout, tag='Wallet ')
|
||||||
|
|
||||||
def checkWallets(self) -> int:
|
def checkWallets(self) -> int:
|
||||||
return 1
|
return 1
|
||||||
|
@ -172,7 +172,7 @@ class JsonrpcDigest():
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
def callrpc_xmr(rpc_port, method, params=[], rpc_host='127.0.0.1', path='json_rpc', auth=None, timeout=120, transport=None):
|
def callrpc_xmr(rpc_port, method, params=[], rpc_host='127.0.0.1', path='json_rpc', auth=None, timeout=120, transport=None, tag=''):
|
||||||
# auth is a tuple: (username, password)
|
# auth is a tuple: (username, password)
|
||||||
try:
|
try:
|
||||||
if rpc_host.count('://') > 0:
|
if rpc_host.count('://') > 0:
|
||||||
@ -194,15 +194,15 @@ def callrpc_xmr(rpc_port, method, params=[], rpc_host='127.0.0.1', path='json_rp
|
|||||||
x.close()
|
x.close()
|
||||||
r = json.loads(v.decode('utf-8'))
|
r = json.loads(v.decode('utf-8'))
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
raise ValueError('RPC Server Error: {}'.format(str(ex)))
|
raise ValueError('{}RPC Server Error: {}'.format(tag, str(ex)))
|
||||||
|
|
||||||
if 'error' in r and r['error'] is not None:
|
if 'error' in r and r['error'] is not None:
|
||||||
raise ValueError('RPC error ' + str(r['error']))
|
raise ValueError(tag + 'RPC error ' + str(r['error']))
|
||||||
|
|
||||||
return r['result']
|
return r['result']
|
||||||
|
|
||||||
|
|
||||||
def callrpc_xmr2(rpc_port: int, method: str, params=None, auth=None, rpc_host='127.0.0.1', timeout=120, transport=None):
|
def callrpc_xmr2(rpc_port: int, method: str, params=None, auth=None, rpc_host='127.0.0.1', timeout=120, transport=None, tag=''):
|
||||||
try:
|
try:
|
||||||
if rpc_host.count('://') > 0:
|
if rpc_host.count('://') > 0:
|
||||||
url = '{}:{}/{}'.format(rpc_host, rpc_port, method)
|
url = '{}:{}/{}'.format(rpc_host, rpc_port, method)
|
||||||
@ -217,40 +217,42 @@ def callrpc_xmr2(rpc_port: int, method: str, params=None, auth=None, rpc_host='1
|
|||||||
x.close()
|
x.close()
|
||||||
r = json.loads(v.decode('utf-8'))
|
r = json.loads(v.decode('utf-8'))
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
raise ValueError('RPC Server Error: {}'.format(str(ex)))
|
raise ValueError('{}RPC Server Error: {}'.format(tag, str(ex)))
|
||||||
|
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
|
||||||
def make_xmr_rpc2_func(port, auth, host='127.0.0.1', proxy_host=None, proxy_port=None, default_timeout=120):
|
def make_xmr_rpc2_func(port, auth, host='127.0.0.1', proxy_host=None, proxy_port=None, default_timeout=120, tag=''):
|
||||||
port = port
|
port = port
|
||||||
auth = auth
|
auth = auth
|
||||||
host = host
|
host = host
|
||||||
transport = None
|
transport = None
|
||||||
default_timeout = default_timeout
|
default_timeout = default_timeout
|
||||||
|
tag = tag
|
||||||
|
|
||||||
if proxy_host:
|
if proxy_host:
|
||||||
transport = SocksTransport()
|
transport = SocksTransport()
|
||||||
transport.set_proxy(proxy_host, proxy_port)
|
transport.set_proxy(proxy_host, proxy_port)
|
||||||
|
|
||||||
def rpc_func(method, params=None, wallet=None, timeout=default_timeout):
|
def rpc_func(method, params=None, wallet=None, timeout=default_timeout):
|
||||||
nonlocal port, auth, host, transport
|
nonlocal port, auth, host, transport, tag
|
||||||
return callrpc_xmr2(port, method, params, auth=auth, rpc_host=host, timeout=timeout, transport=transport)
|
return callrpc_xmr2(port, method, params, auth=auth, rpc_host=host, timeout=timeout, transport=transport, tag=tag)
|
||||||
return rpc_func
|
return rpc_func
|
||||||
|
|
||||||
|
|
||||||
def make_xmr_rpc_func(port, auth, host='127.0.0.1', proxy_host=None, proxy_port=None, default_timeout=120):
|
def make_xmr_rpc_func(port, auth, host='127.0.0.1', proxy_host=None, proxy_port=None, default_timeout=120, tag=''):
|
||||||
port = port
|
port = port
|
||||||
auth = auth
|
auth = auth
|
||||||
host = host
|
host = host
|
||||||
transport = None
|
transport = None
|
||||||
default_timeout = default_timeout
|
default_timeout = default_timeout
|
||||||
|
tag = tag
|
||||||
|
|
||||||
if proxy_host:
|
if proxy_host:
|
||||||
transport = SocksTransport()
|
transport = SocksTransport()
|
||||||
transport.set_proxy(proxy_host, proxy_port)
|
transport.set_proxy(proxy_host, proxy_port)
|
||||||
|
|
||||||
def rpc_func(method, params=None, wallet=None, timeout=default_timeout):
|
def rpc_func(method, params=None, wallet=None, timeout=default_timeout):
|
||||||
nonlocal port, auth, host, transport
|
nonlocal port, auth, host, transport, tag
|
||||||
return callrpc_xmr(port, method, params, rpc_host=host, auth=auth, timeout=timeout, transport=transport)
|
return callrpc_xmr(port, method, params, rpc_host=host, auth=auth, timeout=timeout, transport=transport, tag=tag)
|
||||||
return rpc_func
|
return rpc_func
|
||||||
|
Loading…
Reference in New Issue
Block a user