Progress with packaging
MODIFY
HiddenWallet/HiddenWallet.API/Controllers/WalletController.cs
HiddenWallet/HiddenWallet.API/Controllers/WalletController.cs
@@ -306,7 +306,7 @@ namespace HiddenWallet.API.Controllers
return new ObjectResult(new FailureResponse { Message = "Wrong transaction hex", Details = "" });
}
- return new ObjectResult(Global.WalletWrapper.SendTransactionAsync(tx, request.QuickSend).Result);
+ return new ObjectResult(Global.WalletWrapper.SendTransactionAsync(tx).Result);
}
catch (Exception ex)
{

MODIFY
HiddenWallet/HiddenWallet.API/HiddenWallet.API.csproj
HiddenWallet/HiddenWallet.API/HiddenWallet.API.csproj
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.1</TargetFramework>
- <RuntimeIdentifiers>win7-x64;</RuntimeIdentifiers>
+ <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;</RuntimeIdentifiers>
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="HBitcoin" Version="0.1.7.4" />
- <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
- <PackageReference Include="Microsoft.AspNetCore.Routing" Version="1.1.1" />
- <PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.1.1" />
+ <PackageReference Include="HBitcoin" Version="0.1.7.5" />
+ <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" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0" />

MODIFY
HiddenWallet/HiddenWallet.API/Models/SendTransactionRequest.cs
HiddenWallet/HiddenWallet.API/Models/SendTransactionRequest.cs
@@ -8,6 +8,5 @@ namespace HiddenWallet.API.Models
public class SendTransactionRequest
{
public string Hex { get; set; }
- public bool QuickSend { get; set; }
}
}

MODIFY
HiddenWallet/HiddenWallet.API/Program.cs
HiddenWallet/HiddenWallet.API/Program.cs
@@ -4,6 +4,10 @@ using Microsoft.AspNetCore.Hosting;
using HiddenWallet.API.Wrappers;
using System.Net.Http;
using System;
+using System.Diagnostics;
+using System.Threading.Tasks;
+using Microsoft.DotNet.PlatformAbstractions;
+using System.Runtime.InteropServices;
namespace HiddenWallet.API
{
@@ -11,12 +15,13 @@ namespace HiddenWallet.API
{
public static void Main(string[] args)
{
+ var endPoint = "http://localhost:37120/";
var alreadyRunning = false;
using (var client = new HttpClient())
{
try
{
- client.GetAsync("http://localhost:5000/api/v1/wallet/test").Wait();
+ client.GetAsync(endPoint + "api/v1/wallet/test").Wait();
alreadyRunning = true;
}
catch
@@ -27,12 +32,28 @@ namespace HiddenWallet.API
if (!alreadyRunning)
{
+ Console.WriteLine("Starting Tor process...");
+ var torPath = @"tor\Tor\tor";
+ if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ {
+ torPath = @"tor\Tor\tor.exe";
+ }
+ var torProcessStartInfo = new ProcessStartInfo(torPath)
+ {
+ Arguments = "SOCKSPort 37121 ControlPort 37122 HashedControlPassword 16:0978DBAF70EEB5C46063F3F6FD8CBC7A86DF70D2206916C1E2AE29EAF6",
+ UseShellExecute = false,
+ CreateNoWindow = true,
+ RedirectStandardOutput = true
+ };
+ Global.TorProcess = Process.Start(torProcessStartInfo);
+
Global.WalletWrapper = new WalletWrapper();
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseStartup<Startup>()
+ .UseUrls(endPoint)
.Build();
host.Run();

MODIFY
HiddenWallet/HiddenWallet.API/Wrappers/WalletWrapper.cs
HiddenWallet/HiddenWallet.API/Wrappers/WalletWrapper.cs
@@ -14,6 +14,7 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using static HBitcoin.FullBlockSpv.WalletJob;
+using DotNetTor.SocksPort;
namespace HiddenWallet.API.Wrappers
{
@@ -50,6 +51,9 @@ namespace HiddenWallet.API.Wrappers
private HistoryResponse _historyResponseAlice = new HistoryResponse();
private HistoryResponse _historyResponseBob = new HistoryResponse();
public HistoryResponse GetHistoryResponse(SafeAccount account) => account == AliceAccount ? _historyResponseAlice : _historyResponseBob;
+
+ public readonly SocksPortHandler SocksPortHandler = new SocksPortHandler("127.0.0.1", socksPort: 37121, ignoreSslCertification: true);
+ public readonly DotNetTor.ControlPort.Client ControlPortClient = new DotNetTor.ControlPort.Client("127.0.0.1", controlPort: 37122, password: "ILoveBitcoin21");
#endregion
public WalletWrapper()
@@ -85,7 +89,7 @@ namespace HiddenWallet.API.Wrappers
// it's not running yet, let's run it
_password = password;
- _walletJob = new WalletJob(safe, trackDefaultSafe: false, accountsToTrack: new SafeAccount[] { AliceAccount, BobAccount });
+ _walletJob = new WalletJob(SocksPortHandler, ControlPortClient, safe, trackDefaultSafe: false, accountsToTrack: new SafeAccount[] { AliceAccount, BobAccount });
_walletJob.StateChanged += _walletJob_StateChanged;
_walletJob.Tracker.TrackedTransactions.CollectionChanged += TrackedTransactions_CollectionChanged;
@@ -200,6 +204,7 @@ namespace HiddenWallet.API.Wrappers
public async Task EndAsync()
{
+ Console.WriteLine("Gracefully shutting down...");
if (_walletJob != null)
{
_walletJob.StateChanged -= _walletJob_StateChanged;
@@ -208,7 +213,14 @@ namespace HiddenWallet.API.Wrappers
_cts.Cancel();
await Task.WhenAll(_walletJobTask).ConfigureAwait(false);
- Console.WriteLine("Graceful shut down...");
+ if(Global.TorProcess != null)
+ {
+ if (!Global.TorProcess.HasExited)
+ {
+ Console.WriteLine("Terminating Tor process");
+ Global.TorProcess.Kill();
+ }
+ }
}
public StatusResponse GetStatusResponse()
@@ -269,9 +281,9 @@ namespace HiddenWallet.API.Wrappers
}
}
- public async Task<BaseResponse> SendTransactionAsync(Transaction tx, bool quickSend)
+ public async Task<BaseResponse> SendTransactionAsync(Transaction tx)
{
- SendTransactionResult result = await _walletJob.SendTransactionAsync(tx, quickSend).ConfigureAwait(false);
+ SendTransactionResult result = await _walletJob.SendTransactionAsync(tx).ConfigureAwait(false);
if (result.Success) return new SuccessResponse();
else return new FailureResponse { Message = result.FailingReason };

MODIFY
HiddenWallet/HiddenWallet.GUI/app/html/broadcast-transaction-window.html
HiddenWallet/HiddenWallet.GUI/app/html/broadcast-transaction-window.html
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>HiddenWallet</title>
<link rel="stylesheet" href="../../node_modules/bootstrap/dist/css/bootstrap.min.css">
+ <link rel="stylesheet" media="all" href="../../node_modules/mdi/css/materialdesignicons.min.css" />
<link rel="stylesheet" href="../css/default.css" />
</head>
<body>
<h4><span class="label label-info">Programmer nonsense:</span> </h4>
<textarea id= "transaction" rows="9" cols="76" disabled></textarea><br />
<button class="btn btn-sm btn-primary btn-inline" onclick="closeWindow()">Cancel</button>
- <button id="broadcast-button" class="btn btn-sm btn-success btn-inline" onclick="broadcastTransaction()">Broadcast</button>
+ <button id="broadcast-button" class="btn btn-sm btn-success btn-inline" onclick="broadcastTransaction()">
+ <span class="mdi mdi-tor"></span> Broadcast
+ </button>
</div>
<script src="../js/broadcast-window.js"></script>
<script src="../js/hw-client.js"></script>

MODIFY
HiddenWallet/HiddenWallet.GUI/app/html/wallet-content.html
HiddenWallet/HiddenWallet.GUI/app/html/wallet-content.html
<br /> <br />
<input type="password" id="send-password" class="form-control" placeholder="Password" />
<br />
- <button id="build-transaction-button" class="btn btn-lg btn-primary btn-block" onclick="buildTransaction()">Build Transaction</button>
+ <button id="build-transaction-button" class="btn btn-lg btn-primary btn-block" onclick="buildTransaction()">
+ <span class="mdi mdi-tor"></span> Build Transaction
+ </button>
</div>
\ No newline at end of file

MODIFY
HiddenWallet/HiddenWallet.GUI/app/js/hw-client.js
HiddenWallet/HiddenWallet.GUI/app/js/hw-client.js
function httpGetWallet(path) {
- let theUrl = "http://localhost:5000/api/v1/wallet/" + path;
+ let theUrl = "http://localhost:37120/api/v1/wallet/" + path;
let xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", theUrl, false); // false for synchronous request
xmlHttp.send(null);
@@ -7,7 +7,7 @@ function httpGetWallet(path) {
}
function httpPostWallet(path, data) {
- let theUrl = "http://localhost:5000/api/v1/wallet/" + path;
+ let theUrl = "http://localhost:37120/api/v1/wallet/" + path;
let xmlHttp = new XMLHttpRequest();
xmlHttp.open("POST", theUrl, false); // false for synchronous request
xmlHttp.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
@@ -16,7 +16,7 @@ function httpPostWallet(path, data) {
}
function httpGetWalletAsync(path, callback) {
- let theUrl = "http://localhost:5000/api/v1/wallet/" + path;
+ let theUrl = "http://localhost:37120/api/v1/wallet/" + path;
let xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
@@ -27,7 +27,7 @@ function httpGetWalletAsync(path, callback) {
}
function httpPostWalletAsync(path, data, callback) {
- let theUrl = "http://localhost:5000/api/v1/wallet/" + path;
+ let theUrl = "http://localhost:37120/api/v1/wallet/" + path;
let xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200)

MODIFY
HiddenWallet/HiddenWallet.GUI/app/js/wallet-phase.js
HiddenWallet/HiddenWallet.GUI/app/js/wallet-phase.js
@@ -214,7 +214,7 @@ function buildTransaction() {
broadcastWindow.webContents.send('broadcast-response', json);
})
}
- document.getElementById("build-transaction-button").innerHTML = "Build Transaction";
+ document.getElementById("build-transaction-button").innerHTML = '<span class="mdi mdi-tor"></span> Build Transaction';
document.getElementsByClassName("container").item(0).setAttribute("style", "pointer-events:all;");
});
}

MODIFY
HiddenWallet/HiddenWallet.GUI/index.html
HiddenWallet/HiddenWallet.GUI/index.html
<link rel="stylesheet" href="app/css/justified-nav.css">
<link rel="stylesheet" href="app/css/default.css" />
+ <link rel="stylesheet" media="all" href="node_modules/mdi/css/materialdesignicons.min.css" />
</head>
<body onload="decryptionPhaseShow(); periodicUpdate();">
<iframe id="decryption-phase-menu-frame" src="app/html/decryption-phase-menu.html" style="display:none"></iframe>

MODIFY
HiddenWallet/HiddenWallet.GUI/main.js
HiddenWallet/HiddenWallet.GUI/main.js
@@ -61,7 +61,11 @@ var apiProcess;
function startApi() {
var spawn = require('child_process').spawn;
// run server
- var apipath = path.join(__dirname, '..\\HiddenWallet.API\\bin\\dist\\win\\HiddenWallet.API.exe');
+ var apipath = path.join(__dirname, '..\\HiddenWallet.API\\bin\\dist\\win7\\HiddenWallet.API.exe');
+ if (os.platform() === 'linux') {
+ apipath = path.join(__dirname, '..//api//bin//dist//ubuntu.16.04//HiddenWallet.API')
+ }
+
apiProcess = spawn(apipath, {
detached: true
});

MODIFY
HiddenWallet/HiddenWallet.GUI/package.json
HiddenWallet/HiddenWallet.GUI/package.json
{
- "name": "hidden-wallet.gui",
+ "name": "hiddenwallet",
"version": "0.4.0",
"description": "HiddenWallet.GUI",
"main": "main.js",
"author": {
- "name": "nopara73"
+ "name": "nopara73 <adam.ficsor73@gmail.com>"
},
"devDependencies": {
- "electron": "^1.6.5",
- "electron-builder": "^17.0.1"
+ "electron": "^1.6.6",
+ "electron-builder": "^17.3.1"
},
"dependencies": {
"bootstrap": "^3.3.7",
- "electron": "^1.6.8",
- "electron-builder": "^17.1.2",
"electron-json-storage": "^3.0.5",
- "jquery": "^3.2.1"
+ "jquery": "^3.2.1",
+ "mdi": "^1.9.33"
},
"scripts": {
"start": "electron .",
"dist": "build"
},
"build": {
- "appId": "hidden-wallet",
+ "appId": "hidden.wallet",
"directories": {
"output": "../../dist"
- },
- "extraResources": {
- "from": "../HiddenWallet.API/bin/dist/",
- "to": "HiddenWallet.API/bin/dist/",
- "filter": [
- "**/*"
- ]
- },
- "mac": {
- "category": "bitcoin-wallet"
- },
- "win": {
- "target": [
- "nsis"
- ]
}
}
}

Progress with packaging