| 31 | using namespace std; |
| 32 | |
| 33 | void 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 | |
| 57 | void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry) |
| 58 | { |
no test coverage detected