Automatically remove untrusted-daemon from monero_wallet.conf
This commit is contained in:
parent
0aaf3f8bcc
commit
e9986148d7
@ -78,25 +78,21 @@ def startXmrWalletDaemon(node_dir, bin_dir, wallet_bin, opts=[]):
|
|||||||
config_path = os.path.join(data_dir, 'monero_wallet.conf')
|
config_path = os.path.join(data_dir, 'monero_wallet.conf')
|
||||||
args = [daemon_bin, '--non-interactive', '--config-file=' + config_path] + opts
|
args = [daemon_bin, '--non-interactive', '--config-file=' + config_path] + opts
|
||||||
|
|
||||||
# TODO: Remove
|
# Remove old config
|
||||||
# Remove daemon-address
|
needs_rewrite: bool = False
|
||||||
has_daemon_address = False
|
config_to_remove = ['daemon-address=', 'untrusted-daemon=', 'trusted-daemon=', 'proxy=']
|
||||||
has_untrusted = False
|
|
||||||
with open(config_path) as fp:
|
with open(config_path) as fp:
|
||||||
for line in fp:
|
for line in fp:
|
||||||
if line.startswith('daemon-address'):
|
if any(line.startswith(config_line) for config_line in config_to_remove):
|
||||||
has_daemon_address = True
|
logging.warning('Found old config in monero_wallet.conf: {}'.format(line.strip()))
|
||||||
if line.startswith('untrusted-daemon'):
|
needs_rewrite = True
|
||||||
has_untrusted = True
|
if needs_rewrite:
|
||||||
if has_daemon_address:
|
|
||||||
logging.info('Rewriting monero_wallet.conf')
|
logging.info('Rewriting monero_wallet.conf')
|
||||||
shutil.copyfile(config_path, config_path + '.last')
|
shutil.copyfile(config_path, config_path + '.last')
|
||||||
with open(config_path + '.last') as fp_from, open(config_path, 'w') as fp_to:
|
with open(config_path + '.last') as fp_from, open(config_path, 'w') as fp_to:
|
||||||
for line in fp_from:
|
for line in fp_from:
|
||||||
if not line.startswith('daemon-address'):
|
if not any(line.startswith(config_line) for config_line in config_to_remove):
|
||||||
fp_to.write(line)
|
fp_to.write(line)
|
||||||
if not has_untrusted:
|
|
||||||
fp_to.write('untrusted-daemon=1\n')
|
|
||||||
|
|
||||||
logging.info('Starting wallet daemon {} --wallet-dir={}'.format(daemon_bin, node_dir))
|
logging.info('Starting wallet daemon {} --wallet-dir={}'.format(daemon_bin, node_dir))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user