diff options
author | Andrew Chow <achow101-github@achow101.com> | 2019-08-02 18:04:02 -0400 |
---|---|---|
committer | Andrew Chow <achow101-github@achow101.com> | 2019-08-16 19:34:01 -0400 |
commit | c325f619dd071b5489989f645e42cace8eb23fb4 (patch) | |
tree | 25177eef2a597ec4bdfff5abe7782c10be5daf2f /src/rpc | |
parent | 7a960ba775a60ebcc2e830356693e3ed702b22f1 (diff) |
Return an error from descriptor Parse that gives more information about what failed
Diffstat (limited to 'src/rpc')
-rw-r--r-- | src/rpc/misc.cpp | 10 | ||||
-rw-r--r-- | src/rpc/util.cpp | 5 |
2 files changed, 9 insertions, 6 deletions
diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index d1e9682416..e48ed8db75 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -150,9 +150,10 @@ UniValue getdescriptorinfo(const JSONRPCRequest& request) RPCTypeCheck(request.params, {UniValue::VSTR}); FlatSigningProvider provider; - auto desc = Parse(request.params[0].get_str(), provider); + std::string error; + auto desc = Parse(request.params[0].get_str(), provider, error); if (!desc) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Invalid descriptor")); + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Invalid descriptor, %s", error)); } UniValue result(UniValue::VOBJ); @@ -199,9 +200,10 @@ UniValue deriveaddresses(const JSONRPCRequest& request) } FlatSigningProvider key_provider; - auto desc = Parse(desc_str, key_provider, /* require_checksum = */ true); + std::string error; + auto desc = Parse(desc_str, key_provider, error, /* require_checksum = */ true); if (!desc) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Invalid descriptor")); + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Invalid descriptor, %s", error)); } if (!desc->IsRange() && request.params.size() > 1) { diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp index de90276677..52b2b94852 100644 --- a/src/rpc/util.cpp +++ b/src/rpc/util.cpp @@ -717,9 +717,10 @@ std::vector<CScript> EvalDescriptorStringOrObject(const UniValue& scanobject, Fl throw JSONRPCError(RPC_INVALID_PARAMETER, "Scan object needs to be either a string or an object"); } - auto desc = Parse(desc_str, provider); + std::string error; + auto desc = Parse(desc_str, provider, error); if (!desc) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Invalid descriptor '%s'", desc_str)); + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Invalid descriptor '%s', %s", desc_str, error)); } if (!desc->IsRange()) { range.first = 0; |