Fix the brainwallet functionality. (#2994) (#3005)

This commit is contained in:
Arkadiy Paronyan 2016-10-31 14:07:55 +01:00 committed by Gav Wood
parent 54da6aef33
commit 93327e8c73

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;
} }
}, },
} }