From e9986148d7cd3163424c388204e2b98a553a8492 Mon Sep 17 00:00:00 2001 From: tecnovert Date: Sat, 10 Feb 2024 04:09:08 +0200 Subject: [PATCH] Automatically remove untrusted-daemon from monero_wallet.conf --- bin/basicswap_run.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/bin/basicswap_run.py b/bin/basicswap_run.py index 59db07d..5c169c1 100755 --- a/bin/basicswap_run.py +++ b/bin/basicswap_run.py @@ -78,25 +78,21 @@ def startXmrWalletDaemon(node_dir, bin_dir, wallet_bin, opts=[]): config_path = os.path.join(data_dir, 'monero_wallet.conf') args = [daemon_bin, '--non-interactive', '--config-file=' + config_path] + opts - # TODO: Remove - # Remove daemon-address - has_daemon_address = False - has_untrusted = False + # Remove old config + needs_rewrite: bool = False + config_to_remove = ['daemon-address=', 'untrusted-daemon=', 'trusted-daemon=', 'proxy='] with open(config_path) as fp: for line in fp: - if line.startswith('daemon-address'): - has_daemon_address = True - if line.startswith('untrusted-daemon'): - has_untrusted = True - if has_daemon_address: + if any(line.startswith(config_line) for config_line in config_to_remove): + logging.warning('Found old config in monero_wallet.conf: {}'.format(line.strip())) + needs_rewrite = True + if needs_rewrite: logging.info('Rewriting monero_wallet.conf') shutil.copyfile(config_path, config_path + '.last') with open(config_path + '.last') as fp_from, open(config_path, 'w') as fp_to: 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) - if not has_untrusted: - fp_to.write('untrusted-daemon=1\n') logging.info('Starting wallet daemon {} --wallet-dir={}'.format(daemon_bin, node_dir))