Fix the brainwallet functionality. (#2994)

This commit is contained in:
Gav Wood 2016-10-31 00:01:23 +01:00 committed by Arkadiy Paronyan
parent 6da02e0a7a
commit 29cdfa9061

View File

@ -15,7 +15,7 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
use keccak::Keccak256; use keccak::Keccak256;
use super::{KeyPair, Error, Generator, Secret}; use super::{KeyPair, Error, Generator};
/// Simple brainwallet. /// Simple brainwallet.
pub struct Brain(String); pub struct Brain(String);
@ -38,9 +38,9 @@ impl Generator for Brain {
match i > 16384 { match i > 16384 {
false => i += 1, false => i += 1,
true => { true => {
let result = KeyPair::from_secret(Secret::from(secret.clone())); let result = KeyPair::from_secret(secret.clone().into());
if result.is_ok() { if result.as_ref().ok().map_or(false, |r| r.address()[0] == 0) {
return result return result;
} }
}, },
} }