diff --git a/.gitignore b/.gitignore index d8ad3fb..b3539aa 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ dist/ hsd/ hsd-data/ hsd.lock +hsdconfig.json diff --git a/README.md b/README.md index 46745c4..9a3d2fe 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,20 @@ INTERNAL_HSD: Use internal HSD node (true/false) ``` + +# Internal HSD + +If you set INTERNAL_HSD=true in the .env file the wallet will start and manage its own HSD node. If you want to override the default HSD config create a file called hsdconfig.json in the same directory as main.py and change the values you want to override. For example to disable SPV and use an existing bob wallet sync (on linux) and set the agent to "SuperCoolDev" you could use the following: +```json +{ + "spv": false, + "prefix":"~/.config/Bob/hsd_data", + "flags":[ + "--agent=SuperCoolDev" + ] +} +``` + ## Warnings - This is a work in progress and is not guaranteed to work diff --git a/account.py b/account.py index c9f111e..d427f8c 100644 --- a/account.py +++ b/account.py @@ -48,18 +48,25 @@ if SHOW_EXPIRED is None: HSD_PROCESS = None # Get hsdconfig.json -HSD_CONFIG = {} +HSD_CONFIG = { + "version": "v8.0.0", + "chainMigrate": 4, + "walletMigrate": 7, + "minNodeVersion": 20, + "minNpmVersion": 8, + "spv": False, + "flags": [ + "--agent=FireWallet" + ] +} if not os.path.exists('hsdconfig.json'): - # Pull from the latest git - response = requests.get("https://git.woodburn.au/nathanwoodburn/firewalletbrowser/raw/branch/main/hsdconfig.json") - if response.status_code == 200: - with open('hsdconfig.json', 'w') as f: - f.write(response.text) - HSD_CONFIG = response.json() + with open('hsdconfig.json', 'w') as f: + f.write(json.dumps(HSD_CONFIG, indent=4)) else: with open('hsdconfig.json') as f: - HSD_CONFIG = json.load(f) - + hsdConfigTMP = json.load(f) + for key in hsdConfigTMP: + HSD_CONFIG[key] = hsdConfigTMP[key] hsd = api.hsd(HSD_API, HSD_IP, HSD_NODE_PORT) hsw = api.hsw(HSD_API, HSD_IP, HSD_WALLET_PORT) @@ -1634,7 +1641,6 @@ def hsdStart(): f"--network={HSD_NETWORK}", f"--prefix={prefix}", f"--api-key={HSD_API}", - "--agent=FireWallet", "--http-host=127.0.0.1", "--log-console=false" ] @@ -1647,6 +1653,10 @@ def hsdStart(): if spv: cmd.append("--spv") + # Add flags + if len(HSD_CONFIG.get("flags",[])) > 0: + for flag in HSD_CONFIG.get("flags",[]): + cmd.append(flag) # Launch process HSD_PROCESS = subprocess.Popen( diff --git a/hsdconfig.json b/hsdconfig.json deleted file mode 100644 index 9484276..0000000 --- a/hsdconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -{ -"version": "v8.0.0", -"chainMigrate":4, -"walletMigrate":7, -"minNodeVersion":20, -"minNpmVersion":8, -"spv": true -} \ No newline at end of file