Commit 9cf65ea3 authored by Jeremy Bokobza's avatar Jeremy Bokobza

Added method to get an account by name

parent f3647040
...@@ -125,6 +125,23 @@ namespace Breeze.Wallet ...@@ -125,6 +125,23 @@ namespace Breeze.Wallet
var index = unusedAccounts.Min(a => a.Index); var index = unusedAccounts.Min(a => a.Index);
return unusedAccounts.Single(a => a.Index == index); return unusedAccounts.Single(a => a.Index == index);
} }
/// <summary>
/// Gets the account matching the name passed as a parameter.
/// </summary>
/// <param name="accountName">The name of the account to get.</param>
/// <returns></returns>
/// <exception cref="System.Exception"></exception>
public HdAccount GetAccountByName(string accountName)
{
// get the account
HdAccount account = this.Accounts.SingleOrDefault(a => a.Name == accountName);
if (account == null)
{
throw new Exception($"No account with name {accountName} could be found.");
}
return account;
}
} }
/// <summary> /// <summary>
......
...@@ -210,11 +210,7 @@ namespace Breeze.Wallet ...@@ -210,11 +210,7 @@ namespace Breeze.Wallet
Wallet wallet = this.GetWalletByName(walletName); Wallet wallet = this.GetWalletByName(walletName);
// get the account // get the account
HdAccount account = wallet.AccountsRoot.Single(a => a.CoinType == coinType).Accounts.SingleOrDefault(a => a.Name == accountName); HdAccount account = wallet.AccountsRoot.Single(a => a.CoinType == coinType).GetAccountByName(accountName);
if (account == null)
{
throw new Exception($"No account with name {accountName} could be found.");
}
// validate address creation // validate address creation
if (account.ExternalAddresses.Any()) if (account.ExternalAddresses.Any())
......
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