Skip to content

Commit

Permalink
add command line version
Browse files Browse the repository at this point in the history
  • Loading branch information
mvadari committed Jul 18, 2024
1 parent fa246bb commit 3fadb8d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/xrpld/app/main/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ printHelp(const po::options_description& desc)
" sign_for <signer_address> <signer_private_key> <tx_json> "
"[offline]\n"
" stop\n"
" simulate [<tx_blob>|<tx_json>] [<binary>]\n"
" submit <tx_blob>|[<private_key> <tx_json>]\n"
" submit_multisigned <tx_json>\n"
" tx <id>\n"
Expand Down
32 changes: 32 additions & 0 deletions src/xrpld/net/detail/RPCCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,37 @@ class RPCParser
return rpcError(rpcINVALID_PARAMS);
}

// simulate any transaction on the network
//
// simulate <tx_blob> [binary]
// simulate <tx_json> [binary]
Json::Value
parseSimulate(Json::Value const& jvParams)

Check warning on line 932 in src/xrpld/net/detail/RPCCall.cpp

View check run for this annotation

Codecov / codecov/patch

src/xrpld/net/detail/RPCCall.cpp#L932

Added line #L932 was not covered by tests
{
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;

Check warning on line 955 in src/xrpld/net/detail/RPCCall.cpp

View check run for this annotation

Codecov / codecov/patch

src/xrpld/net/detail/RPCCall.cpp#L955

Added line #L955 was not covered by tests
}

// sign/submit any transaction to the network
//
// sign <private_key> <json> offline
Expand Down Expand Up @@ -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},
Expand Down

0 comments on commit 3fadb8d

Please sign in to comment.