Commit a11f8eaf authored by Pieterjan Vanhoof's avatar Pieterjan Vanhoof Committed by GitHub

Merge pull request #45 from bokobza/feature/build-transaction

Retrieve coin type from DI
parents 135a3452 e83721ca
...@@ -28,12 +28,14 @@ namespace Breeze.Wallet ...@@ -28,12 +28,14 @@ namespace Breeze.Wallet
private const int WalletCreationAccountsCount = 2; private const int WalletCreationAccountsCount = 2;
private readonly CoinType coinType;
/// <summary> /// <summary>
/// Occurs when a transaction is found. /// Occurs when a transaction is found.
/// </summary> /// </summary>
public event EventHandler<TransactionFoundEventArgs> TransactionFound; public event EventHandler<TransactionFoundEventArgs> TransactionFound;
public WalletManager() public WalletManager(ConcurrentChain chain)
{ {
this.Wallets = new List<Wallet>(); this.Wallets = new List<Wallet>();
...@@ -43,10 +45,12 @@ namespace Breeze.Wallet ...@@ -43,10 +45,12 @@ namespace Breeze.Wallet
this.Load(this.DeserializeWallet(path)); this.Load(this.DeserializeWallet(path));
} }
this.coinType = chain.GetCoinType();
// 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
this.PubKeys = this.LoadKeys(CoinType.Bitcoin); this.PubKeys = this.LoadKeys(this.coinType);
this.TrackedTransactions = this.LoadTransactions(CoinType.Bitcoin); this.TrackedTransactions = this.LoadTransactions(this.coinType);
this.TransactionFound += this.OnTransactionFound; this.TransactionFound += this.OnTransactionFound;
} }
...@@ -72,14 +76,14 @@ namespace Breeze.Wallet ...@@ -72,14 +76,14 @@ namespace Breeze.Wallet
// generate multiple accounts and addresses from the get-go // generate multiple accounts and addresses from the get-go
for (int i = 0; i < WalletCreationAccountsCount; i++) for (int i = 0; i < WalletCreationAccountsCount; i++)
{ {
HdAccount account = CreateNewAccount(wallet, CoinType.Bitcoin, password); HdAccount account = CreateNewAccount(wallet, this.coinType, password);
this.CreateAddressesInAccount(account, coinNetwork, UnusedAddressesBuffer); this.CreateAddressesInAccount(account, coinNetwork, UnusedAddressesBuffer);
this.CreateAddressesInAccount(account, coinNetwork, UnusedAddressesBuffer, true); this.CreateAddressesInAccount(account, coinNetwork, UnusedAddressesBuffer, true);
} }
// save the changes to the file and add addresses to be tracked // save the changes to the file and add addresses to be tracked
this.SaveToFile(wallet); this.SaveToFile(wallet);
this.PubKeys = this.LoadKeys(CoinType.Bitcoin); this.PubKeys = this.LoadKeys(this.coinType);
this.Load(wallet); this.Load(wallet);
return mnemonic; return mnemonic;
...@@ -117,14 +121,14 @@ namespace Breeze.Wallet ...@@ -117,14 +121,14 @@ namespace Breeze.Wallet
// generate multiple accounts and addresses from the get-go // generate multiple accounts and addresses from the get-go
for (int i = 0; i < WalletRecoveryAccountsCount; i++) for (int i = 0; i < WalletRecoveryAccountsCount; i++)
{ {
HdAccount account = CreateNewAccount(wallet, CoinType.Bitcoin, password); HdAccount account = CreateNewAccount(wallet, this.coinType, password);
this.CreateAddressesInAccount(account, coinNetwork, UnusedAddressesBuffer); this.CreateAddressesInAccount(account, coinNetwork, UnusedAddressesBuffer);
this.CreateAddressesInAccount(account, coinNetwork, UnusedAddressesBuffer, true); this.CreateAddressesInAccount(account, coinNetwork, UnusedAddressesBuffer, true);
} }
// save the changes to the file and add addresses to be tracked // save the changes to the file and add addresses to be tracked
this.SaveToFile(wallet); this.SaveToFile(wallet);
this.PubKeys = this.LoadKeys(CoinType.Bitcoin); this.PubKeys = this.LoadKeys(this.coinType);
this.Load(wallet); this.Load(wallet);
return wallet; return wallet;
......
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