Fix testnet mode, expanduser on paths.

This commit is contained in:
tecnovert 2019-07-23 16:26:37 +02:00
parent 5bfcdd469b
commit e039d90bee
No known key found for this signature in database
GPG key ID: 8ED6D8750C4E3F93
3 changed files with 18 additions and 9 deletions

View file

@ -531,7 +531,9 @@ class BasicSwap():
def setDefaultConnectParams(self, coin):
chain_client_settings = self.getChainClientSettings(coin)
datadir = chain_client_settings.get('datadir', os.path.join(cfg.DATADIRS, chainparams[coin]['name']))
bindir = os.path.expanduser(chain_client_settings.get('bindir', ''))
datadir = os.path.expanduser(chain_client_settings.get('datadir', os.path.join(cfg.DATADIRS, chainparams[coin]['name'])))
blocks_confirmed = chain_client_settings.get('blocks_confirmed', 6)
connection_type = chain_client_settings.get('connection_type', 'none')
use_segwit = chain_client_settings.get('use_segwit', False)
@ -543,8 +545,11 @@ class BasicSwap():
elif 'rpcpassword' in chain_client_settings:
rpcauth = chain_client_settings['rpcuser'] + ':' + chain_client_settings['rpcpassword']
if rpcauth is None:
testnet_name = '' if self.chain == 'mainnet' else self.chain
if testnet_name == 'testnet' and coin != Coins.PART:
testnet_name += '4'
authcookiepath = os.path.join(datadir, testnet_name, '.cookie')
# Wait for daemon to start
authcookiepath = os.path.join(datadir, '' if self.chain == 'mainnet' else self.chain, '.cookie')
for i in range(10):
if not os.path.exists(authcookiepath):
time.sleep(0.5)
@ -565,6 +570,7 @@ class BasicSwap():
return {
'coin': coin,
'connection_type': connection_type,
'bindir': bindir,
'datadir': datadir,
'rpcport': chain_client_settings.get('rpcport', chainparams[coin][self.chain]['rpcport']),
'rpcauth': rpcauth,
@ -2242,8 +2248,7 @@ class BasicSwap():
return callrpc(self.coin_clients[coin]['rpcport'], self.coin_clients[coin]['rpcauth'], method, params, wallet)
def calltx(self, cmd):
settings = self.getChainClientSettings(Coins.PART)
bindir = settings.get('bindir', '')
bindir = self.coin_clients[Coins.PART]['bindir']
command_cli = os.path.join(bindir, cfg.PARTICL_TX)
chainname = '' if self.chain == 'mainnet' else (' -' + self.chain)
args = command_cli + chainname + ' ' + cmd

View file

@ -331,7 +331,11 @@ def main():
with open(core_conf_path, 'w') as fp:
if chain != 'mainnet':
fp.write(chain + '=1\n\n')
fp.write(chain + '=1\n')
if chain == 'testnet':
fp.write('[test]\n\n')
else:
logger.warning('Unknown chain %s', chain)
fp.write('rpcport={}\n'.format(core_settings['rpcport']))
fp.write('printtoconsole=0\n')

View file

@ -44,9 +44,9 @@ def signal_handler(sig, frame):
def startDaemon(node_dir, bin_dir, daemon_bin, opts=[]):
daemon_bin = os.path.join(bin_dir, daemon_bin)
daemon_bin = os.path.expanduser(os.path.join(bin_dir, daemon_bin))
args = [daemon_bin, '-datadir=' + node_dir] + opts
args = [daemon_bin, '-datadir=' + os.path.expanduser(node_dir)] + opts
logger.info('Starting node ' + daemon_bin + ' ' + '-datadir=' + node_dir)
return subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)