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

Function paramEntryToJSON

src/rpc/blockchain.cpp:105–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103}
104
105UniValue paramEntryToJSON(const DynaFedParamEntry& entry)
106{
107 UniValue result(UniValue::VOBJ);
108
109 // set the type
110 if (entry.m_serialize_type == 0) {
111 result.pushKV("type", "null");
112 } else if (entry.m_serialize_type == 1) {
113 result.pushKV("type", "compact");
114 } else if (entry.m_serialize_type == 2) {
115 result.pushKV("type", "full");
116 }
117
118 // nothing more to do for null
119 if (entry.m_serialize_type == 0) {
120 return result;
121 }
122
123 // fields all params have
124 result.pushKV("root", entry.CalculateRoot().GetHex());
125 result.pushKV("signblockscript", HexStr(entry.m_signblockscript));
126 result.pushKV("max_block_witness", (uint64_t)entry.m_signblock_witness_limit);
127
128 // add the extra root which is stored for compact and calculated for full
129 if (entry.m_serialize_type == 1) {
130 // compact
131 result.pushKV("extra_root", entry.m_elided_root.GetHex());
132 } else if (entry.m_serialize_type == 2) {
133 // full
134 result.pushKV("extra_root", entry.CalculateExtraRoot().GetHex());
135 }
136
137 // some extra fields only present on full params
138 if (entry.m_serialize_type == 2) {
139 result.pushKV("fedpeg_program", HexStr(entry.m_fedpeg_program));
140 result.pushKV("fedpegscript", HexStr(entry.m_fedpegscript));
141 UniValue result_extension(UniValue::VARR);
142 for (auto& item : entry.m_extension_space) {
143 result_extension.push_back(HexStr(item));
144 }
145 result.pushKV("extension_space", result_extension);
146 }
147
148 return result;
149}
150
151UniValue dynaParamsToJSON(const DynaFedParams& dynafed_params)
152{

Callers 1

dynaParamsToJSONFunction · 0.85

Calls 6

CalculateRootMethod · 0.80
CalculateExtraRootMethod · 0.80
HexStrFunction · 0.50
pushKVMethod · 0.45
GetHexMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected