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/json/json_writer.h>
25 #include <ripple/net/RPCErr.h>
26 #include <ripple/protocol/LedgerFormats.h>
27 #include <ripple/protocol/SField.h>
28 #include <ripple/protocol/TER.h>
29 #include <ripple/protocol/TxFormats.h>
30 #include <ripple/protocol/digest.h>
31 #include <ripple/protocol/jss.h>
32 #include <ripple/rpc/Context.h>
33 #include <ripple/rpc/Role.h>
35 #include <boost/algorithm/string.hpp>
72 auto replace = [&](
char const* oldStr,
char const* newStr) ->
std::string {
74 boost::replace_all(
out, oldStr, newStr);
78 auto contains = [&](
char const* s) ->
bool {
79 return inp.
find(s) != std::string::npos;
84 if (contains(
"256") || contains(
"160") || contains(
"128"))
85 return replace(
"UINT",
"Hash");
87 return replace(
"UINT",
"UInt");
91 {
"OBJECT",
"STObject"},
93 {
"ACCOUNT",
"AccountID"},
94 {
"LEDGERENTRY",
"LedgerEntry"},
95 {
"NOTPRESENT",
"NotPresent"},
96 {
"PATHSET",
"PathSet"},
98 {
"XCHAIN_BRIDGE",
"XChainBridge"},
101 if (
auto const& it = replacements.find(inp); it != replacements.end())
113 pos = inpToProcess.
find(
"_");
114 if (pos == std::string::npos)
115 pos = inpToProcess.
size();
117 if (token.
size() > 1)
119 boost::algorithm::to_lower(token);
120 token.
data()[0] -= (
'a' -
'A');
125 if (pos == inpToProcess.
size())
127 inpToProcess = inpToProcess.
substr(pos + 1);
137 defs_[jss::TYPES][
"Done"] = -1;
139 for (
auto const& [rawName, typeValue] :
sTypeMap)
143 defs_[jss::TYPES][typeName] = typeValue;
144 typeMap[typeValue] = typeName;
149 defs_[jss::LEDGER_ENTRY_TYPES][jss::Invalid] = -1;
153 defs_[jss::LEDGER_ENTRY_TYPES][f.getName()] = f.getType();
165 v[jss::isVLEncoded] =
false;
166 v[jss::isSerialized] =
false;
167 v[jss::isSigningField] =
false;
168 v[jss::type] =
"Unknown";
170 defs_[jss::FIELDS][i++] = a;
178 v[jss::isVLEncoded] =
false;
179 v[jss::isSerialized] =
false;
180 v[jss::isSigningField] =
false;
181 v[jss::type] =
"Unknown";
183 defs_[jss::FIELDS][i++] = a;
188 a[0U] =
"ObjectEndMarker";
191 v[jss::isVLEncoded] =
false;
192 v[jss::isSerialized] =
true;
193 v[jss::isSigningField] =
true;
194 v[jss::type] =
"STObject";
196 defs_[jss::FIELDS][i++] = a;
201 a[0U] =
"ArrayEndMarker";
204 v[jss::isVLEncoded] =
false;
205 v[jss::isSerialized] =
true;
206 v[jss::isSigningField] =
true;
207 v[jss::type] =
"STArray";
209 defs_[jss::FIELDS][i++] = a;
214 a[0U] =
"taker_gets_funded";
217 v[jss::isVLEncoded] =
false;
218 v[jss::isSerialized] =
false;
219 v[jss::isSigningField] =
false;
220 v[jss::type] =
"Amount";
222 defs_[jss::FIELDS][i++] = a;
227 a[0U] =
"taker_pays_funded";
230 v[jss::isVLEncoded] =
false;
231 v[jss::isSerialized] =
false;
232 v[jss::isSigningField] =
false;
233 v[jss::type] =
"Amount";
235 defs_[jss::FIELDS][i++] = a;
240 if (f->fieldName ==
"")
245 uint32_t type = f->fieldType;
247 innerObj[jss::nth] = f->fieldValue;
251 innerObj[jss::isVLEncoded] =
252 (type == 7U || type == 8U ||
256 innerObj[jss::isSerialized] =
257 (type < 10000 && f->fieldName !=
"hash" &&
258 f->fieldName !=
"index");
262 innerObj[jss::isSigningField] = f->shouldInclude(
false);
264 innerObj[jss::type] = typeMap[type];
267 innerArray[0U] = f->fieldName;
268 innerArray[1U] = innerObj;
270 defs_[jss::FIELDS][i++] = innerArray;
278 defs_[jss::TRANSACTION_RESULTS][terInfo.first] = code;
283 defs_[jss::TRANSACTION_TYPES][jss::Invalid] = -1;
286 defs_[jss::TRANSACTION_TYPES][f.getName()] = f.getType();
302 auto& params = context.
params;
305 if (params.isMember(jss::hash))
307 if (!params[jss::hash].isString() ||
308 !hash.
parseHex(params[jss::hash].asString()))
313 if (defs.hashMatches(hash))
336 auto const lf = proxied[jss::result][jss::info][jss::load_factor];
337 auto const vq = proxied[jss::result][jss::info][jss::validation_quorum];
338 ret[jss::info][jss::validation_quorum] = vq.
isNull() ? 1 : vq;
339 ret[jss::info][jss::load_factor] = lf.
isNull() ? 1 : lf;