Set bootstrap-daemon-address to auto

get_block_count returns "Internal error" if bootstrap-daemon is active
Use get_height instead.
2024-05-20_merge
tecnovert 4 years ago
parent 755583fd1d
commit 2049fcef3d
No known key found for this signature in database
GPG Key ID: 8ED6D8750C4E3F93
  1. 24
      basicswap/interface_xmr.py
  2. 28
      basicswap/rpc_xmr.py
  3. 2
      basicswap/templates/wallets.html
  4. 2
      bin/basicswap_prepare.py
  5. 3
      doc/install.md

@ -25,6 +25,7 @@ from .util import (
format_amount) format_amount)
from .rpc_xmr import ( from .rpc_xmr import (
make_xmr_rpc_func, make_xmr_rpc_func,
make_xmr_rpc2_func,
make_xmr_wallet_rpc_func) make_xmr_wallet_rpc_func)
from .ecc_util import ( from .ecc_util import (
b2i, i2b, b2h) b2i, i2b, b2h)
@ -56,11 +57,10 @@ class XMRInterface(CoinInterface):
def __init__(self, coin_settings, network): def __init__(self, coin_settings, network):
super().__init__() super().__init__()
rpc_cb = make_xmr_rpc_func(coin_settings['rpcport'], host=coin_settings.get('rpchost', 'localhost')) self.rpc_cb = make_xmr_rpc_func(coin_settings['rpcport'], host=coin_settings.get('rpchost', 'localhost'))
rpc_wallet_cb = make_xmr_wallet_rpc_func(coin_settings['walletrpcport'], coin_settings['walletrpcauth']) self.rpc_cb2 = make_xmr_rpc2_func(coin_settings['rpcport'], host=coin_settings.get('rpchost', 'localhost')) # non-json endpoint
self.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._network = network
self.blocks_confirmed = coin_settings['blocks_confirmed'] self.blocks_confirmed = coin_settings['blocks_confirmed']
self._restore_height = coin_settings.get('restore_height', 0) self._restore_height = coin_settings.get('restore_height', 0)
@ -107,12 +107,18 @@ class XMRInterface(CoinInterface):
def getBlockchainInfo(self): def getBlockchainInfo(self):
rv = {} rv = {}
rv['blocks'] = self.rpc_cb('get_block_count')['count']
# get_block_count returns "Internal error" if bootstrap-daemon is active
# rv['blocks'] = self.rpc_cb('get_block_count')['count']
rv['blocks'] = self.rpc_cb2('get_height')['height']
rv['verificationprogress'] = 0 # TODO rv['verificationprogress'] = 0 # TODO
return rv return rv
def getChainHeight(self): def getChainHeight(self):
return self.rpc_cb('get_block_count')['count'] # get_block_count returns "Internal error" if bootstrap-daemon is active
# return self.rpc_cb('get_info')['height']
# return self.rpc_cb('get_block_count')['count']
return self.rpc_cb2('get_height')['height']
def getWalletInfo(self): def getWalletInfo(self):
self.rpc_wallet_cb('open_wallet', {'filename': self._wallet_filename}) self.rpc_wallet_cb('open_wallet', {'filename': self._wallet_filename})
@ -243,7 +249,7 @@ class XMRInterface(CoinInterface):
''' '''
# Debug # Debug
try: try:
current_height = self.rpc_wallet_cb('get_block_count')['count'] current_height = self.rpc_wallet_cb('get_height')['height']
logging.info('findTxB XMR current_height %d\nAddress: %s', current_height, address_b58) logging.info('findTxB XMR current_height %d\nAddress: %s', current_height, address_b58)
except Exception as e: except Exception as e:
logging.info('rpc_cb failed %s', str(e)) logging.info('rpc_cb failed %s', str(e))
@ -285,7 +291,7 @@ class XMRInterface(CoinInterface):
num_tries = 40 num_tries = 40
for i in range(num_tries + 1): for i in range(num_tries + 1):
try: try:
current_height = self.rpc_cb('get_block_count')['count'] current_height = self.rpc_cb2('get_height')['height']
print('current_height', current_height) print('current_height', current_height)
except Exception as e: except Exception as e:
logging.warning('rpc_cb failed %s', str(e)) logging.warning('rpc_cb failed %s', str(e))
@ -327,7 +333,7 @@ class XMRInterface(CoinInterface):
self.rpc_wallet_cb('refresh') self.rpc_wallet_cb('refresh')
try: try:
current_height = self.rpc_cb('get_block_count')['count'] current_height = self.rpc_cb2('get_height')['height']
logging.info('findTxnByHash XMR current_height %d\nhash: %s', current_height, txid) logging.info('findTxnByHash XMR current_height %d\nhash: %s', current_height, txid)
except Exception as e: except Exception as e:
logging.info('rpc_cb failed %s', str(e)) logging.info('rpc_cb failed %s', str(e))

@ -51,6 +51,23 @@ def callrpc_xmr_na(rpc_port, method, params=[], rpc_host='127.0.0.1', path='json
return r['result'] return r['result']
def callrpc_xmr2(rpc_port, method, params=None, rpc_host='127.0.0.1'):
try:
url = 'http://{}:{}/{}'.format(rpc_host, rpc_port, method)
headers = {
'content-type': 'application/json'
}
if params is None:
p = requests.post(url, headers=headers)
else:
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'): def make_xmr_rpc_func(port, host='127.0.0.1'):
port = port port = port
host = host host = host
@ -62,6 +79,17 @@ def make_xmr_rpc_func(port, host='127.0.0.1'):
return rpc_func return rpc_func
def make_xmr_rpc2_func(port, host='127.0.0.1'):
port = port
host = host
def rpc_func(method, params=None, wallet=None):
nonlocal port
nonlocal host
return callrpc_xmr2(port, method, params, rpc_host=host)
return rpc_func
def make_xmr_wallet_rpc_func(port, auth, host='127.0.0.1'): def make_xmr_wallet_rpc_func(port, auth, host='127.0.0.1'):
port = port port = port
auth = auth auth = auth

@ -21,7 +21,7 @@
<tr><td>Blocks:</td><td>{{ w.blocks }}</td></tr> <tr><td>Blocks:</td><td>{{ w.blocks }}</td></tr>
<tr><td>Synced:</td><td>{{ w.synced }}</td></tr> <tr><td>Synced:</td><td>{{ w.synced }}</td></tr>
<tr><td>Expected Seed:</td><td>{{ w.expected_seed }}</td>{% if w.expected_seed != true %}<td><input type="submit" name="reseed_{{ w.cid }}" value="Reseed wallet" onclick="confirmReseed()"></td>{% endif %}</tr> <tr><td>Expected Seed:</td><td>{{ w.expected_seed }}</td>{% if w.expected_seed != true %}<td><input type="submit" name="reseed_{{ w.cid }}" value="Reseed wallet" onclick="confirmReseed()"></td>{% endif %}</tr>
<tr><td><input type="submit" name="newaddr_{{ w.cid }}" value="Deposit Address"></td><td>{{ w.deposit_address }}</td></tr> <tr><td><input type="submit" name="newaddr_{{ w.cid }}" value="Deposit Address"></td><td colspan=2>{{ w.deposit_address }}</td></tr>
<tr><td><input type="submit" name="withdraw_{{ w.cid }}" value="Withdraw"></td><td>Amount: <input type="text" name="amt_{{ w.cid }}"></td><td>Address: <input type="text" name="to_{{ w.cid }}"></td><td>Subtract fee: <input type="checkbox" name="subfee_{{ w.cid }}"></td></tr> <tr><td><input type="submit" name="withdraw_{{ w.cid }}" value="Withdraw"></td><td>Amount: <input type="text" name="amt_{{ w.cid }}"></td><td>Address: <input type="text" name="to_{{ w.cid }}"></td><td>Subtract fee: <input type="checkbox" name="subfee_{{ w.cid }}"></td></tr>
<tr><td>Fee Rate:</td><td>{{ w.fee_rate }}</td><td>Est Fee:</td><td>{{ w.est_fee }}</td></tr> <tr><td>Fee Rate:</td><td>{{ w.fee_rate }}</td><td>Est Fee:</td><td>{{ w.est_fee }}</td></tr>
</table> </table>

@ -292,6 +292,8 @@ def prepareDataDir(coin, settings, chain, particl_mnemonic):
fp.write('zmq-rpc-bind-port={}\n'.format(core_settings['zmqport'])) fp.write('zmq-rpc-bind-port={}\n'.format(core_settings['zmqport']))
fp.write('zmq-rpc-bind-ip=127.0.0.1\n') fp.write('zmq-rpc-bind-ip=127.0.0.1\n')
fp.write('prune-blockchain=1') fp.write('prune-blockchain=1')
fp.write('restricted-rpc=1')
fp.write('bootstrap-daemon-address=auto')
wallet_conf_path = os.path.join(data_dir, coin + '_wallet.conf') wallet_conf_path = os.path.join(data_dir, coin + '_wallet.conf')
if os.path.exists(wallet_conf_path): if os.path.exists(wallet_conf_path):

@ -83,7 +83,7 @@ Dependencies:
$ wget -O coincurve-anonswap.zip https://github.com/tecnovert/coincurve/archive/anonswap.zip $ wget -O coincurve-anonswap.zip https://github.com/tecnovert/coincurve/archive/anonswap.zip
$ unzip coincurve-anonswap.zip $ unzip coincurve-anonswap.zip
$ cd $SWAP_DATADIR/coincurve-anonswap $ cd $SWAP_DATADIR/coincurve-anonswap
$ python3 setup.py install --force $ pip3 install .
$ cd $SWAP_DATADIR $ cd $SWAP_DATADIR
@ -106,6 +106,7 @@ Start the app
$ basicswap-run --datadir=$SWAP_DATADIR $ basicswap-run --datadir=$SWAP_DATADIR
Open in browser: `http://localhost:12700` Open in browser: `http://localhost:12700`
It may take a few minutes to start as the coin daemons are started before the http interface.
Start after installed: Start after installed:

Loading…
Cancel
Save