20#include <xrpld/rpc/Context.h> 
   21#include <xrpld/rpc/Role.h> 
   23#include <xrpl/json/json_value.h> 
   24#include <xrpl/json/json_writer.h> 
   25#include <xrpl/protocol/LedgerFormats.h> 
   26#include <xrpl/protocol/SField.h> 
   27#include <xrpl/protocol/TER.h> 
   28#include <xrpl/protocol/TxFormats.h> 
   29#include <xrpl/protocol/digest.h> 
   30#include <xrpl/protocol/jss.h> 
   32#include <boost/algorithm/string.hpp> 
   69    auto replace = [&](
char const* oldStr, 
char const* newStr) -> 
std::string {
 
   71        boost::replace_all(
out, oldStr, newStr);
 
   75    auto contains = [&](
char const* s) -> 
bool {
 
   76        return inp.
find(s) != std::string::npos;
 
   81        if (contains(
"512") || contains(
"384") || contains(
"256") ||
 
   82            contains(
"192") || contains(
"160") || contains(
"128"))
 
   83            return replace(
"UINT", 
"Hash");
 
   85            return replace(
"UINT", 
"UInt");
 
   89        {
"OBJECT", 
"STObject"},
 
   91        {
"ACCOUNT", 
"AccountID"},
 
   92        {
"LEDGERENTRY", 
"LedgerEntry"},
 
   93        {
"NOTPRESENT", 
"NotPresent"},
 
   94        {
"PATHSET", 
"PathSet"},
 
   96        {
"XCHAIN_BRIDGE", 
"XChainBridge"},
 
   99    if (
auto const& it = replacements.find(inp); it != replacements.end())
 
  111        pos = inpToProcess.
find(
"_");
 
  112        if (pos == std::string::npos)
 
  113            pos = inpToProcess.
size();
 
  115        if (token.
size() > 1)
 
  117            boost::algorithm::to_lower(token);
 
  118            token.
data()[0] -= (
'a' - 
'A');
 
  123        if (pos == inpToProcess.
size())
 
  125        inpToProcess = inpToProcess.
substr(pos + 1);
 
 
  135    defs_[jss::TYPES][
"Done"] = -1;
 
  137    for (
auto const& [rawName, typeValue] : 
sTypeMap)
 
  141        defs_[jss::TYPES][typeName] = typeValue;
 
  142        typeMap[typeValue] = typeName;
 
  147    defs_[jss::LEDGER_ENTRY_TYPES][jss::Invalid] = -1;
 
  151        defs_[jss::LEDGER_ENTRY_TYPES][f.getName()] = f.getType();
 
  163        v[jss::isVLEncoded] = 
false;
 
  164        v[jss::isSerialized] = 
false;
 
  165        v[jss::isSigningField] = 
false;
 
  166        v[jss::type] = 
"Unknown";
 
  168        defs_[jss::FIELDS][i++] = a;
 
  176        v[jss::isVLEncoded] = 
false;
 
  177        v[jss::isSerialized] = 
false;
 
  178        v[jss::isSigningField] = 
false;
 
  179        v[jss::type] = 
"Unknown";
 
  181        defs_[jss::FIELDS][i++] = a;
 
  186        a[0U] = 
"ObjectEndMarker";
 
  189        v[jss::isVLEncoded] = 
false;
 
  190        v[jss::isSerialized] = 
true;
 
  191        v[jss::isSigningField] = 
true;
 
  192        v[jss::type] = 
"STObject";
 
  194        defs_[jss::FIELDS][i++] = a;
 
  199        a[0U] = 
"ArrayEndMarker";
 
  202        v[jss::isVLEncoded] = 
false;
 
  203        v[jss::isSerialized] = 
true;
 
  204        v[jss::isSigningField] = 
true;
 
  205        v[jss::type] = 
"STArray";
 
  207        defs_[jss::FIELDS][i++] = a;
 
  212        a[0U] = 
"taker_gets_funded";
 
  215        v[jss::isVLEncoded] = 
false;
 
  216        v[jss::isSerialized] = 
false;
 
  217        v[jss::isSigningField] = 
false;
 
  218        v[jss::type] = 
"Amount";
 
  220        defs_[jss::FIELDS][i++] = a;
 
  225        a[0U] = 
"taker_pays_funded";
 
  228        v[jss::isVLEncoded] = 
false;
 
  229        v[jss::isSerialized] = 
false;
 
  230        v[jss::isSigningField] = 
false;
 
  231        v[jss::type] = 
"Amount";
 
  233        defs_[jss::FIELDS][i++] = a;
 
  238        if (f->fieldName == 
"")
 
  243        uint32_t type = f->fieldType;
 
  245        innerObj[jss::nth] = f->fieldValue;
 
  249        innerObj[jss::isVLEncoded] =
 
  250            (type == 7U  || type == 8U  ||
 
  254        innerObj[jss::isSerialized] =
 
  255            (type < 10000 && f->fieldName != 
"hash" &&
 
  256             f->fieldName != 
"index"); 
 
  260        innerObj[jss::isSigningField] = f->shouldInclude(
false);
 
  262        innerObj[jss::type] = typeMap[type];
 
  265        innerArray[0U] = f->fieldName;
 
  266        innerArray[1U] = innerObj;
 
  268        defs_[jss::FIELDS][i++] = innerArray;
 
  276        defs_[jss::TRANSACTION_RESULTS][terInfo.first] = code;
 
  281    defs_[jss::TRANSACTION_TYPES][jss::Invalid] = -1;
 
  284        defs_[jss::TRANSACTION_TYPES][f.getName()] = f.getType();
 
 
  300    auto& params = context.
params;
 
  303    if (params.isMember(jss::hash))
 
  305        if (!params[jss::hash].isString() ||
 
  306            !hash.
parseHex(params[jss::hash].asString()))
 
  311    if (defs.hashMatches(hash))
 
 
Outputs a Value in JSON format without formatting (not human friendly).
 
std::string write(Value const &root) override
 
Value get(UInt index, Value const &defaultValue) const
If the array contains at least index+1 elements, returns the element value, otherwise returns default...
 
static std::unordered_map< int, SField const * > const & getKnownCodeToField()
 
An immutable linear range of bytes.
 
std::uint8_t const * data() const noexcept
Return a pointer to beginning of the storage.
 
constexpr bool parseHex(std::string_view sv)
Parse a hex string into a base_uint.
 
std::string translate(std::string const &inp)
 
bool hashMatches(uint256 hash) const
 
Json::Value const & get() const
 
JSON (JavaScript Object Notation).
 
@ arrayValue
array value (ordered list)
 
@ objectValue
object value (collection of name/value pairs).
 
Json::Value invalid_field_error(std::string const &name)
 
static std::string to_string(TableType type)
to_string Returns the name of a table according to its TableType.
 
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
 
static std::map< std::string, int > const sTypeMap
 
Json::Value doServerDefinitions(RPC::JsonContext &)
 
std::string to_string(base_uint< Bits, Tag > const &a)
 
std::unordered_map< TERUnderlyingType, std::pair< char const *const, char const *const > > const & transResults()
 
sha512_half_hasher::result_type sha512Half(Args const &... args)
Returns the SHA512-Half of a series of objects.