1#include <test/jtx/JSONRPCClient.h> 
    3#include <xrpl/json/json_reader.h> 
    4#include <xrpl/json/to_string.h> 
    5#include <xrpl/protocol/jss.h> 
    6#include <xrpl/server/Port.h> 
    8#include <boost/asio.hpp> 
    9#include <boost/beast/http/dynamic_body.hpp> 
   10#include <boost/beast/http/message.hpp> 
   11#include <boost/beast/http/read.hpp> 
   12#include <boost/beast/http/string_body.hpp> 
   13#include <boost/beast/http/write.hpp> 
   22    static boost::asio::ip::tcp::endpoint
 
   36            using namespace boost::asio::ip;
 
   37            if (pp.
ip && pp.
ip->is_unspecified())
 
   38                *pp.
ip = pp.
ip->is_v6() ? address{address_v6::loopback()}
 
   39                                        : address{address_v4::loopback()};
 
   42                Throw<std::runtime_error>(
"Use fixConfigPorts with auto ports");
 
   46        Throw<std::runtime_error>(
"Missing HTTP port");
 
 
   50    template <
class ConstBufferSequence>
 
   57        buffer_copy(buffer(&s[0], s.
size()), b);
 
 
   61    boost::asio::ip::tcp::endpoint 
ep_;
 
   62    boost::asio::io_context 
ios_;
 
   64    boost::beast::multi_buffer 
bin_;
 
   65    boost::beast::multi_buffer 
bout_;
 
   90        using namespace boost::beast::http;
 
   92        using namespace std::string_literals;
 
   94        request<string_body> req;
 
   95        req.method(boost::beast::http::verb::post);
 
   98        req.insert(
"Content-Type", 
"application/json; charset=UTF-8");
 
  102            req.insert(
"Host", ostr.
str());
 
  106            jr[jss::method] = cmd;
 
  109                jr[jss::jsonrpc] = 
"2.0";
 
  110                jr[jss::ripplerpc] = 
"2.0";
 
  120        req.prepare_payload();
 
  123        response<dynamic_body> res;
 
  129        if (jv[
"result"].isMember(
"error"))
 
  130            jv[
"error"] = jv[
"result"][
"error"];
 
  131        if (jv[
"result"].isMember(
"status"))
 
  132            jv[
"status"] = jv[
"result"][
"status"];
 
 
 
Unserialize a JSON document into a Value.
 
bool parse(std::string const &document, Value &root)
Read a Value from a JSON document.
 
Value & append(Value const &value)
Append value to array at the end.
 
Holds unparsed configuration information.
 
bool exists(std::string const &name) const
Returns true if a section with the given name exists.
 
Section & section(std::string const &name)
Returns the section with the given name.
 
std::vector< std::string > const & values() const
Returns all the values in the section.
 
static boost::asio::ip::tcp::endpoint getEndpoint(BasicConfig const &cfg)
 
unsigned version() const override
Get RPC 1.0 or RPC 2.0.
 
~JSONRPCClient() override
 
boost::asio::io_context ios_
 
boost::asio::ip::tcp::socket stream_
 
boost::asio::ip::tcp::endpoint ep_
 
boost::beast::multi_buffer bout_
 
JSONRPCClient(Config const &cfg, unsigned rpc_version)
 
Json::Value invoke(std::string const &cmd, Json::Value const ¶ms) override
Submit a command synchronously.
 
static std::string buffer_string(ConstBufferSequence const &b)
 
boost::beast::multi_buffer bin_
 
@ arrayValue
array value (ordered list)
 
std::unique_ptr< AbstractClient > makeJSONRPCClient(Config const &cfg, unsigned rpc_version)
Returns a client using JSON-RPC over HTTP/S.
 
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
 
void parse_Port(ParsedPort &port, Section const §ion, std::ostream &log)
 
std::string to_string(base_uint< Bits, Tag > const &a)
 
std::optional< std::uint16_t > port
 
std::set< std::string, boost::beast::iless > protocol
 
std::optional< boost::asio::ip::address > ip