|
|
|
@ -172,7 +172,7 @@ class JsonrpcDigest(): |
|
|
|
|
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) |
|
|
|
|
try: |
|
|
|
|
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() |
|
|
|
|
r = json.loads(v.decode('utf-8')) |
|
|
|
|
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: |
|
|
|
|
raise ValueError('RPC error ' + str(r['error'])) |
|
|
|
|
raise ValueError(tag + 'RPC error ' + str(r['error'])) |
|
|
|
|
|
|
|
|
|
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: |
|
|
|
|
if rpc_host.count('://') > 0: |
|
|
|
|
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() |
|
|
|
|
r = json.loads(v.decode('utf-8')) |
|
|
|
|
except Exception as ex: |
|
|
|
|
raise ValueError('RPC Server Error: {}'.format(str(ex))) |
|
|
|
|
raise ValueError('{}RPC Server Error: {}'.format(tag, str(ex))) |
|
|
|
|
|
|
|
|
|
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 |
|
|
|
|
auth = auth |
|
|
|
|
host = host |
|
|
|
|
transport = None |
|
|
|
|
default_timeout = default_timeout |
|
|
|
|
tag = tag |
|
|
|
|
|
|
|
|
|
if proxy_host: |
|
|
|
|
transport = SocksTransport() |
|
|
|
|
transport.set_proxy(proxy_host, proxy_port) |
|
|
|
|
|
|
|
|
|
def rpc_func(method, params=None, wallet=None, timeout=default_timeout): |
|
|
|
|
nonlocal port, auth, host, transport |
|
|
|
|
return callrpc_xmr2(port, method, params, auth=auth, rpc_host=host, timeout=timeout, transport=transport) |
|
|
|
|
nonlocal port, auth, host, transport, tag |
|
|
|
|
return callrpc_xmr2(port, method, params, auth=auth, rpc_host=host, timeout=timeout, transport=transport, tag=tag) |
|
|
|
|
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 |
|
|
|
|
auth = auth |
|
|
|
|
host = host |
|
|
|
|
transport = None |
|
|
|
|
default_timeout = default_timeout |
|
|
|
|
tag = tag |
|
|
|
|
|
|
|
|
|
if proxy_host: |
|
|
|
|
transport = SocksTransport() |
|
|
|
|
transport.set_proxy(proxy_host, proxy_port) |
|
|
|
|
|
|
|
|
|
def rpc_func(method, params=None, wallet=None, timeout=default_timeout): |
|
|
|
|
nonlocal port, auth, host, transport |
|
|
|
|
return callrpc_xmr(port, method, params, rpc_host=host, auth=auth, timeout=timeout, transport=transport) |
|
|
|
|
nonlocal port, auth, host, transport, tag |
|
|
|
|
return callrpc_xmr(port, method, params, rpc_host=host, auth=auth, timeout=timeout, transport=transport, tag=tag) |
|
|
|
|
return rpc_func |
|
|
|
|