From 320f6f955d7f5f0d961b5a756c09ed80229e28b9 Mon Sep 17 00:00:00 2001 From: Erik Zhang Date: Wed, 31 Jan 2018 18:25:03 +0800 Subject: [PATCH] enhancement/userwallet (#106) * allow users to create db3 wallet * update dependency: Neo v2.7.1 --- neo-cli/Shell/MainService.cs | 37 ++++++++++++++++++++++++------------ neo-cli/neo-cli.csproj | 4 ++-- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/neo-cli/Shell/MainService.cs b/neo-cli/Shell/MainService.cs index 944bb7748..fd96d487c 100644 --- a/neo-cli/Shell/MainService.cs +++ b/neo-cli/Shell/MainService.cs @@ -140,11 +140,6 @@ private bool OnCreateWalletCommand(string[] args) return true; } string path = args[2]; - if (Path.GetExtension(path) == ".db3") - { - Console.WriteLine("Wallet files in db3 format are not supported, please use a .json file extension."); - return true; - } string password = ReadPassword("password"); if (password.Length == 0) { @@ -157,13 +152,31 @@ private bool OnCreateWalletCommand(string[] args) Console.WriteLine("error"); return true; } - NEP6Wallet wallet = new NEP6Wallet(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()}"); + switch (Path.GetExtension(path)) + { + case ".db3": + { + Program.Wallet = UserWallet.Create(path, password); + WalletAccount account = Program.Wallet.CreateAccount(); + Console.WriteLine($"address: {account.Address}"); + Console.WriteLine($" pubkey: {account.GetKey().PublicKey.EncodePoint(true).ToHexString()}"); + } + break; + case ".json": + { + NEP6Wallet wallet = new NEP6Wallet(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; } diff --git a/neo-cli/neo-cli.csproj b/neo-cli/neo-cli.csproj index 5ae136a65..2b8fdf817 100644 --- a/neo-cli/neo-cli.csproj +++ b/neo-cli/neo-cli.csproj @@ -3,7 +3,7 @@ 2016-2017 The Neo Project Neo.CLI - 2.7.0 + 2.7.1 The Neo Project netcoreapp2.0 neo-cli @@ -28,7 +28,7 @@ - +