diff --git a/src/xrpld/app/main/Main.cpp b/src/xrpld/app/main/Main.cpp index 059d9758d39..0ee0efa9f6d 100644 --- a/src/xrpld/app/main/Main.cpp +++ b/src/xrpld/app/main/Main.cpp @@ -176,6 +176,7 @@ printHelp(const po::options_description& desc) " sign_for " "[offline]\n" " stop\n" + " simulate [|] []\n" " submit |[ ]\n" " submit_multisigned \n" " tx \n" diff --git a/src/xrpld/net/detail/RPCCall.cpp b/src/xrpld/net/detail/RPCCall.cpp index 533878ab1b0..15fa38be0c9 100644 --- a/src/xrpld/net/detail/RPCCall.cpp +++ b/src/xrpld/net/detail/RPCCall.cpp @@ -924,6 +924,37 @@ class RPCParser return rpcError(rpcINVALID_PARAMS); } + // simulate any transaction on the network + // + // simulate [binary] + // simulate [binary] + Json::Value + parseSimulate(Json::Value const& jvParams) + { + Json::Value txJSON; + Json::Reader reader; + Json::Value jvRequest{Json::objectValue}; + + if (!jvParams[0u].isString()) + return rpcError(rpcINVALID_PARAMS); + if (reader.parse(jvParams[0u].asString(), txJSON)) + { + jvRequest[jss::tx_json] = txJSON; + } + else + { + jvRequest[jss::tx_blob] = jvParams[0u].asString(); + } + if (jvParams.size() == 2) + { + if (!jvParams[1u].isString() || jvParams[1u].asString() != "binary") + return rpcError(rpcINVALID_PARAMS); + jvRequest[jss::binary] = true; + } + + return jvRequest; + } + // sign/submit any transaction to the network // // sign offline @@ -1244,6 +1275,7 @@ class RPCParser {"sign", &RPCParser::parseSignSubmit, 2, 3}, {"sign_for", &RPCParser::parseSignFor, 3, 4}, {"stop", &RPCParser::parseAsIs, 0, 0}, + {"simulate", &RPCParser::parseSimulate, 1, 2}, {"submit", &RPCParser::parseSignSubmit, 1, 3}, {"submit_multisigned", &RPCParser::parseSubmitMultiSigned, 1, 1}, {"transaction_entry", &RPCParser::parseTransactionEntry, 2, 2},