From cf2f68f2b3c89c9ad65a493c1423a3a4fdaa185f Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Wed, 14 Jun 2023 23:27:13 +1000 Subject: [PATCH] main: Added support for custom HSD launch command --- FireWallet/MainForm.cs | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/FireWallet/MainForm.cs b/FireWallet/MainForm.cs index 46a4b8d..1295d1f 100644 --- a/FireWallet/MainForm.cs +++ b/FireWallet/MainForm.cs @@ -239,13 +239,41 @@ namespace FireWallet hsdProcess.StartInfo.RedirectStandardOutput = false; hsdProcess.StartInfo.UseShellExecute = false; hsdProcess.StartInfo.FileName = "node.exe"; - hsdProcess.StartInfo.Arguments = dir + "hsd/bin/hsd --agent=FireWallet --index-tx --index-address --api-key " + nodeSettings["Key"]; - string bobPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Bob\\hsd_data"; - if (Directory.Exists(bobPath)) + if (nodeSettings.ContainsKey("HSD-command")) { - hsdProcess.StartInfo.Arguments = hsdProcess.StartInfo.Arguments + " --prefix " + bobPath; + AddLog("Using custom HSD command"); + string command = nodeSettings["HSD-command"]; + command = command.Replace("{default-dir}", dir + "hsd\\bin\\hsd"); + + string bobPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Bob\\hsd_data"; + if (Directory.Exists(bobPath)) + { + command = command.Replace("{Bob}", bobPath); + } + else if (command.Contains("{Bob}")) + { + AddLog("Bob not found, using default HSD command"); + command = dir + "hsd\\bin\\hsd --agent=FireWallet --index-tx --index-address --api-key " + nodeSettings["Key"]; + } + + command = command.Replace("{key}", nodeSettings["Key"]); + hsdProcess.StartInfo.Arguments = command; } + else + { + AddLog("Using default HSD command"); + hsdProcess.StartInfo.Arguments = dir + "hsd\\bin\\hsd --agent=FireWallet --index-tx --index-address --api-key " + nodeSettings["Key"]; + string bobPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Bob\\hsd_data"; + if (Directory.Exists(bobPath)) + { + hsdProcess.StartInfo.Arguments = hsdProcess.StartInfo.Arguments + " --prefix " + bobPath; + } + } + + + + hsdProcess.Start(); // Wait for HSD to start await Task.Delay(2000);