コード例 #1
0
        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());
        }
コード例 #2
0
        public MainWindowViewModel()
        {
            foreach (var wallet in WalletViewModel.Load(AppContext.BaseDirectory))
            {
                Wallets.Add(wallet);
                wallet.Update();
            }
            SelectedWallet = Wallets.FirstOrDefault();

            StartConnecting();
        }
コード例 #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();
            }
        }