|
|
@ -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 |
|
|
|