| 296 | } |
| 297 | |
| 298 | KeyPair KeyManager::presaleSecret(std::string const& _json, function<string(bool)> const& _password) |
| 299 | { |
| 300 | js::mValue val; |
| 301 | json_spirit::read_string(_json, val); |
| 302 | auto obj = val.get_obj(); |
| 303 | string p = _password(true); |
| 304 | if (obj["encseed"].type() == js::str_type) |
| 305 | { |
| 306 | auto encseed = fromHex(obj["encseed"].get_str()); |
| 307 | while (true) |
| 308 | { |
| 309 | KeyPair k = KeyPair::fromEncryptedSeed(&encseed, p); |
| 310 | if (obj["ethaddr"].type() == js::str_type) |
| 311 | { |
| 312 | Address a(obj["ethaddr"].get_str()); |
| 313 | Address b = k.address(); |
| 314 | if (a != b) |
| 315 | { |
| 316 | if ((p = _password(false)).empty()) |
| 317 | BOOST_THROW_EXCEPTION(PasswordUnknown()); |
| 318 | continue; |
| 319 | } |
| 320 | } |
| 321 | return k; |
| 322 | } |
| 323 | } |
| 324 | else |
| 325 | BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("encseed type is not js::str_type")); |
| 326 | } |
| 327 | |
| 328 | Addresses KeyManager::accounts() const |
| 329 | { |
no test coverage detected