mirror of
https://github.com/basicswap/basicswap.git
synced 2025-11-05 18:38:09 +01:00
Pass XMR restore height through json settings.
This commit is contained in:
@@ -530,6 +530,7 @@ class BasicSwap(BaseApp):
|
||||
'connection_type': connection_type,
|
||||
'bindir': bindir,
|
||||
'datadir': datadir,
|
||||
'rpchost': chain_client_settings.get('rpchost', '127.0.0.1'),
|
||||
'rpcport': chain_client_settings.get('rpcport', chainparams[coin][self.chain]['rpcport']),
|
||||
'rpcauth': rpcauth,
|
||||
'blocks_confirmed': chain_client_settings.get('blocks_confirmed', 6),
|
||||
@@ -543,6 +544,7 @@ class BasicSwap(BaseApp):
|
||||
'core_version': None,
|
||||
'explorers': [],
|
||||
'chain_lookups': chain_client_settings.get('chain_lookups', 'local'),
|
||||
'restore_height': chain_client_settings.get('restore_height', 0),
|
||||
}
|
||||
|
||||
if self.coin_clients[coin]['connection_type'] == 'rpc':
|
||||
|
||||
@@ -55,13 +55,14 @@ class XMRInterface(CoinInterface):
|
||||
|
||||
def __init__(self, coin_settings, network):
|
||||
super().__init__()
|
||||
rpc_cb = make_xmr_rpc_func(coin_settings['rpcport'])
|
||||
rpc_cb = make_xmr_rpc_func(coin_settings['rpcport'], host=coin_settings['rpchost'])
|
||||
rpc_wallet_cb = make_xmr_wallet_rpc_func(coin_settings['walletrpcport'], coin_settings['walletrpcauth'])
|
||||
|
||||
self.rpc_cb = rpc_cb
|
||||
self.rpc_wallet_cb = rpc_wallet_cb
|
||||
self._network = network
|
||||
self.blocks_confirmed = coin_settings['blocks_confirmed']
|
||||
self._restore_height = coin_settings['restore_height']
|
||||
|
||||
def setWalletFilename(self, wallet_filename):
|
||||
self._wallet_filename = wallet_filename
|
||||
@@ -74,13 +75,6 @@ class XMRInterface(CoinInterface):
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
try:
|
||||
if restore_height is None:
|
||||
restore_height = self.getChainHeight()
|
||||
except Exception as e:
|
||||
logging.warning('Unable to get restore_height, set to zero. Error: {}'.format(str(e)))
|
||||
restore_height = 0
|
||||
|
||||
Kbv = self.getPubkey(key_view)
|
||||
Kbs = self.getPubkey(key_spend)
|
||||
address_b58 = xmr_util.encode_address(Kbv, Kbs)
|
||||
@@ -90,7 +84,7 @@ class XMRInterface(CoinInterface):
|
||||
'address': address_b58,
|
||||
'viewkey': b2h(key_view[::-1]),
|
||||
'spendkey': b2h(key_spend[::-1]),
|
||||
'restore_height': restore_height,
|
||||
'restore_height': self._restore_height,
|
||||
}
|
||||
rv = self.rpc_wallet_cb('generate_from_keys', params)
|
||||
logging.info('generate_from_keys %s', dumpj(rv))
|
||||
|
||||
@@ -28,9 +28,9 @@ def callrpc_xmr(rpc_port, auth, method, params=[], path='json_rpc'):
|
||||
return r['result']
|
||||
|
||||
|
||||
def callrpc_xmr_na(rpc_port, method, params=[], path='json_rpc'):
|
||||
def callrpc_xmr_na(rpc_port, method, params=[], rpc_host='127.0.0.1', path='json_rpc'):
|
||||
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,
|
||||
@@ -65,12 +65,14 @@ def callrpc_xmr2(rpc_port, method, params=[]):
|
||||
return r
|
||||
|
||||
|
||||
def make_xmr_rpc_func(port):
|
||||
def make_xmr_rpc_func(port, host='127.0.0.1'):
|
||||
port = port
|
||||
host = host
|
||||
|
||||
def rpc_func(method, params=None, wallet=None):
|
||||
nonlocal port
|
||||
return callrpc_xmr_na(port, method, params)
|
||||
nonlocal host
|
||||
return callrpc_xmr_na(port, method, params, rpc_host=host)
|
||||
return rpc_func
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user