Пример #1
0
 public static NEP6Wallet Migrate(string path, string db3path, string password)
 {
     using (UserWallet wallet_old = UserWallet.Open(db3path, password))
     {
         NEP6Wallet wallet_new = new NEP6Wallet(path, wallet_old.Name);
         using (wallet_new.Unlock(password))
         {
             foreach (WalletAccount account in wallet_old.GetAccounts())
             {
                 wallet_new.CreateAccount(account.Contract, account.GetKey());
             }
         }
         return(wallet_new);
     }
 }
Пример #2
0
        public void OpenWallet(string walletPath, string password)
        {
            Wallet      wallet;
            IDisposable walletLocker;

            if (Path.GetExtension(walletPath) == ".db3")
            {
                DeprecatedWallet userWallet;
                try
                {
                    userWallet   = DeprecatedWallet.Open(walletPath, password);
                    walletLocker = null;
                }
                catch (CryptographicException)
                {
                    this.notificationService.ShowErrorNotification(Strings.PasswordIncorrect);
                    return;
                }
                wallet = userWallet;
            }
            else
            {
                var nep6Wallet = new NEP6Wallet(walletPath);
                try
                {
                    walletLocker = nep6Wallet.Unlock(password);
                }
                catch (CryptographicException)
                {
                    this.notificationService.ShowErrorNotification(Strings.PasswordIncorrect);
                    return;
                }
                wallet = nep6Wallet;
            }

            if (wallet == null)
            {
                // TODO Localise text
                this.notificationService.ShowErrorNotification("Could not open wallet! An error occurred while opening");
                return;
            }

            this.SetCurrentWallet(wallet, walletLocker);
        }