Add TB unrelated improvements during TB developements
MODIFY
HiddenWallet/HiddenWallet.API/Config.cs
HiddenWallet/HiddenWallet.API/Config.cs
@@ -14,9 +14,6 @@ namespace HiddenWallet.API
public static Network Network = Network.Main;
public static bool CanSpendUnconfirmed = false;
- public static Uri TumbleBitServerTestNet = new Uri("http://t4cqwqlvswcyyagg.onion/api/v1/tumblers/310586435471416ca16058c1fb9ed3c868f239b9");
- public static Uri TumbleBitServerMainNet = null;
-
static Config()
{
if (!File.Exists(ConfigFileSerializer.ConfigFilePath))
@@ -32,9 +29,7 @@ namespace HiddenWallet.API
ConfigFileSerializer.Serialize(
WalletFilePath,
Network.ToString(),
- CanSpendUnconfirmed.ToString(),
- TumbleBitServerTestNet == null ? "" : TumbleBitServerTestNet.AbsoluteUri,
- TumbleBitServerMainNet == null ? "" : TumbleBitServerMainNet.AbsoluteUri);
+ CanSpendUnconfirmed.ToString());
Load();
}
@@ -75,18 +70,6 @@ namespace HiddenWallet.API
CanSpendUnconfirmed = false;
else
throw new NotSupportedException($"Wrong CanSpendUnconfirmed value in {ConfigFileSerializer.ConfigFilePath}");
-
- if (rawContent.TumbleBitServerTestNet == null || rawContent.TumbleBitServerTestNet == "")
- {
- TumbleBitServerTestNet = null;
- }
- else TumbleBitServerTestNet = new Uri(rawContent.TumbleBitServerTestNet);
-
- if (rawContent.TumbleBitServerMainNet == null || rawContent.TumbleBitServerMainNet == "")
- {
- TumbleBitServerMainNet = null;
- }
- else TumbleBitServerMainNet = new Uri(rawContent.TumbleBitServerMainNet);
}
public class ConfigFileSerializer
@@ -99,39 +82,28 @@ namespace HiddenWallet.API
public string Network { get; set; }
public string CanSpendUnconfirmed { get; set; }
- public string TumbleBitServerTestNet { get; set; }
- public string TumbleBitServerMainNet { get; set; }
-
[JsonConstructor]
private ConfigFileSerializer(
string walletFilePath,
string network,
- string canSpendUnconfirmed,
- string tumbleBitServerTestNet,
- string tumbleBitServerMainNet)
+ string canSpendUnconfirmed)
{
WalletFilePath = walletFilePath;
Network = network;
CanSpendUnconfirmed = canSpendUnconfirmed;
- TumbleBitServerTestNet = tumbleBitServerTestNet;
- TumbleBitServerMainNet = tumbleBitServerMainNet;
}
internal static void Serialize(
string walletFilePath,
string network,
- string canSpendUnconfirmed,
- string tumbleBitServerTestNet,
- string tumbleBitServerMainNet)
+ string canSpendUnconfirmed)
{
var content =
JsonConvert.SerializeObject(
new ConfigFileSerializer(
walletFilePath,
network,
- canSpendUnconfirmed,
- tumbleBitServerTestNet,
- tumbleBitServerMainNet), Formatting.Indented);
+ canSpendUnconfirmed), Formatting.Indented);
File.WriteAllText(ConfigFilePath, content);
}
@@ -147,9 +119,7 @@ namespace HiddenWallet.API
return new ConfigFileSerializer(
configFileSerializer.WalletFilePath,
configFileSerializer.Network,
- configFileSerializer.CanSpendUnconfirmed,
- configFileSerializer.TumbleBitServerTestNet,
- configFileSerializer.TumbleBitServerMainNet);
+ configFileSerializer.CanSpendUnconfirmed);
}
}
}

MODIFY
HiddenWallet/HiddenWallet.API/Controllers/WalletController.cs
HiddenWallet/HiddenWallet.API/Controllers/WalletController.cs
@@ -9,7 +9,6 @@ using HBitcoin.KeyManagement;
using NBitcoin;
using System.Globalization;
using HBitcoin.Models;
-using HBitcoin.Fees;
namespace HiddenWallet.API.Controllers
{
@@ -314,19 +313,5 @@ namespace HiddenWallet.API.Controllers
return new ObjectResult(new FailureResponse { Message = ex.Message, Details = ex.ToString() });
}
}
-
- [Route("tumbler-server")]
- [HttpGet]
- public IActionResult TumblerServer()
- {
- try
- {
- return new ObjectResult(Global.WalletWrapper.GetTumblerServerResponseAsync().Result);
- }
- catch (Exception ex)
- {
- return new ObjectResult(new FailureResponse { Message = ex.Message, Details = ex.ToString() });
- }
- }
}
}

MODIFY
HiddenWallet/HiddenWallet.API/HiddenWallet.API.csproj
HiddenWallet/HiddenWallet.API/HiddenWallet.API.csproj
<RuntimeIdentifiers>win7-x64;win8-x64;win81-x64;win10-x64;osx.10.10-x64;osx.10.11-x64;osx.10.12-x64;ubuntu.14.04-x64;ubuntu.14.10-x64;ubuntu.15.04-x64;ubuntu.15.10-x64;ubuntu.16.04-x64;ubuntu.16.10-x64;debian.8-x64;linuxmint.17-x64;linuxmint.17.1-x64;linuxmint.17.2-x64;linuxmint.17.3-x64;linuxmint.18-x64;win7-x86;win8-x86;win81-x86;win10-x86</RuntimeIdentifiers>
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="HBitcoin" Version="0.2.4" />
+ <PackageReference Include="HBitcoin" Version="0.1.8.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Routing" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.1.2" />

MODIFY
HiddenWallet/HiddenWallet.API/Wrappers/WalletWrapper.cs
HiddenWallet/HiddenWallet.API/Wrappers/WalletWrapper.cs
@@ -15,8 +15,6 @@ using System.Threading;
using System.Threading.Tasks;
using static HBitcoin.FullBlockSpv.WalletJob;
using DotNetTor.SocksPort;
-using HBitcoin.TumbleBit.ClassicTumbler;
-using HBitcoin.Fees;
namespace HiddenWallet.API.Wrappers
{
@@ -89,8 +87,7 @@ namespace HiddenWallet.API.Wrappers
// it's not running yet, let's run it
_password = password;
- Uri tumblerUri = Config.Network == Network.Main ? Config.TumbleBitServerMainNet : Config.TumbleBitServerTestNet;
- _walletJob = new WalletJob(Tor.SocksPortHandler, Tor.ControlPortClient, safe, tumbleBitServerUri: tumblerUri, trackDefaultSafe: false, accountsToTrack: new SafeAccount[] { AliceAccount, BobAccount });
+ _walletJob = new WalletJob(Tor.SocksPortHandler, Tor.ControlPortClient, safe, trackDefaultSafe: false, accountsToTrack: new SafeAccount[] { AliceAccount, BobAccount });
_walletJob.StateChanged += _walletJob_StateChanged;
_walletJob.Tracker.TrackedTransactions.CollectionChanged += TrackedTransactions_CollectionChanged;
@@ -287,38 +284,5 @@ namespace HiddenWallet.API.Wrappers
if (result.Success) return new SuccessResponse();
else return new FailureResponse { Message = result.FailingReason, Details = "" };
}
-
- public async Task<TumblerServerResponse> GetTumblerServerResponseAsync()
- {
- var addressUri = Network == Network.Main ? Config.TumbleBitServerMainNet : Config.TumbleBitServerTestNet;
- var address = "";
- if (addressUri != null)
- {
- address = addressUri.AbsoluteUri;
- }
-
- if(address == "" || _walletJob.UseTumbleBit == false)
- {
- return new TumblerServerResponse { Address = address, Status = "TumbleBitConfiguredToBeNotUsed", Denomination = "", FeePercent = "", SatoshiFeePerBytes = "", CycleLengthMinutes = "" };
- }
-
- if (_walletJob.TumbleBitSetupSuccessful == false)
- {
- return new TumblerServerResponse { Address = address, Status = "TumblerServerIssues", Denomination = "", FeePercent = "", SatoshiFeePerBytes = "", CycleLengthMinutes = "" };
- }
- var satoshiFeePerBytes = (await _walletJob.FeeJob.GetFeePerBytesAsync(FeeType.High, default(CancellationToken)).ConfigureAwait(false)).ToDecimal(MoneyUnit.Satoshi);
- var periods = _walletJob.TumbleBitRuntime.TumblerParameters.CycleGenerator.FirstCycle.GetPeriods();
- var lengthBlocks = periods.Total.End - periods.Total.Start;
- var cycleLengthMinutes = lengthBlocks * 10;
-
- var denomination = _walletJob.TumbleBitRuntime.TumblerParameters.Denomination.ToDecimal(MoneyUnit.BTC);
- var fee = _walletJob.TumbleBitRuntime.TumblerParameters.Fee.ToDecimal(MoneyUnit.BTC);
- var feePercent = (fee / denomination) * 100;
- var fps = feePercent.ToString("0.##");
- var ds = denomination.ToString(CultureInfo.InvariantCulture);
- var sfpb = satoshiFeePerBytes.ToString(CultureInfo.InvariantCulture);
- var slm = cycleLengthMinutes.ToString(CultureInfo.InvariantCulture);
- return new TumblerServerResponse { Address = address, Status = "Online", Denomination = ds, FeePercent = fps, SatoshiFeePerBytes = sfpb, CycleLengthMinutes = slm };
- }
}
}

MODIFY
HiddenWallet/HiddenWallet.GUI/app/html/wallet-content.html
HiddenWallet/HiddenWallet.GUI/app/html/wallet-content.html
<span class="mdi mdi-tor"></span> Build Transaction
</button>
</div>
\ No newline at end of file
-
-<div id="mixer-content">
- <span class="label label-info" style="font-size: 14px;">Queue coins for mixing with TumbleBit</span>
- <hr />
-
- <label>Tumbler</label>
- <input id="tumbler-address" type="text" class="form-control" readonly />
- <br />
- <label>Status:</label>
- <span class="label" style="font-size: 13px; margin-left:11.4em;" id="tumbler-status"></span>
- <br />
- <div id="mixer-settings-content">
- <label>Denomination:</label>
- <span class="label label-success" style="font-size: 13px; margin-left:7.4em;" id="tumbler-denomination"></span>
- <br />
- <label>Tumbler Fee:</label>
- <span class="label label-success" style="font-size: 13px; margin-left:8.4em;" id="tumbler-fee"></span>
- <br />
- <label>Time to tumble the first coin:</label>
- <span style="font-size: 13px;" class="label label-success" id="tumbling-time"></span>
- <hr />
-
- <label>From:</label>
- <div class="dropdown">
- <span id="choose-wallet-dropdown-active" onclick="chooseWalletDropdown()" style="font-size: 15px; margin-left:2.2em;" class="label label-danger dropbtn"><span class="mdi mdi-arrow-down-drop-circle"></span> Select Wallet!</span>
- <div id="choose-wallet-dropdown" class="dropdown-content">
- <a id="wallet-dropdown-alice" onclick="chooseWalletDropdown('alice')" href="#">Alice</a>
- <a id="wallet-dropdown-bob" onclick="chooseWalletDropdown('bob')" href="#">Bob</a>
- </div>
- </div>
- <label>To:</label>
- <span class="label label-danger" id="tumbling-to-wallet" style="font-size: 15px;">?</span>
- <br />
- <br />
- <div id="not-enough-funds-to-mix" style="font-size: 13px;" class="alert alert-danger">Not enough funds to mix</div>
- <div id="wallet-selected">
- <form class="form-inline">
- <label>Amount:</label>
- <input style="margin-left:1em;" id="amount-input" class="form-control form-inline" onchange="amountChanged()" onkeypress="document.getElementById('amount-input').stepUp(1); return false;" type="number" size="11" />
- <label>BTC</label>
- </form>
- <hr />
-
- <label>Estimated Network Fees:</label>
- <span style="font-size: 13px;" class="label label-success" id="tumbling-network-fees"></span>
- <br />
- <br />
-
- <button id="broadcast-button" class="btn btn-lg btn-success btn-block" onclick="">
- <span class="mdi mdi-tor"></span> Start Mixing
- </button>
- </div>
- </div>
- <hr />
- <table class="table table-striped">
- <thead>
- <tr>
- <th>Cycle</th>
- <th>From</th>
- <th>To</th>
- <th>Anonymity Set</th>
- <th>Status</th>
- <th>Estimated Time Left</th>
- </tr>
- </thead>
- <tbody id="tumbling-records"></tbody>
- </table>
-</div>
\ No newline at end of file

MODIFY
HiddenWallet/HiddenWallet.GUI/app/html/wallet-phase-tabs.html
HiddenWallet/HiddenWallet.GUI/app/html/wallet-phase-tabs.html
<ul class="nav nav-tabs">
<li class="active"><a>Alice Wallet</a></li>
<li><a href="javascript:walletPhaseShow('bob')">Bob Wallet</a></li>
- <li><a href="javascript:walletPhaseShow('mixer')">Mixer</a></li>
</ul>
</nav>
</div>
<ul class="nav nav-tabs">
<li><a href="javascript:walletPhaseShow('alice')">Alice Wallet</a></li>
<li class="active"><a>Bob Wallet</a></li>
- <li><a href="javascript:walletPhaseShow('mixer')">Mixer</a></li>
- </ul>
- </nav>
-</div>
-
-<div class="masthead" id="mixer-active">
- <nav>
- <ul class="nav nav-tabs">
- <li><a href="javascript:walletPhaseShow('alice')">Alice Wallet</a></li>
- <li><a href="javascript:walletPhaseShow('bob')">Bob Wallet</a></li>
- <li class="active"><a>Mixer</a></li>
</ul>
</nav>
</div>
\ No newline at end of file

MODIFY
HiddenWallet/HiddenWallet.GUI/app/js/wallet-phase.js
HiddenWallet/HiddenWallet.GUI/app/js/wallet-phase.js
@@ -24,18 +24,6 @@ function walletPhaseShow(tabItem = "") {
document.getElementById("after-menu-hr").style.display = "block";
walletShow('receive');
}
- else if (tabItem === "mixer") {
- document.getElementById("content").setAttribute("style", "max-height: 430");
- document.getElementById("tabs").innerHTML = document.getElementById("wallet-phase-tabs-frame").contentWindow.document.getElementById("mixer-active").outerHTML;
- let hintTextArray = ["TumbleBit cannot steal your coins, nor deanonymize you", "Losing internet connection while mixing is dangerous if the Tumbler is malicous"];
- let randomHint = hintTextArray[Math.floor(Math.random() * hintTextArray.length)];
- writeHint(randomHint);
- document.getElementById("menu").innerHTML = "";
- document.getElementById("balances").innerHTML = "";
- document.getElementById("before-menu-br").style.display = "block";
- document.getElementById("after-menu-hr").style.display = "none";
- mixerShow();
- }
else if (tabItem === "") {
storage.get('lastAccount', function (error, data) {
if (error) throw error;
@@ -63,100 +51,6 @@ function walletShow(menuItem) {
updateWalletContent();
}
-
-/* When the user clicks on the button,
-toggle between hiding and showing the dropdown content */
-function chooseWalletDropdown(aliceBob = "") {
- let balances;
- if (aliceBob === "") {
- document.getElementById("choose-wallet-dropdown").classList.toggle("show");
- }
- else if (aliceBob === "alice") {
- document.getElementById("choose-wallet-dropdown-active").innerHTML = "Alice";
- document.getElementById("tumbling-to-wallet").innerHTML = "Bob";
- resp = httpGetWallet("balances/alice");
- }
- else if (aliceBob === "bob") {
- document.getElementById("choose-wallet-dropdown-active").innerHTML = "Bob";
- document.getElementById("tumbling-to-wallet").innerHTML = "Alice";
- resp = httpGetWallet("balances/bob");
- }
- if (aliceBob === "bob" || aliceBob === "alice") {
- document.getElementById("choose-wallet-dropdown-active").classList.remove("label-danger");
- document.getElementById("choose-wallet-dropdown-active").classList.add("label-success");
- document.getElementById("tumbling-to-wallet").classList.remove("label-danger");
- document.getElementById("tumbling-to-wallet").classList.add("label-success");
-
- let maximumMixed = resp.Available - (resp.Available * (tumblerFeePercent / 100));
-
- if (maximumMixed < tumblerDenomination) {
- document.getElementById("not-enough-funds-to-mix").style.removeProperty("display");
- document.getElementById("wallet-selected").style.display = "none";
- }
- else {
- var times = Math.floor(maximumMixed / tumblerDenomination);
- maximumMixed -= (estCycleFee * times);
- document.getElementById("wallet-selected").style.removeProperty("display");
- document.getElementById("not-enough-funds-to-mix").style.display = "none";
- document.getElementById("amount-input").step = tumblerDenomination;
- document.getElementById("amount-input").min = tumblerDenomination;
- document.getElementById("amount-input").max = maximumMixed;
- document.getElementById("amount-input").value = tumblerDenomination;
- document.getElementById("tumbling-network-fees").innerText = estCycleFee + " BTC";
- }
- }
-}
-
-function amountChanged() {
- let cycleCount = document.getElementById("amount-input").value / tumblerDenomination;
- document.getElementById("tumbling-network-fees").innerText = round(cycleCount * estCycleFee, 8) + " BTC";
-}
-
-function round(value, precision) {
- var multiplier = Math.pow(10, precision || 0);
- return Math.round(value * multiplier) / multiplier;
-}
-
-let tumblerAddress;
-let tumblerDenomination;
-let tumblerFeePercent;
-let tumblerFeeRate;
-let estCycleFee;
-function mixerShow() {
- document.getElementById("content").innerHTML = document.getElementById("wallet-content-frame").contentWindow.document.getElementById("mixer-content").outerHTML;
- let resp = httpGetWallet("tumbler-server");
- tumblerAddress = resp.Address;
- tumblerDenomination = resp.Denomination;
- tumblerFeePercent = resp.FeePercent;
- tumblerFeeRate = resp.SatoshiFeePerBytes;
- estCycleFee = tumblerFeeRate * (380 + 310) * 2 * 0.00000001;
-
- document.getElementById("tumbler-address").value = resp.Address;
-
- document.getElementById("tumbler-status").innerText = resp.Status;
- if (walletState.toUpperCase() === "SyncingHeaders".toUpperCase()
- || walletState.toUpperCase() === "NotStarted".toUpperCase()
- || (blocksLeftToSync !== 0 && blocksLeftToSync !== 1 && blocksLeftToSync !== 2)) {
- document.getElementById("tumbler-status").innerText = "WalletIsNotSynced";
- document.getElementById("tumbler-status").classList.add("label-danger");
- document.getElementById("mixer-settings-content").style.display = "none";
- }
- else if (resp.Status.toUpperCase() != "online".toUpperCase()) {
- document.getElementById("tumbler-status").classList.add("label-danger");
- document.getElementById("mixer-settings-content").style.display = "none";
- }
- else {
- document.getElementById("tumbler-status").classList.add("label-success");
-
- document.getElementById("tumbler-denomination").innerText = resp.Denomination + " BTC";
- document.getElementById("tumbler-fee").innerText = resp.FeePercent + " %";
- document.getElementById("tumbling-time").innerText = Math.round((resp.CycleLengthMinutes / 60) * 10) / 10 + " hours";
-
- document.getElementById("wallet-selected").style.display = "none";
- document.getElementById("not-enough-funds-to-mix").style.display = "none";
- }
-}
-
function updateWalletContent() {
let tabs = document.getElementById("tabs");
if (tabs.childElementCount > 0) {

Add TB unrelated improvements during TB developements