Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Commit

Permalink
Backup Wallet on change password (#578)
Browse files Browse the repository at this point in the history
* backup wallet  on changepass

* move backup to cli

* case

* update nuget

Co-authored-by: Shargon <shargon@gmail.com>
Co-authored-by: Owen Zhang <38493437+superboyiii@users.noreply.github.com>
  • Loading branch information
3 people authored May 7, 2020
1 parent b96017f commit abc9f2d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions neo-cli/CLI/MainService.Wallet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,25 @@ private void OnChangePasswordCommand()
return;
}

if (CurrentWallet is NEP6Wallet wallet)
{
string backupFile = wallet.Path + ".bak";
if (!File.Exists(wallet.Path) || File.Exists(backupFile))
{
Console.WriteLine("Wallet backup fail");
return;
}
try
{
File.Copy(wallet.Path, backupFile);
}
catch (IOException)
{
Console.WriteLine("Wallet backup fail");
return;
}
}

bool succeed = CurrentWallet.ChangePassword(oldPassword, newPassword);
if (succeed)
{
Expand Down
2 changes: 1 addition & 1 deletion neo-cli/neo-cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Neo" Version="3.0.0-CI00906" />
<PackageReference Include="Neo" Version="3.0.0-CI00907" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit abc9f2d

Please sign in to comment.