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

Function ScriptPubKeyToJSON

src/rpcrawtransaction.cpp:33–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31using namespace std;
32
33void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex)
34{
35 txnouttype type;
36 vector<CTxDestination> addresses;
37 int nRequired;
38
39 out.push_back(Pair("asm", ScriptToAsmStr(scriptPubKey)));
40 if (fIncludeHex)
41 out.push_back(Pair("hex", HexStr(scriptPubKey.begin(), scriptPubKey.end())));
42
43 if (!ExtractDestinations(scriptPubKey, type, addresses, nRequired)) {
44 out.push_back(Pair("type", GetTxnOutputType(type)));
45 return;
46 }
47
48 out.push_back(Pair("reqSigs", nRequired));
49 out.push_back(Pair("type", GetTxnOutputType(type)));
50
51 UniValue a(UniValue::VARR);
52 BOOST_FOREACH(const CTxDestination& addr, addresses)
53 a.push_back(CBitcoinAddress(addr).ToString());
54 out.push_back(Pair("addresses", a));
55}
56
57void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry)
58{

Callers 4

gettxoutFunction · 0.85
BOOST_FOREACHFunction · 0.85
TxToJSONFunction · 0.85
decodescriptFunction · 0.85

Calls 10

PairFunction · 0.85
ScriptToAsmStrFunction · 0.85
HexStrFunction · 0.85
ExtractDestinationsFunction · 0.85
GetTxnOutputTypeFunction · 0.85
CBitcoinAddressClass · 0.85
push_backMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected