Implement changeBump
MODIFY
HiddenWallet/HiddenWallet.API/Models/StatusResponse.cs
HiddenWallet/HiddenWallet.API/Models/StatusResponse.cs
@@ -13,5 +13,6 @@ namespace HiddenWallet.API.Models
public int TrackingHeight { get; set; }
public int ConnectedNodeCount { get; set; }
public int MemPoolTransactionCount { get; set; }
+ public int ChangeBump { get; set; }
}
}

MODIFY
HiddenWallet/HiddenWallet.API/Wrappers/WalletWrapper.cs
HiddenWallet/HiddenWallet.API/Wrappers/WalletWrapper.cs
@@ -18,6 +18,11 @@ namespace HiddenWallet.API.Wrappers
{
public class WalletWrapper
{
+#region Members
+ private int _changeBump = 0; // every time a change happens this value is bumped
+ private int _trackingHeight = 0;
+ private string _walletState = WalletState.NotStarted.ToString();
+
private string _password = null;
private WalletJob _walletJob = null;
private readonly SafeAccount _aliceAccount = new SafeAccount(1);
@@ -29,6 +34,8 @@ namespace HiddenWallet.API.Wrappers
public bool WalletExists => File.Exists(Config.WalletFilePath);
public bool IsDecrypted => !_walletJobTask.IsCompleted && _password != null;
+#endregion
+
public WalletWrapper()
{
// Loads the config file
@@ -36,6 +43,7 @@ namespace HiddenWallet.API.Wrappers
Config.Load();
}
+#region SafeOperations
public WalletCreateResponse Create(string password)
{
var safe = Safe.Create(out Mnemonic mnemonic, password, Config.WalletFilePath, Config.Network);
@@ -64,6 +72,10 @@ namespace HiddenWallet.API.Wrappers
_walletJob = new WalletJob(safe, trackDefaultSafe: false, accountsToTrack: new SafeAccount[] { _aliceAccount, _bobAccount });
_walletJobTask = _walletJob.StartAsync(_cts.Token);
+
+ _walletJob.BestHeightChanged += _walletJob_BestHeightChanged;
+ _walletJob.StateChanged += _walletJob_StateChanged;
+ _walletJob.Tracker.TrackedTransactions.CollectionChanged += TrackedTransactions_CollectionChanged;
}
}
@@ -77,8 +89,42 @@ namespace HiddenWallet.API.Wrappers
DateTimeOffset.ParseExact(creationTime, "yyyy-MM-dd", CultureInfo.InvariantCulture));
}
+ #endregion
+
+#region EventSubscriptions
+ private void TrackedTransactions_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
+ {
+ if(_changeBump >= 10000)
+ {
+ _changeBump = 0;
+ }
+ else
+ {
+ _changeBump++;
+ }
+ }
+
+ private void _walletJob_StateChanged(object sender, EventArgs e)
+ {
+ _walletState = _walletJob.State.ToString();
+ }
+
+ private void _walletJob_BestHeightChanged(object sender, EventArgs e)
+ {
+ var trackingHeight = _walletJob.BestHeight;
+ if (trackingHeight.Type == HeightType.Chain)
+ {
+ _trackingHeight = trackingHeight.Value;
+ }
+ }
+#endregion
+
public async Task EndAsync()
{
+ _walletJob.BestHeightChanged -= _walletJob_BestHeightChanged;
+ _walletJob.StateChanged -= _walletJob_StateChanged;
+ _walletJob.Tracker.TrackedTransactions.CollectionChanged -= TrackedTransactions_CollectionChanged;
+
_cts.Cancel();
await Task.WhenAll(_walletJobTask).ConfigureAwait(false);
Console.WriteLine("Graceful shut down...");
@@ -97,22 +143,19 @@ namespace HiddenWallet.API.Wrappers
}
}
- var th = 0;
- var trackingHeight = _walletJob.BestHeight;
- if (trackingHeight.Type == HeightType.Chain)
- {
- th = trackingHeight.Value;
- }
+ var th = _trackingHeight;
- var ws = _walletJob.State.ToString();
+ var ws = _walletState;
var nc = WalletJob.ConnectedNodeCount;
var mtxc = MemPoolJob.Transactions.Count;
- return new StatusResponse { HeaderHeight = hh, TrackingHeight = th, ConnectedNodeCount = nc, MemPoolTransactionCount = mtxc, WalletState = ws };
+ var cb = _changeBump;
+
+ return new StatusResponse { HeaderHeight = hh, TrackingHeight = th, ConnectedNodeCount = nc, MemPoolTransactionCount = mtxc, WalletState = ws, ChangeBump = cb };
}
- else return new StatusResponse { HeaderHeight = 0, TrackingHeight = 0, ConnectedNodeCount = 0, MemPoolTransactionCount = 0, WalletState = WalletState.NotStarted.ToString() };
+ else return new StatusResponse { HeaderHeight = 0, TrackingHeight = 0, ConnectedNodeCount = 0, MemPoolTransactionCount = 0, WalletState = WalletState.NotStarted.ToString(), ChangeBump = 0 };
}
}
}

MODIFY
HiddenWallet/HiddenWallet.GUI/HiddenWallet.GUI.njsproj
HiddenWallet/HiddenWallet.GUI/HiddenWallet.GUI.njsproj
<Content Include="app\html\decryption-phase-content.html" />
<Content Include="app\html\decryption-phase-menu.html" />
<Content Include="app\html\shutdown.html" />
+ <Content Include="app\html\wallet-content.html" />
<Content Include="app\html\wallet-menu.html" />
<Content Include="app\html\wallet-phase-tabs.html" />
<Content Include="index.html" />

ADD
HiddenWallet/HiddenWallet.GUI/app/html/wallet-content.html
HiddenWallet/HiddenWallet.GUI/app/html/wallet-content.html
MODIFY
HiddenWallet/HiddenWallet.GUI/app/js/wallet-phase.js
HiddenWallet/HiddenWallet.GUI/app/js/wallet-phase.js
@@ -26,7 +26,10 @@ function walletPhaseShow(tabItem = "") {
writeHint("Move coins between Alice and Bob only by mixing!");
walletShow('receive');
- document.getElementById("content").innerHTML = "content not implemented";
+
+ document.getElementById("before-menu-br").outerHTML = "";
+ document.getElementById("balances").innerHTML = '<h4><span class="label label-default" style="display:block;">Available: 3.123213123 BTC, Incoming: 2023.321323 BTC </span></h4>';
+ document.getElementById("content").innerHTML = "content not imlemented";
}
function walletShow(menuItem) {

MODIFY
HiddenWallet/HiddenWallet.GUI/index.html
HiddenWallet/HiddenWallet.GUI/index.html
<iframe id="wallet-menu-frame" src="app/html/wallet-menu.html" style="display:none"></iframe>
<iframe id="decryption-phase-content-frame" src="app/html/decryption-phase-content.html" style="display:none"></iframe>
<iframe id="wallet-phase-tabs-frame" src="app/html/wallet-phase-tabs.html" style="display:none"></iframe>
+ <iframe id="wallet-content-frame" src="app/html/wallet-content.html" style="display:none"></iframe>
<div id="title-bar">
<div id="title"> </div>
<div id="title-bar-btns">
<div id="below-title-bar" class="container">
<h4><span id="hint" class="label label-info"></span></h4>
<div id="tabs"> </div>
- <br />
+ <div id="balances"> </div>
+ <br id="before-menu-br" />
<div id="menu"> </div>
<hr />
<div id="content"> </div>

Implement changeBump