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

Function SidechainScriptPubKeyToJSON

src/core_write.cpp:190–212  ·  view source on GitHub ↗

ELEMENTS:

Source from the content-addressed store, hash-verified

188
189// ELEMENTS:
190static void SidechainScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool include_hex, bool include_addresses, bool is_parent_chain)
191{
192 const std::string prefix = is_parent_chain ? "pegout_" : "";
193 CTxDestination address;
194
195 out.pushKV(prefix + "asm", ScriptToAsmStr(scriptPubKey));
196 if (include_addresses) {
197 out.pushKV(prefix + "desc", InferDescriptor(scriptPubKey, DUMMY_SIGNING_PROVIDER)->ToString());
198 }
199 if (include_hex) out.pushKV(prefix + "hex", HexStr(scriptPubKey));
200
201 std::vector<std::vector<unsigned char>> solns;
202 const TxoutType type{Solver(scriptPubKey, solns)};
203
204 if (include_addresses && ExtractDestination(scriptPubKey, address) && type != TxoutType::PUBKEY) {
205 if (is_parent_chain) {
206 out.pushKV(prefix + "address", EncodeParentDestination(address));
207 } else {
208 out.pushKV(prefix + "address", EncodeDestination(address));
209 }
210 }
211 out.pushKV(prefix + "type", GetTxnOutputType(type));
212}
213
214// TODO: from v23 ("addresses" and "reqSigs" deprecated) this method should be refactored to remove the `include_addresses` option
215// this method can also be combined with `ScriptToUniv` as they will overlap

Callers 1

ScriptPubKeyToUnivFunction · 0.85

Calls 10

ScriptToAsmStrFunction · 0.85
InferDescriptorFunction · 0.85
SolverFunction · 0.85
ExtractDestinationFunction · 0.85
EncodeParentDestinationFunction · 0.85
EncodeDestinationFunction · 0.85
GetTxnOutputTypeFunction · 0.85
HexStrFunction · 0.50
pushKVMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected