Remove BitcoindProcessBridge, add ProcessInvoker class.
MODIFY
WalletWasabi/BitcoinCore/CoreNode.cs
WalletWasabi/BitcoinCore/CoreNode.cs
@@ -24,6 +24,7 @@ using WalletWasabi.Blockchain.Mempool;
using WalletWasabi.Blockchain.P2p;
using WalletWasabi.Helpers;
using WalletWasabi.Logging;
+using WalletWasabi.Microservices;
using WalletWasabi.Services;
using WalletWasabi.Stores;
@@ -186,9 +187,11 @@ namespace WalletWasabi.BitcoinCore
public static async Task<Version> GetVersionAsync(CancellationToken cancel)
{
+ var invoker = new ProcessInvoker();
+
var arguments = "-version";
- var bridge = new BitcoindProcessBridge();
- var (responseString, exitCode) = await bridge.SendCommandAsync(arguments, openConsole:false, cancel).ConfigureAwait(false);
+ var process = ProcessBuilder.BuildProcessInstance(MicroserviceHelpers.GetBinaryPath("bitcoind"), arguments);
+ var (responseString, exitCode) = await invoker.SendCommandAsync(process, cancel).ConfigureAwait(false);
if (exitCode != 0)
{

DELETE
WalletWasabi/BitcoinCore/Processes/BitcoindProcessBridge.cs
-using System;
-using System.Collections.Generic;
-using System.Text;
-using WalletWasabi.Microservices;
-
-namespace WalletWasabi.BitcoinCore.Processes
-{
- public class BitcoindProcessBridge : ProcessBridge
- {
- public BitcoindProcessBridge() : base(MicroserviceHelpers.GetBinaryPath("bitcoind"))
- {
- }
- }
-}

MODIFY
WalletWasabi/BitcoinCore/Processes/BitcoindRpcProcessBridge.cs
WalletWasabi/BitcoinCore/Processes/BitcoindRpcProcessBridge.cs
@@ -14,11 +14,11 @@ using WalletWasabi.Microservices;
namespace WalletWasabi.BitcoinCore.Processes
{
- public class BitcoindRpcProcessBridge : BitcoindProcessBridge
+ public class BitcoindRpcProcessBridge : ProcessBridge
{
public const string PidFileName = "bitcoin.pid";
- public BitcoindRpcProcessBridge(IRPCClient rpc, string dataDir, bool printToConsole) : base()
+ public BitcoindRpcProcessBridge(IRPCClient rpc, string dataDir, bool printToConsole) : base(MicroserviceHelpers.GetBinaryPath("bitcoind"))
{
RpcClient = Guard.NotNull(nameof(rpc), rpc);
Network = RpcClient.Network;

ADD
WalletWasabi/Microservices/ProcessInvoker.cs
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace WalletWasabi.Microservices
+{
+ public class ProcessInvoker
+ {
+ public async Task<(string response, int exitCode)> SendCommandAsync(Process process, CancellationToken cancel)
+ {
+ // "using" makes sure the process exits at the end of this method.
+ using var processAsync = new ProcessAsync(process);
+
+ process.Start();
+
+ await processAsync.WaitForExitAsync(cancel);
+
+ string responseString = process.StartInfo.UseShellExecute
+ ? string.Empty
+ : await process.StandardOutput.ReadToEndAsync().ConfigureAwait(false);
+
+ return (responseString, exitCode: process.ExitCode);
+ }
+ }
+}

Remove BitcoindProcessBridge, add ProcessInvoker class.