Exemple #1
0
 private static Wallet OpenWallet(WalletIndexer indexer, string path, string password)
 {
     if (Path.GetExtension(path) == ".db3")
     {
         return(UserWallet.Open(indexer, path, password));
     }
     else
     {
         TERC1Wallet terc1wallet = new TERC1Wallet(indexer, path);
         terc1wallet.Unlock(password);
         return(terc1wallet);
     }
 }
Exemple #2
0
        private bool OnCreateWalletCommand(string[] args)
        {
            if (args.Length < 3)
            {
                Console.WriteLine("error");
                return(true);
            }
            string path     = args[2];
            string password = ConsoleHelper.ReadPassword("password");

            if (password.Length == 0)
            {
                Console.WriteLine("cancelled");
                return(true);
            }
            string password2 = ConsoleHelper.ReadPassword("password");

            if (password != password2)
            {
                Console.WriteLine("error");
                return(true);
            }
            switch (Path.GetExtension(path))
            {
            case ".db3":
            {
                Program.Wallet = UserWallet.Create(GetIndexer(), path, password);
                WalletAccount account = Program.Wallet.CreateAccount();
                Console.WriteLine($"address: {account.Address}");
                Console.WriteLine($" pubkey: {account.GetKey().PublicKey.EncodePoint(true).ToHexString()}");
            }
            break;

            case ".json":
            {
                TERC1Wallet wallet = new TERC1Wallet(GetIndexer(), path);
                wallet.Unlock(password);
                WalletAccount account = wallet.CreateAccount();
                wallet.Save();
                Program.Wallet = wallet;
                Console.WriteLine($"address: {account.Address}");
                Console.WriteLine($" pubkey: {account.GetKey().PublicKey.EncodePoint(true).ToHexString()}");
            }
            break;

            default:
                Console.WriteLine("Wallet files in that format are not supported, please use a .json or .db3 file extension.");
                break;
            }
            return(true);
        }