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

Backup Wallet on change password #578

Merged
merged 6 commits into from
May 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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