MCPcopy Create free account
hub / github.com/ElementsProject/elements / calcfastmerkleroot

Function calcfastmerkleroot

src/rpc/misc.cpp:942–974  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

940}
941
942static RPCHelpMan calcfastmerkleroot()
943{
944 return RPCHelpMan{"calcfastmerkleroot",
945 "\nhidden utility RPC for computing sha2 midstates\n",
946 {
947 {"leaves", RPCArg::Type::ARR, RPCArg::Optional::NO, "array of data to compute the fast merkle root of.",
948 {
949 {"data", RPCArg::Type::STR_HEX, RPCArg::Optional::OMITTED, "hex-encoded data"},
950 }},
951 },
952 RPCResult{
953 RPCResult::Type::STR_HEX, "", "merkle root of provided data"
954 },
955 RPCExamples{
956 HelpExampleCli("calcfastmerkleroot", "[\"a\", \"b\", \"c\"]")
957 },
958 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
959{
960 std::vector<uint256> leaves;
961 for (const UniValue& leaf : request.params[0].get_array().getValues()) {
962 uint256 l;
963 l.SetHex(leaf.get_str());
964 leaves.push_back(l);
965 }
966
967 uint256 root = ComputeFastMerkleRoot(leaves);
968
969 UniValue ret(UniValue::VOBJ);
970 ret.setStr(root.GetHex());
971 return ret;
972},
973 };
974}
975
976static RPCHelpMan dumpassetlabels()
977{

Callers

nothing calls this directly

Calls 6

HelpExampleCliFunction · 0.85
ComputeFastMerkleRootFunction · 0.85
setStrMethod · 0.80
SetHexMethod · 0.45
push_backMethod · 0.45
GetHexMethod · 0.45

Tested by

no test coverage detected