internal static WalletViewModel[] Load(string directory) { List <WalletViewModel> wallets = new List <WalletViewModel>(); foreach (var child in new DirectoryInfo(directory).GetDirectories()) { WalletViewModel vm = new WalletViewModel(); vm.Name = child.Name; try { vm.PrivateKeys = File.ReadAllText(vm.PrivateKeyFile()) .Split(',') .Select(c => new BitcoinExtKey(c, Network.Main)) .ToArray(); using (var fs = File.Open(vm.WalletFile(), FileMode.Open)) { vm._Wallet = Wallet.Load(fs); } wallets.Add(vm); } catch (IOException) { } } return(wallets.ToArray()); }
public MainWindowViewModel() { foreach (var wallet in WalletViewModel.Load(AppContext.BaseDirectory)) { Wallets.Add(wallet); wallet.Update(); } SelectedWallet = Wallets.FirstOrDefault(); StartConnecting(); }
internal async void CreateWallet(WalletCreationViewModel walletCreationViewModel) { WalletCreation creation = walletCreationViewModel.CreateWalletCreation(); Message = "Creating wallet..."; Wallet wallet = await CreateWallet(creation); Message = "Wallet created"; var walletVm = new WalletViewModel(wallet, walletCreationViewModel); Wallets.Add(walletVm); if (SelectedWallet == null) { SelectedWallet = walletVm; } walletVm.Save(); if (_ConnectionParameters != null) { wallet.Configure(_ConnectionParameters); wallet.Connect(); } }