| 192 | } |
| 193 | |
| 194 | void ScriptPubKeyToUniv(const CScript &scriptPubKey, UniValue &out, |
| 195 | bool fIncludeHex) { |
| 196 | TxoutType type; |
| 197 | std::vector<CTxDestination> addresses; |
| 198 | int nRequired; |
| 199 | |
| 200 | out.pushKV("asm", ScriptToAsmStr(scriptPubKey)); |
| 201 | if (fIncludeHex) { |
| 202 | out.pushKV("hex", HexStr(scriptPubKey)); |
| 203 | } |
| 204 | |
| 205 | if (!ExtractDestinations(scriptPubKey, type, addresses, nRequired) || |
| 206 | type == TxoutType::PUBKEY) { |
| 207 | out.pushKV("type", GetTxnOutputType(type)); |
| 208 | return; |
| 209 | } |
| 210 | |
| 211 | out.pushKV("reqSigs", nRequired); |
| 212 | out.pushKV("type", GetTxnOutputType(type)); |
| 213 | |
| 214 | UniValue a(UniValue::VARR); |
| 215 | for (const CTxDestination &addr : addresses) { |
| 216 | a.push_back(EncodeDestination(addr, GetConfig())); |
| 217 | } |
| 218 | out.pushKV("addresses", a); |
| 219 | } |
| 220 | |
| 221 | void TxToUniv(const CTransaction &tx, const BlockHash &hashBlock, |
| 222 | UniValue &entry, bool include_hex, const CTxUndo *txundo, |