From f64b2c1030270c86c9eff3a6aad2ace3f32fc74d Mon Sep 17 00:00:00 2001
From: tecnovert <tecnovert@tecnovert.net>
Date: Sun, 5 May 2024 14:37:54 +0200
Subject: [PATCH] Rewrite litecoin.conf from basicswap-run to add config for
 0.21.3.

---
 bin/basicswap_run.py | 18 ++++++++++++++++++
 doc/release-notes.md |  1 +
 2 files changed, 19 insertions(+)

diff --git a/bin/basicswap_run.py b/bin/basicswap_run.py
index f9e754a..22ce1ca 100755
--- a/bin/basicswap_run.py
+++ b/bin/basicswap_run.py
@@ -53,6 +53,24 @@ def startDaemon(node_dir, bin_dir, daemon_bin, opts=[]):
     daemon_bin = os.path.expanduser(os.path.join(bin_dir, daemon_bin))
 
     datadir_path = os.path.expanduser(node_dir)
+
+    # Rewrite litecoin.conf for 0.21.3
+    ltc_conf_path = os.path.join(datadir_path, 'litecoin.conf')
+    if os.path.exists(ltc_conf_path):
+        config_to_add = ['blockfilterindex=0', 'peerblockfilters=0']
+        with open(ltc_conf_path) as fp:
+            for line in fp:
+                line = line.strip()
+                if line in config_to_add:
+                    config_to_add.remove(line)
+
+        if len(config_to_add) > 0:
+            logging.info('Rewriting litecoin.conf')
+            shutil.copyfile(ltc_conf_path, ltc_conf_path + '.last')
+            with open(ltc_conf_path, 'a') as fp:
+                for line in config_to_add:
+                    fp.write(line + '\n')
+
     args = [daemon_bin, '-datadir=' + datadir_path] + opts
     logging.info('Starting node ' + daemon_bin + ' ' + '-datadir=' + node_dir)
     return subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=datadir_path)
diff --git a/doc/release-notes.md b/doc/release-notes.md
index bc0198b..6d5cf01 100644
--- a/doc/release-notes.md
+++ b/doc/release-notes.md
@@ -10,6 +10,7 @@
   - Blank/unset for active coins.
   - All for all known coins.
   - Comma separated list of coin tickers to show.
+- basicswap-run will rewrite litecoin.conf file to add config required to run Litecoin 0.21.3 in pruned mode.
 
 
 0.12.7