external_signer: remove ExternalSignerException

It's not clear why this need it's own exception class, as opposed to just
throwing std::runtime_error().
pull/826/head
fanquake 4 years ago
parent 9e0b199b97
commit c8f469c6d5
No known key found for this signature in database
GPG Key ID: 2EEB9F5CC09526C1

@ -9,6 +9,7 @@
#include <util/system.h> #include <util/system.h>
#include <external_signer.h> #include <external_signer.h>
#include <stdexcept>
#include <string> #include <string>
#include <vector> #include <vector>
@ -26,21 +27,21 @@ bool ExternalSigner::Enumerate(const std::string& command, std::vector<ExternalS
// Call <command> enumerate // Call <command> enumerate
const UniValue result = RunCommandParseJSON(command + " enumerate"); const UniValue result = RunCommandParseJSON(command + " enumerate");
if (!result.isArray()) { if (!result.isArray()) {
throw ExternalSignerException(strprintf("'%s' received invalid response, expected array of signers", command)); throw std::runtime_error(strprintf("'%s' received invalid response, expected array of signers", command));
} }
for (UniValue signer : result.getValues()) { for (UniValue signer : result.getValues()) {
// Check for error // Check for error
const UniValue& error = find_value(signer, "error"); const UniValue& error = find_value(signer, "error");
if (!error.isNull()) { if (!error.isNull()) {
if (!error.isStr()) { if (!error.isStr()) {
throw ExternalSignerException(strprintf("'%s' error", command)); throw std::runtime_error(strprintf("'%s' error", command));
} }
throw ExternalSignerException(strprintf("'%s' error: %s", command, error.getValStr())); throw std::runtime_error(strprintf("'%s' error: %s", command, error.getValStr()));
} }
// Check if fingerprint is present // Check if fingerprint is present
const UniValue& fingerprint = find_value(signer, "fingerprint"); const UniValue& fingerprint = find_value(signer, "fingerprint");
if (fingerprint.isNull()) { if (fingerprint.isNull()) {
throw ExternalSignerException(strprintf("'%s' received invalid response, missing signer fingerprint", command)); throw std::runtime_error(strprintf("'%s' received invalid response, missing signer fingerprint", command));
} }
const std::string fingerprintStr = fingerprint.get_str(); const std::string fingerprintStr = fingerprint.get_str();
// Skip duplicate signer // Skip duplicate signer

@ -8,7 +8,6 @@
#include <univalue.h> #include <univalue.h>
#include <util/system.h> #include <util/system.h>
#include <stdexcept>
#include <string> #include <string>
#include <vector> #include <vector>
@ -16,11 +15,6 @@
struct PartiallySignedTransaction; struct PartiallySignedTransaction;
class ExternalSignerException : public std::runtime_error {
public:
using std::runtime_error::runtime_error;
};
//! Enables interaction with an external signing device or service, such as //! Enables interaction with an external signing device or service, such as
//! a hardware wallet. See doc/external-signer.md //! a hardware wallet. See doc/external-signer.md
class ExternalSigner class ExternalSigner

@ -49,7 +49,7 @@ static RPCHelpMan enumeratesigners()
signer_res.pushKV("name", signer.m_name); signer_res.pushKV("name", signer.m_name);
signers_res.push_back(signer_res); signers_res.push_back(signer_res);
} }
} catch (const ExternalSignerException& e) { } catch (const std::exception& e) {
throw JSONRPCError(RPC_MISC_ERROR, e.what()); throw JSONRPCError(RPC_MISC_ERROR, e.what());
} }
UniValue result(UniValue::VOBJ); UniValue result(UniValue::VOBJ);

Loading…
Cancel
Save