ELEMENTS:
| 188 | |
| 189 | // ELEMENTS: |
| 190 | static void SidechainScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool include_hex, bool include_addresses, bool is_parent_chain) |
| 191 | { |
| 192 | const std::string prefix = is_parent_chain ? "pegout_" : ""; |
| 193 | CTxDestination address; |
| 194 | |
| 195 | out.pushKV(prefix + "asm", ScriptToAsmStr(scriptPubKey)); |
| 196 | if (include_addresses) { |
| 197 | out.pushKV(prefix + "desc", InferDescriptor(scriptPubKey, DUMMY_SIGNING_PROVIDER)->ToString()); |
| 198 | } |
| 199 | if (include_hex) out.pushKV(prefix + "hex", HexStr(scriptPubKey)); |
| 200 | |
| 201 | std::vector<std::vector<unsigned char>> solns; |
| 202 | const TxoutType type{Solver(scriptPubKey, solns)}; |
| 203 | |
| 204 | if (include_addresses && ExtractDestination(scriptPubKey, address) && type != TxoutType::PUBKEY) { |
| 205 | if (is_parent_chain) { |
| 206 | out.pushKV(prefix + "address", EncodeParentDestination(address)); |
| 207 | } else { |
| 208 | out.pushKV(prefix + "address", EncodeDestination(address)); |
| 209 | } |
| 210 | } |
| 211 | out.pushKV(prefix + "type", GetTxnOutputType(type)); |
| 212 | } |
| 213 | |
| 214 | // TODO: from v23 ("addresses" and "reqSigs" deprecated) this method should be refactored to remove the `include_addresses` option |
| 215 | // this method can also be combined with `ScriptToUniv` as they will overlap |
no test coverage detected