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, App.Network))
                        .ToArray();
                    using (var fs = File.Open(vm.WalletFile(), FileMode.Open))
                    {
                        vm._Wallet = Wallet.Load(fs);
                    }
                    wallets.Add(vm);
                }
                catch (IOException)
                {
                }
            }
            return(wallets.ToArray());
        }
Beispiel #2
0
        public MainWindowViewModel()
        {
            foreach (var wallet in WalletViewModel.Load(App.AppDir))
            {
                Wallets.Add(wallet);
                wallet.Update();
            }
            SelectedWallet = Wallets.FirstOrDefault();

            StartConnecting();
        }
Beispiel #3
0
        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();
            }
        }