| 43 | using namespace std; |
| 44 | |
| 45 | void 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 | |
| 75 | void TxToJSON(const CTransaction &tx, const int64_t txTime, const uint256 hashBlock, UniValue &entry) |
no test coverage detected