Skip to content

Commit

Permalink
enhancement/userwallet (neo-project#106)
Browse files Browse the repository at this point in the history
* allow users to create db3 wallet

* update dependency: Neo v2.7.1
  • Loading branch information
erikzhang authored Jan 31, 2018
1 parent 5078839 commit 320f6f9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
37 changes: 25 additions & 12 deletions neo-cli/Shell/MainService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions neo-cli/neo-cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Copyright>2016-2017 The Neo Project</Copyright>
<AssemblyTitle>Neo.CLI</AssemblyTitle>
<Version>2.7.0</Version>
<Version>2.7.1</Version>
<Authors>The Neo Project</Authors>
<TargetFramework>netcoreapp2.0</TargetFramework>
<AssemblyName>neo-cli</AssemblyName>
Expand All @@ -28,7 +28,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Neo" Version="2.7.0" />
<PackageReference Include="Neo" Version="2.7.1" />
</ItemGroup>

</Project>

0 comments on commit 320f6f9

Please sign in to comment.