MCPcopy Create free account
hub / github.com/bitcoin-sv/bitcoin-sv / ScriptPublicKeyToJSON

Function ScriptPublicKeyToJSON

src/core_write.cpp:334–368  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

332}
333
334void ScriptPublicKeyToJSON(const CScript& scriptPubKey,
335 bool fIncludeHex,
336 ProtocolEra era,
337 CJSONWriter& entry) {
338 entry.pushK("asm");
339 entry.pushQuote();
340 ScriptToAsmStr(scriptPubKey, entry.getWriter());
341 entry.pushQuote();
342 if (fIncludeHex)
343 {
344 entry.pushK("hex");
345 entry.pushQuote();
346 HexStr(scriptPubKey.begin(), scriptPubKey.end(), entry.getWriter());
347 entry.pushQuote();
348 }
349
350 txnouttype type{};
351 std::vector<CTxDestination> addresses;
352 int nRequired{};
353 if (!ExtractDestinations(scriptPubKey, era, type, addresses, nRequired))
354 {
355 entry.pushKV("type", GetTxnOutputType(type));
356 return;
357 }
358
359 entry.pushKV("reqSigs", nRequired);
360 entry.pushKV("type", GetTxnOutputType(type));
361
362 entry.writeBeginArray("addresses");
363 for (const CTxDestination& addr : addresses )
364 {
365 entry.pushV(EncodeDestination(addr));
366 }
367 entry.writeEndArray();
368}

Callers 1

TxToJSONFunction · 0.85

Calls 13

ScriptToAsmStrFunction · 0.85
HexStrFunction · 0.85
ExtractDestinationsFunction · 0.85
GetTxnOutputTypeFunction · 0.85
EncodeDestinationFunction · 0.85
pushKMethod · 0.80
pushQuoteMethod · 0.80
writeBeginArrayMethod · 0.80
pushVMethod · 0.80
writeEndArrayMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected