From 18d9398525ae4bf6b5d526d12b4a91a8370b394c Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sat, 15 Aug 2015 14:00:05 +0200 Subject: [PATCH] Fix --sign-tx in ethkey. --- ethkey/KeyAux.h | 17 ++++++++--------- libdevcore/FixedHash.cpp | 9 ++++++++- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/ethkey/KeyAux.h b/ethkey/KeyAux.h index d69b801bb..0dac480dc 100644 --- a/ethkey/KeyAux.h +++ b/ethkey/KeyAux.h @@ -228,17 +228,16 @@ public: { if (h128 u = fromUUID(_signKey)) return Secret(secretStore().secret(u, [&](){ return getPassword("Enter password for key: "); })); - else if (Address a = Address(_signKey)) - return keyManager().secret(a, [&](){ return getPassword("Enter password for key (hint:" + keyManager().passwordHint(a) + "): "); }); - else if (_signKey.substr(0, 6) == "brain:") + if (_signKey.substr(0, 6) == "brain:") return KeyManager::brain(_signKey.substr(6)); - else if (_signKey == "brain") + if (_signKey == "brain") return KeyManager::brain(getPassword("Enter brain wallet phrase: ")); - else - { - cerr << "Bad file, UUID and address: " << _signKey << endl; - exit(-1); - } + Address a; + DEV_IGNORE_EXCEPTIONS(a = Address(_signKey)); + if (a) + return keyManager().secret(a, [&](){ return getPassword("Enter password for key (hint:" + keyManager().passwordHint(a) + "): "); }); + cerr << "Bad file, UUID and address: " << _signKey << endl; + exit(-1); } } diff --git a/libdevcore/FixedHash.cpp b/libdevcore/FixedHash.cpp index be202b5f4..420e2bb16 100644 --- a/libdevcore/FixedHash.cpp +++ b/libdevcore/FixedHash.cpp @@ -30,7 +30,14 @@ boost::random_device dev::s_fixedHashEngine; h128 dev::fromUUID(std::string const& _uuid) { - return h128(boost::replace_all_copy(_uuid, "-", "")); + try + { + return h128(boost::replace_all_copy(_uuid, "-", "")); + } + catch (...) + { + return h128(); + } } std::string dev::toUUID(h128 const& _uuid)