Commit dd82a8e6 authored by Dan Gershony's avatar Dan Gershony

Remove the hardcoded CoinType

parent 3dc33b09
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.1" /> <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" /> <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="1.1.1" /> <PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="1.1.1" />
<PackageReference Include="Stratis.Bitcoin" Version="1.0.1.5-alpha" /> <PackageReference Include="Stratis.Bitcoin" Version="1.0.1.6-alpha" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="1.0.0-rc3" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="1.0.0-rc3" />
<PackageReference Include="System.Reactive" Version="3.1.1" /> <PackageReference Include="System.Reactive" Version="3.1.1" />
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" /> <PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="1.1.1" /> <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.1" /> <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.1" />
<PackageReference Include="Stratis.Bitcoin" Version="1.0.1.5-alpha" /> <PackageReference Include="Stratis.Bitcoin" Version="1.0.1.6-alpha" />
</ItemGroup> </ItemGroup>
</Project> </Project>
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="ConcurrentHashSet" Version="1.0.1" /> <PackageReference Include="ConcurrentHashSet" Version="1.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="1.0.3" /> <PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="1.0.3" />
<PackageReference Include="Stratis.Bitcoin" Version="1.0.1.5-alpha" /> <PackageReference Include="Stratis.Bitcoin" Version="1.0.1.6-alpha" />
</ItemGroup> </ItemGroup>
</Project> </Project>
...@@ -16,30 +16,6 @@ namespace Breeze.Wallet ...@@ -16,30 +16,6 @@ namespace Breeze.Wallet
return chain.Tip.Header.BlockTime.ToUnixTimeSeconds() > (DateTimeOffset.Now.ToUnixTimeSeconds() - TimeSpan.FromHours(1).TotalSeconds); return chain.Tip.Header.BlockTime.ToUnixTimeSeconds() > (DateTimeOffset.Now.ToUnixTimeSeconds() - TimeSpan.FromHours(1).TotalSeconds);
} }
/// <summary>
/// Gets the type of the coin this chain relates to.
/// Obviously this method and how we figure out what coin we're on needs to be revisited.
/// </summary>
/// <param name="chain">The chain.</param>
/// <returns></returns>
/// <exception cref="System.Exception">No support for this coin.</exception>
public static CoinType GetCoinType(this ConcurrentChain chain)
{
uint256 genesis = chain.Genesis.Header.GetHash();
switch (genesis.ToString())
{
case "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f":
return CoinType.Bitcoin;
case "b0e511e965aeb40614ca65a1b79bd6e4e7ef299fa23e575a64b079691e9d4690":
return CoinType.Stratis;
case "000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943":
return CoinType.Testnet;
default:
throw new Exception("No support for this coin.");
}
}
/// <summary> /// <summary>
/// Gets the height of the first block created after this date. /// Gets the height of the first block created after this date.
/// </summary> /// </summary>
......
...@@ -22,13 +22,13 @@ namespace Breeze.Wallet ...@@ -22,13 +22,13 @@ namespace Breeze.Wallet
private readonly BlockNotification blockNotification; private readonly BlockNotification blockNotification;
private readonly CoinType coinType; private readonly CoinType coinType;
public Tracker(IWalletManager walletManager, ConcurrentChain chain, Signals signals, BlockNotification blockNotification) public Tracker(IWalletManager walletManager, ConcurrentChain chain, Signals signals, BlockNotification blockNotification, Network network)
{ {
this.walletManager = walletManager as WalletManager; this.walletManager = walletManager as WalletManager;
this.chain = chain; this.chain = chain;
this.signals = signals; this.signals = signals;
this.blockNotification = blockNotification; this.blockNotification = blockNotification;
this.coinType = chain.GetCoinType(); this.coinType = (CoinType)network.Consensus.CoinType;
} }
/// <inheritdoc /> /// <inheritdoc />
......
...@@ -35,7 +35,7 @@ namespace Breeze.Wallet ...@@ -35,7 +35,7 @@ namespace Breeze.Wallet
/// </summary> /// </summary>
public event EventHandler<TransactionFoundEventArgs> TransactionFound; public event EventHandler<TransactionFoundEventArgs> TransactionFound;
public WalletManager(ConcurrentChain chain) public WalletManager(ConcurrentChain chain, Network netwrok)
{ {
this.Wallets = new List<Wallet>(); this.Wallets = new List<Wallet>();
...@@ -45,7 +45,7 @@ namespace Breeze.Wallet ...@@ -45,7 +45,7 @@ namespace Breeze.Wallet
this.Load(this.DeserializeWallet(path)); this.Load(this.DeserializeWallet(path));
} }
this.coinType = chain.GetCoinType(); this.coinType = (CoinType)netwrok.Consensus.CoinType;
// load data in memory for faster lookups // load data in memory for faster lookups
// TODO get the coin type from somewhere else // TODO get the coin type from somewhere else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment