Add CoinJoinService
MODIFY
HiddenWallet.Daemon/Wrappers/WalletWrapper.cs
HiddenWallet.Daemon/Wrappers/WalletWrapper.cs
@@ -102,11 +102,11 @@ namespace HiddenWallet.Daemon.Wrappers
if(Network == Network.Main)
{
- await _walletJob.SubscribeTumblerPhaseChangeAsync(Global.Config.ChaumianTumblerMainAddress);
+ await _walletJob.CoinJoinService.SubscribePhaseChangeAsync(Global.Config.ChaumianTumblerMainAddress);
}
else
{
- await _walletJob.SubscribeTumblerPhaseChangeAsync(Global.Config.ChaumianTumblerTestNetAddress);
+ await _walletJob.CoinJoinService.SubscribePhaseChangeAsync(Global.Config.ChaumianTumblerTestNetAddress);
}
}
}

MODIFY
HiddenWallet.FullSpvWallet/WalletJob.cs
HiddenWallet.FullSpvWallet/WalletJob.cs
@@ -24,6 +24,7 @@ using Nito.AsyncEx;
using HiddenWallet.WebClients.SmartBit;
using HiddenWallet.Helpers;
using Microsoft.AspNetCore.SignalR.Client;
+using HiddenWallet.FullSpvWallet.ChaumianCoinJoin;
namespace HiddenWallet.FullSpv
{
@@ -42,6 +43,8 @@ namespace HiddenWallet.FullSpv
public BlockDownloader BlockDownloader;
+ public CoinJoinService CoinJoinService;
+
public FeeService FeeService;
private Height _creationHeight;
@@ -243,6 +246,8 @@ namespace HiddenWallet.FullSpv
FeeService = new FeeService(safeToTrack.Network, ControlPortClient, disposeTorControl: false, handler: handler, disposeHandler: false);
+ CoinJoinService = new CoinJoinService(this);
+
if (accountsToTrack == null || accountsToTrack.Count() < 2)
{
@@ -381,7 +386,7 @@ namespace HiddenWallet.FullSpv
{
}
- await DisposeTumblerAsync();
+ await CoinJoinService.DisposeAsync();
}
}
@@ -1285,64 +1290,5 @@ namespace HiddenWallet.FullSpv
}
#endregion
-
- #region ChaumianCoinJoin
-
- public HubConnection TumblerConnection { get; private set; } = null;
-
- public async Task SubscribeTumblerPhaseChangeAsync(string address)
- {
- try
- {
- TumblerConnection = new HubConnectionBuilder()
- .WithUrl(address)
- .Build();
-
- TumblerConnection.On<string>("PhaseChange", data =>
- {
- Debug.WriteLine($"Received: {data}");
- });
-
- await TumblerConnection.StartAsync();
-
- TumblerConnection.Closed += TumblerConnection_ClosedAsync;
- }
- catch(Exception ex)
- {
- await DisposeTumblerAsync();
- Debug.WriteLine(ex);
- }
- }
-
- private async Task TumblerConnection_ClosedAsync(Exception arg)
- {
- await DisposeTumblerAsync();
- }
-
- private async Task DisposeTumblerAsync()
- {
- try
- {
- if (TumblerConnection != null)
- {
- try
- {
- TumblerConnection.Closed -= TumblerConnection_ClosedAsync;
- }
- catch (Exception)
- {
-
- }
- await TumblerConnection?.DisposeAsync();
- TumblerConnection = null;
- }
- }
- catch (Exception)
- {
-
- }
- }
-
- #endregion
}
}

Add CoinJoinService