Additional RPCs for password management (#2779)

* Add personal_testPassword and stub for personal_changePassword

* Add change-password functionality.

* Address grumble.

* Update tests.

* Update build.
This commit is contained in:
Gav Wood
2016-10-22 14:24:02 +01:00
committed by GitHub
parent 7bd37e3972
commit 37a2ee98de
3 changed files with 53 additions and 2 deletions

View File

@@ -265,6 +265,20 @@ impl AccountProvider {
Ok(())
}
/// Returns `true` if the password for `account` is `password`. `false` if not.
pub fn test_password(&self, account: &Address, password: String) -> Result<bool, Error> {
match self.sstore.sign(&account, &password, &Default::default()) {
Ok(_) => Ok(true),
Err(SSError::InvalidPassword) => Ok(false),
Err(e) => Err(Error::SStore(e)),
}
}
/// Changes the password of `account` from `password` to `new_password`. Fails if incorrect `password` given.
pub fn change_password(&self, account: &Address, password: String, new_password: String) -> Result<(), Error> {
self.sstore.change_password(&account, &password, &new_password).map_err(Error::SStore)
}
/// Helper method used for unlocking accounts.
fn unlock_account(&self, account: Address, password: String, unlock: Unlock) -> Result<(), Error> {
// verify password by signing dump message