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