From 8579eb0c191005022dcb20641444ab471e277f67 Mon Sep 17 00:00:00 2001 From: CJ Cobb Date: Mon, 29 Mar 2021 16:51:41 -0400 Subject: [PATCH] Maintain compatibility for forwarded RPC responses: Typically, an RPC response contains a `result` field, which contains details about the operation performed. For ease of parsing, forwarded responses must look like a non-forwarded response. In some instances the response was incorrectly composed, so that the actual `result` object would be encapsulated by an outer `result` object, breaking existing code. This commit, addresses this issue and correctly "folds" the `result` field, ensuring a consistent schema for responses. --- src/ripple/rpc/impl/ServerHandlerImp.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/ripple/rpc/impl/ServerHandlerImp.cpp b/src/ripple/rpc/impl/ServerHandlerImp.cpp index fd709507d..51e1a5ef1 100644 --- a/src/ripple/rpc/impl/ServerHandlerImp.cpp +++ b/src/ripple/rpc/impl/ServerHandlerImp.cpp @@ -904,6 +904,17 @@ ServerHandlerImp::processRequest( reply.append(std::move(r)); else reply = std::move(r); + + if (reply.isMember(jss::result) && + reply[jss::result].isMember(jss::result)) + { + reply = reply[jss::result]; + if (reply.isMember(jss::status)) + { + reply[jss::result][jss::status] = reply[jss::status]; + reply.removeMember(jss::status); + } + } } auto response = to_string(reply);