Add Tor Hidden Service support
MODIFY
HiddenWallet.ChaumianTumbler/Program.cs
HiddenWallet.ChaumianTumbler/Program.cs
@@ -29,8 +29,10 @@ namespace HiddenWallet.ChaumianTumbler
{
await Global.InitializeAsync();
+ var endPoint = "http://localhost:80/";
using (var host = WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
+ .UseUrls(endPoint)
.Build())
{
await host.RunAsync();

MODIFY
HiddenWallet.Daemon/Config.cs
HiddenWallet.Daemon/Config.cs
@@ -32,6 +32,12 @@ namespace HiddenWallet.Daemon
[JsonProperty(PropertyName = "ChaumianTumblerMainAddress", Order = 5)]
public string ChaumianTumblerMainAddress { get; private set; }
+ [JsonProperty(PropertyName = "ChaumianTumblerTestNetNotificationAddress", Order = 6)]
+ public string ChaumianTumblerTestNetNotificationAddress { get; private set; }
+
+ [JsonProperty(PropertyName = "ChaumianTumblerMainNotificationAddress", Order = 7)]
+ public string ChaumianTumblerMainNotificationAddress { get; private set; }
+
public Config()
{
@@ -55,8 +61,10 @@ namespace HiddenWallet.Daemon
WalletFilePath = Path.Combine(FullSpvWallet.Global.DataDir, "Wallets", "Wallet.json");
Network = Network.Main;
CanSpendUnconfirmed = false;
- ChaumianTumblerTestNetAddress = "http://localhost:60949/"; // TODO: change it when active tumbler had been set up
- ChaumianTumblerMainAddress = "http://localhost:60949/"; // TODO: change it when active tumbler had been set up
+ ChaumianTumblerTestNetAddress = "http://i4dmqjdw2nljsyt3.onion/"; // TODO: change it when active tumbler had been set up
+ ChaumianTumblerMainAddress = "http://i4dmqjdw2nljsyt3.onion/"; // TODO: change it when active tumbler had been set up
+ ChaumianTumblerTestNetNotificationAddress = "http://localhost:80/"; // TODO: change it when active tumbler had been set up
+ ChaumianTumblerMainNotificationAddress = "http://localhost:80/"; // TODO: change it when active tumbler had been set up
if (!File.Exists(path))
{

MODIFY
HiddenWallet.Daemon/Controllers/WalletController.cs
HiddenWallet.Daemon/Controllers/WalletController.cs
@@ -331,7 +331,8 @@ namespace HiddenWallet.Daemon.Controllers
//Fees:
//var satoshiFeePerBytes = (await _walletJob.FeeJob.GetFeePerBytesAsync(FeeType.High, default(CancellationToken)).ConfigureAwait(false)).ToDecimal(MoneyUnit.Satoshi);
- return new ObjectResult(new ChaumianCoinJoin.Models.StatusResponse { Success = true, Address = "To Do: set in WalletWrapper.GetTumblerServerResponseAsync", Phase = ChaumianCoinJoin.TumblerPhase.InputRegistration.ToString(), Denomination = "0.15", AnonymitySet = 12, TimeSpentInInputRegistrationInSeconds = 416, MaximumInputsPerAlices = 4, FeePerInputs = "0.00015 BTC", FeePerOutputs = "0.00015 BTC", NetworkFee = "0.002034 BTC", Version = "1" });
+ var address = Global.WalletWrapper.Network == Network.Main ? Global.Config.ChaumianTumblerMainAddress : Global.Config.ChaumianTumblerTestNetAddress;
+ return new ObjectResult(new ChaumianCoinJoin.Models.StatusResponse { Address = address, Phase = ChaumianCoinJoin.TumblerPhase.InputRegistration.ToString(), Denomination = "0.15", AnonymitySet = 12, TimeSpentInInputRegistrationInSeconds = 416, MaximumInputsPerAlices = 4, FeePerInputs = "0.00015 BTC", FeePerOutputs = "0.00015 BTC", NetworkFee = "0.002034 BTC", Version = "1" });
//try
//{
// return new ObjectResult(Global.WalletWrapper.GetTumblerServerResponseAsync().Result);

MODIFY
HiddenWallet.Daemon/Wrappers/WalletWrapper.cs
HiddenWallet.Daemon/Wrappers/WalletWrapper.cs
@@ -103,11 +103,11 @@ namespace HiddenWallet.Daemon.Wrappers
if(Network == Network.Main)
{
- _walletJob.CoinJoinService.SetConnection(Global.Config.ChaumianTumblerMainAddress, Global.RsaPubKey, Tor.SocksPortHandler, disposeHandler: false);
+ _walletJob.CoinJoinService.SetConnection(Global.Config.ChaumianTumblerMainAddress, Global.Config.ChaumianTumblerMainNotificationAddress, Global.RsaPubKey, Tor.SocksPortHandler, disposeHandler: false);
}
else
{
- _walletJob.CoinJoinService.SetConnection(Global.Config.ChaumianTumblerTestNetAddress, Global.RsaPubKey, Tor.SocksPortHandler, disposeHandler: false);
+ _walletJob.CoinJoinService.SetConnection(Global.Config.ChaumianTumblerTestNetAddress, Global.Config.ChaumianTumblerTestNetNotificationAddress, Global.RsaPubKey, Tor.SocksPortHandler, disposeHandler: false);
}
await _walletJob.CoinJoinService.SubscribePhaseChangeAsync();
}

MODIFY
HiddenWallet.FullSpvWallet/ChaumianCoinJoin/CoinJoinService.cs
HiddenWallet.FullSpvWallet/ChaumianCoinJoin/CoinJoinService.cs
@@ -26,7 +26,7 @@ namespace HiddenWallet.FullSpvWallet.ChaumianCoinJoin
public HubConnection TumblerConnection { get; private set; }
public WalletJob WalletJob { get; private set; }
public ChaumianTumblerClient TumblerClient { get; private set; }
- public string BaseAddress { get; private set; }
+ public string NotificationBaseAddress { get; private set; }
public SafeAccount From { get; private set; }
public SafeAccount To { get; private set; }
@@ -57,11 +57,14 @@ namespace HiddenWallet.FullSpvWallet.ChaumianCoinJoin
WalletJob = walletJob ?? throw new ArgumentNullException(nameof(walletJob));
}
- public void SetConnection(string address, BlindingRsaPubKey pubKey, HttpMessageHandler handler, bool disposeHandler = false)
+ public void SetConnection(string address, string notificationAddress, BlindingRsaPubKey pubKey, HttpMessageHandler handler, bool disposeHandler = false)
{
PubKey = pubKey ?? throw new ArgumentNullException(nameof(pubKey));
- BaseAddress = address.EndsWith('/') ? address : address + "/";
- TumblerClient = new ChaumianTumblerClient(BaseAddress, handler, disposeHandler);
+ if (address == null) throw new ArgumentNullException(address);
+ if (notificationAddress == null) throw new ArgumentNullException(notificationAddress);
+ NotificationBaseAddress = notificationAddress.Trim().EndsWith('/') ? notificationAddress.Trim() : notificationAddress.Trim() + "/";
+ var correctedAddress = address.Trim().EndsWith('/') ? address.Trim() : address.Trim() + "/";
+ TumblerClient = new ChaumianTumblerClient(correctedAddress, handler, disposeHandler);
}
#region Notifications
@@ -71,7 +74,7 @@ namespace HiddenWallet.FullSpvWallet.ChaumianCoinJoin
try
{
TumblerConnection = new HubConnectionBuilder()
- .WithUrl(BaseAddress + "ChaumianTumbler")
+ .WithUrl(NotificationBaseAddress + "ChaumianTumbler")
.Build();
TumblerConnection.On<string>("PhaseChange", async data =>
@@ -283,6 +286,10 @@ namespace HiddenWallet.FullSpvWallet.ChaumianCoinJoin
}
else if (phase == TumblerPhase.OutputRegistration)
{
+ Debug.WriteLine($"Changing Tor circuit");
+ await WalletJob.ControlPortClient.ChangeCircuitAsync();
+ await Task.Delay(100);
+
var request = new OutputRequest
{
Output = ActiveOutput.ToString(),
@@ -292,6 +299,10 @@ namespace HiddenWallet.FullSpvWallet.ChaumianCoinJoin
}
else if (phase == TumblerPhase.Signing)
{
+ Debug.WriteLine($"Changing Tor circuit");
+ await WalletJob.ControlPortClient.ChangeCircuitAsync();
+ await Task.Delay(100);
+
var request = new CoinJoinRequest
{
UniqueId = UniqueAliceId

MODIFY
HiddenWallet/ChaumianCoinJoin/ChaumianTumblerClient.cs
HiddenWallet/ChaumianCoinJoin/ChaumianTumblerClient.cs
@@ -24,9 +24,7 @@ namespace HiddenWallet.ChaumianCoinJoin
if (address == null) throw new ArgumentNullException(nameof(address));
if (handler == null) throw new ArgumentNullException(nameof(handler));
- HttpClient = new HttpClient(handler, disposeHandler);
-
- HttpClient = new HttpClient
+ HttpClient = new HttpClient(handler, disposeHandler)
{
BaseAddress = new Uri(address + "api/v1/Tumbler/")
};

Add Tor Hidden Service support