-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWrapper.cs
58 lines (48 loc) · 2.06 KB
/
Wrapper.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System.Diagnostics;
using System.Reflection;
using System.Text;
using static System.Net.WebRequestMethods;
namespace P2FK.IO
{
public class Wrapper
{
//default mainnet connection info
public string ProdCLIPath = @"C:\SUP\SUP.exe"; // Replace with the actual path to SUP.EXE
public string ProdVersionByte = @"0"; // Replace with the actual version byte
public string ProdRPCURL = @"http://127.0.0.1:8332";
public string ProdRPCUser = "good-user";
public string ProdRPCPassword = "better-password";
//default testnet connection info
public string TestCLIPath = @"C:\SUP\SUP.exe"; // Replace with the actual path to SUP.EXE
public string TestVersionByte = @"111"; // Replace with the actual version byte
public string TestRPCURL = @"http://127.0.0.1:18332";
public string TestRPCUser = "good-user";
public string TestRPCPassword = "better-password";
public string RunCommand(string executablePath, string arguments)
{
ProcessStartInfo processStartInfo = new ProcessStartInfo
{
FileName = executablePath,
Arguments = arguments,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true,
UseShellExecute = false,
StandardOutputEncoding = Encoding.UTF8, // Set the standard output encoding to UTF-8
StandardErrorEncoding = Encoding.UTF8 // Set the standard error encoding to UTF-8
};
using (Process process = new Process { StartInfo = processStartInfo })
{
process.Start();
string output = process.StandardOutput.ReadToEnd();
string error = process.StandardError.ReadToEnd();
process.WaitForExit();
if (!string.IsNullOrEmpty(error))
{
return $"Error: {error}";
}
return output;
}
}
}
}