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