From ddb5785f74ed501c06d29ae0028d55cc017d08e4 Mon Sep 17 00:00:00 2001 From: Belane Date: Sun, 3 May 2020 16:39:38 +0200 Subject: [PATCH 1/4] backup wallet on changepass --- neo-cli/CLI/MainService.Wallet.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/neo-cli/CLI/MainService.Wallet.cs b/neo-cli/CLI/MainService.Wallet.cs index 4664f9ce5..3eadbb067 100644 --- a/neo-cli/CLI/MainService.Wallet.cs +++ b/neo-cli/CLI/MainService.Wallet.cs @@ -482,6 +482,15 @@ private void OnChangePasswordCommand() return; } + if (CurrentWallet is NEP6Wallet wallet) + { + if (!wallet.Backup()) + { + Console.WriteLine("Wallet backup fail"); + return; + } + } + bool succeed = CurrentWallet.ChangePassword(oldPassword, newPassword); if (succeed) { From d93c8c0e99c376ef4d8d8a467716d924d00a417e Mon Sep 17 00:00:00 2001 From: Belane Date: Mon, 4 May 2020 13:07:40 +0200 Subject: [PATCH 2/4] move backup to cli --- neo-cli/CLI/MainService.Wallet.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/neo-cli/CLI/MainService.Wallet.cs b/neo-cli/CLI/MainService.Wallet.cs index 3eadbb067..60ef251a4 100644 --- a/neo-cli/CLI/MainService.Wallet.cs +++ b/neo-cli/CLI/MainService.Wallet.cs @@ -484,7 +484,17 @@ private void OnChangePasswordCommand() if (CurrentWallet is NEP6Wallet wallet) { - if (!wallet.Backup()) + 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; From 7adda0967e96d85ea272645e6629bae4bda837c4 Mon Sep 17 00:00:00 2001 From: Belane Date: Mon, 4 May 2020 16:14:03 +0200 Subject: [PATCH 3/4] case --- neo-cli/CLI/MainService.Wallet.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/neo-cli/CLI/MainService.Wallet.cs b/neo-cli/CLI/MainService.Wallet.cs index 60ef251a4..08ae8527e 100644 --- a/neo-cli/CLI/MainService.Wallet.cs +++ b/neo-cli/CLI/MainService.Wallet.cs @@ -484,15 +484,15 @@ private void OnChangePasswordCommand() if (CurrentWallet is NEP6Wallet wallet) { - string backupFile = wallet.path + ".bak"; - if (!File.Exists(wallet.path) || File.Exists(backupFile)) + 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); + File.Copy(wallet.Path, backupFile); } catch (IOException) { From 0a95d824c5970f524ef711848dd560ca6ee40b6a Mon Sep 17 00:00:00 2001 From: Belane Date: Wed, 6 May 2020 17:13:11 +0200 Subject: [PATCH 4/4] update nuget --- neo-cli/neo-cli.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neo-cli/neo-cli.csproj b/neo-cli/neo-cli.csproj index ae36d6481..b9bb0f8c6 100644 --- a/neo-cli/neo-cli.csproj +++ b/neo-cli/neo-cli.csproj @@ -28,7 +28,7 @@ - +