MCPcopy Create free account
hub / github.com/BitcoinUnlimited/BitcoinUnlimited / ScriptPubKeyToJSON

Function ScriptPubKeyToJSON

src/rpc/rawtransaction.cpp:45–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43using namespace std;
44
45void ScriptPubKeyToJSON(const CScript &scriptPubKey, UniValue &out, bool fIncludeHex)
46{
47 txnouttype type;
48 vector<CTxDestination> addresses;
49 int nRequired;
50 const uint32_t flags = STANDARD_SCRIPT_VERIFY_FLAGS | SCRIPT_ENABLE_P2SH_32;
51
52 out.pushKV("asm", ScriptToAsmStr(scriptPubKey));
53 if (fIncludeHex)
54 out.pushKV("hex", HexStr(scriptPubKey.begin(), scriptPubKey.end()));
55
56 if (!ExtractDestinations(scriptPubKey, type, addresses, nRequired, flags))
57 {
58 out.pushKV("type", GetTxnOutputType(type));
59 return;
60 }
61
62 out.pushKV("reqSigs", nRequired);
63 out.pushKV("type", GetTxnOutputType(type));
64
65 UniValue a(UniValue::VARR);
66 for (const CTxDestination &addr : addresses)
67 {
68 a.push_back(EncodeDestination(addr));
69 }
70
71 out.pushKV("addresses", a);
72}
73
74
75void TxToJSON(const CTransaction &tx, const int64_t txTime, const uint256 hashBlock, UniValue &entry)

Callers 4

rest_getutxosFunction · 0.85
TxToJSONFunction · 0.85
decodescriptFunction · 0.85
gettxoutFunction · 0.85

Calls 9

ScriptToAsmStrFunction · 0.85
HexStrFunction · 0.85
ExtractDestinationsFunction · 0.85
GetTxnOutputTypeFunction · 0.85
EncodeDestinationFunction · 0.85
pushKVMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected