Start isolated docker setup.

This commit is contained in:
tecnovert
2020-12-27 21:39:10 +02:00
parent a6ead83fd2
commit d2ded157f8
20 changed files with 332 additions and 42 deletions

View File

@@ -576,6 +576,7 @@ class BasicSwap(BaseApp):
if self.coin_clients[coin]['connection_type'] == 'rpc':
if coin == Coins.XMR:
self.coin_clients[coin]['walletrpchost'] = chain_client_settings.get('walletrpchost', 'localhost')
self.coin_clients[coin]['walletrpcport'] = chain_client_settings.get('walletrpcport', chainparams[coin][self.chain]['walletrpcport'])
if 'walletrpcpassword' in chain_client_settings:
self.coin_clients[coin]['walletrpcauth'] = (chain_client_settings['walletrpcuser'], chain_client_settings['walletrpcpassword'])

View File

@@ -113,7 +113,7 @@ class BTCInterface(CoinInterface):
def __init__(self, coin_settings, network):
super().__init__()
self.rpc_callback = make_rpc_func(coin_settings['rpcport'], coin_settings['rpcauth'])
self.rpc_callback = make_rpc_func(coin_settings['rpcport'], coin_settings['rpcauth'], host=coin_settings['rpchost'])
self.txoType = CTxOut
self._network = network
self.blocks_confirmed = coin_settings['blocks_confirmed']

View File

@@ -32,7 +32,7 @@ class PARTInterface(BTCInterface):
return 0xa0
def __init__(self, coin_settings, network):
self.rpc_callback = make_rpc_func(coin_settings['rpcport'], coin_settings['rpcauth'])
self.rpc_callback = make_rpc_func(coin_settings['rpcport'], coin_settings['rpcauth'], host=coin_settings['rpchost'])
self.txoType = CTxOutPart
self._network = network
self.blocks_confirmed = coin_settings['blocks_confirmed']

View File

@@ -91,9 +91,9 @@ class Jsonrpc():
raise
def callrpc(rpc_port, auth, method, params=[], wallet=None):
def callrpc(rpc_port, auth, method, params=[], wallet=None, host='127.0.0.1'):
try:
url = 'http://%s@127.0.0.1:%d/' % (auth, rpc_port)
url = 'http://{}@{}:{}/'.format(auth, host, rpc_port)
if wallet is not None:
url += 'wallet/' + urllib.parse.quote(wallet)
x = Jsonrpc(url)
@@ -129,12 +129,13 @@ def callrpc_cli(bindir, datadir, chain, cmd, cli_bin='particl-cli'):
return r
def make_rpc_func(port, auth, wallet=None):
def make_rpc_func(port, auth, wallet=None, host='127.0.0.1'):
port = port
auth = auth
wallet = wallet
host = host
def rpc_func(method, params=None, wallet_override=None):
nonlocal port, auth, wallet
return callrpc(port, auth, method, params, wallet if wallet_override is None else wallet_override)
nonlocal port, auth, wallet, host
return callrpc(port, auth, method, params, wallet if wallet_override is None else wallet_override, host)
return rpc_func

View File

@@ -4,10 +4,10 @@ import json
import requests
def callrpc_xmr(rpc_port, auth, method, params=[], path='json_rpc'):
def callrpc_xmr(rpc_port, auth, method, params=[], rpc_host='127.0.0.1', path='json_rpc'):
# auth is a tuple: (username, password)
try:
url = 'http://127.0.0.1:{}/{}'.format(rpc_port, path)
url = 'http://{}:{}/{}'.format(rpc_host, rpc_port, path)
request_body = {
'method': method,
'params': params,
@@ -51,20 +51,6 @@ def callrpc_xmr_na(rpc_port, method, params=[], rpc_host='127.0.0.1', path='json
return r['result']
def callrpc_xmr2(rpc_port, method, params=[]):
try:
url = 'http://127.0.0.1:{}/{}'.format(rpc_port, method)
headers = {
'content-type': 'application/json'
}
p = requests.post(url, data=json.dumps(params), headers=headers)
r = json.loads(p.text)
except Exception as ex:
raise ValueError('RPC Server Error: {}'.format(str(ex)))
return r
def make_xmr_rpc_func(port, host='127.0.0.1'):
port = port
host = host
@@ -76,11 +62,12 @@ def make_xmr_rpc_func(port, host='127.0.0.1'):
return rpc_func
def make_xmr_wallet_rpc_func(port, auth):
def make_xmr_wallet_rpc_func(port, auth, host='127.0.0.1'):
port = port
auth = auth
host = host
def rpc_func(method, params=None, wallet=None):
nonlocal port, auth
return callrpc_xmr(port, auth, method, params)
nonlocal port, auth, host
return callrpc_xmr(port, auth, method, params, rpc_host=host)
return rpc_func