Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add abstract method Wallet.ChangePassword() #1552

Merged
merged 1 commit into from
Apr 11, 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
6 changes: 3 additions & 3 deletions src/neo/Wallets/NEP6/NEP6Wallet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,14 +302,14 @@ public override bool VerifyPassword(string password)
}
}

public bool ChangePassword(string password_old, string password_new)
public override bool ChangePassword(string oldPassword, string newPassword)
{
bool succeed = true;
lock (accounts)
{
Parallel.ForEach(accounts.Values, (account, state) =>
{
if (!account.ChangePasswordPrepare(password_old, password_new))
if (!account.ChangePasswordPrepare(oldPassword, newPassword))
{
state.Stop();
succeed = false;
Expand All @@ -321,7 +321,7 @@ public bool ChangePassword(string password_old, string password_new)
foreach (NEP6Account account in accounts.Values)
account.ChangePasswordCommit();
if (password != null)
password = password_new;
password = newPassword;
}
else
{
Expand Down
6 changes: 3 additions & 3 deletions src/neo/Wallets/SQLite/UserWallet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,10 @@ private void BuildDatabase()
}
}

public bool ChangePassword(string password_old, string password_new)
public override bool ChangePassword(string oldPassword, string newPassword)
{
if (!VerifyPassword(password_old)) return false;
byte[] passwordKey = password_new.ToAesKey();
if (!VerifyPassword(oldPassword)) return false;
byte[] passwordKey = newPassword.ToAesKey();
try
{
SaveStoredData("PasswordHash", passwordKey.Concat(salt).ToArray().Sha256());
Expand Down
1 change: 1 addition & 0 deletions src/neo/Wallets/Wallet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public abstract class Wallet
public abstract string Name { get; }
public abstract Version Version { get; }

public abstract bool ChangePassword(string oldPassword, string newPassword);
public abstract bool Contains(UInt160 scriptHash);
public abstract WalletAccount CreateAccount(byte[] privateKey);
public abstract WalletAccount CreateAccount(Contract contract, KeyPair key = null);
Expand Down
5 changes: 5 additions & 0 deletions tests/neo.UnitTests/Wallets/UT_Wallet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ internal class MyWallet : Wallet

Dictionary<UInt160, WalletAccount> accounts = new Dictionary<UInt160, WalletAccount>();

public override bool ChangePassword(string oldPassword, string newPassword)
{
throw new NotImplementedException();
}

public override bool Contains(UInt160 scriptHash)
{
return accounts.ContainsKey(scriptHash);
Expand Down