20 #include <ripple/app/main/Application.h>
21 #include <ripple/app/misc/NetworkOPs.h>
22 #include <ripple/app/reporting/P2pProxy.h>
23 #include <ripple/json/json_value.h>
24 #include <ripple/net/RPCErr.h>
25 #include <ripple/protocol/LedgerFormats.h>
26 #include <ripple/protocol/SField.h>
27 #include <ripple/protocol/TER.h>
28 #include <ripple/protocol/TxFormats.h>
29 #include <ripple/protocol/digest.h>
30 #include <ripple/protocol/jss.h>
31 #include <ripple/rpc/Context.h>
32 #include <ripple/rpc/Role.h>
34 #include <boost/algorithm/string.hpp>
71 auto replace = [&](
char const* oldStr,
char const* newStr) ->
std::string {
73 boost::replace_all(
out, oldStr, newStr);
77 auto contains = [&](
char const* s) ->
bool {
78 return inp.
find(s) != std::string::npos;
83 if (contains(
"256") || contains(
"160") || contains(
"128"))
84 return replace(
"UINT",
"Hash");
86 return replace(
"UINT",
"UInt");
90 {
"OBJECT",
"STObject"},
92 {
"ACCOUNT",
"AccountID"},
93 {
"LEDGERENTRY",
"LedgerEntry"},
94 {
"NOTPRESENT",
"NotPresent"},
95 {
"PATHSET",
"PathSet"},
97 {
"XCHAIN_BRIDGE",
"XChainBridge"},
100 if (
auto const& it = replacements.find(inp); it != replacements.end())
112 pos = inpToProcess.
find(
"_");
113 if (pos == std::string::npos)
114 pos = inpToProcess.
size();
116 if (token.
size() > 1)
118 boost::algorithm::to_lower(token);
119 token.
data()[0] -= (
'a' -
'A');
124 if (pos == inpToProcess.
size())
126 inpToProcess = inpToProcess.
substr(pos + 1);
136 defs_[jss::TYPES][
"Done"] = -1;
138 for (
auto const& [rawName, typeValue] :
sTypeMap)
142 defs_[jss::TYPES][typeName] = typeValue;
143 typeMap[typeValue] = typeName;
148 defs_[jss::LEDGER_ENTRY_TYPES][jss::Invalid] = -1;
152 defs_[jss::LEDGER_ENTRY_TYPES][f.getName()] = f.getType();
164 v[jss::isVLEncoded] =
false;
165 v[jss::isSerialized] =
false;
166 v[jss::isSigningField] =
false;
167 v[jss::type] =
"Unknown";
169 defs_[jss::FIELDS][i++] = a;
177 v[jss::isVLEncoded] =
false;
178 v[jss::isSerialized] =
false;
179 v[jss::isSigningField] =
false;
180 v[jss::type] =
"Unknown";
182 defs_[jss::FIELDS][i++] = a;
187 a[0U] =
"ObjectEndMarker";
190 v[jss::isVLEncoded] =
false;
191 v[jss::isSerialized] =
true;
192 v[jss::isSigningField] =
true;
193 v[jss::type] =
"STObject";
195 defs_[jss::FIELDS][i++] = a;
200 a[0U] =
"ArrayEndMarker";
203 v[jss::isVLEncoded] =
false;
204 v[jss::isSerialized] =
true;
205 v[jss::isSigningField] =
true;
206 v[jss::type] =
"STArray";
208 defs_[jss::FIELDS][i++] = a;
213 a[0U] =
"taker_gets_funded";
216 v[jss::isVLEncoded] =
false;
217 v[jss::isSerialized] =
false;
218 v[jss::isSigningField] =
false;
219 v[jss::type] =
"Amount";
221 defs_[jss::FIELDS][i++] = a;
226 a[0U] =
"taker_pays_funded";
229 v[jss::isVLEncoded] =
false;
230 v[jss::isSerialized] =
false;
231 v[jss::isSigningField] =
false;
232 v[jss::type] =
"Amount";
234 defs_[jss::FIELDS][i++] = a;
239 if (f->fieldName ==
"")
244 uint32_t type = f->fieldType;
246 innerObj[jss::nth] = f->fieldValue;
250 innerObj[jss::isVLEncoded] =
251 (type == 7U || type == 8U ||
255 innerObj[jss::isSerialized] =
256 (type < 10000 && f->fieldName !=
"hash" &&
257 f->fieldName !=
"index");
261 innerObj[jss::isSigningField] = f->shouldInclude(
false);
263 innerObj[jss::type] = typeMap[type];
266 innerArray[0U] = f->fieldName;
267 innerArray[1U] = innerObj;
269 defs_[jss::FIELDS][i++] = innerArray;
277 defs_[jss::TRANSACTION_RESULTS][terInfo.first] = code;
282 defs_[jss::TRANSACTION_TYPES][jss::Invalid] = -1;
285 defs_[jss::TRANSACTION_TYPES][f.getName()] = f.getType();
301 auto& params = context.
params;
304 if (params.isMember(jss::hash))
306 if (!params[jss::hash].isString() ||
307 !hash.
parseHex(params[jss::hash].asString()))
312 if (defs.hashMatches(hash))
335 auto const lf = proxied[jss::result][jss::info][jss::load_factor];
336 auto const vq = proxied[jss::result][jss::info][jss::validation_quorum];
337 ret[jss::info][jss::validation_quorum] = vq.
isNull() ? 1 : vq;
338 ret[jss::info][jss::load_factor] = lf.
isNull() ? 1 : lf;