| 332 | } |
| 333 | |
| 334 | void ScriptPublicKeyToJSON(const CScript& scriptPubKey, |
| 335 | bool fIncludeHex, |
| 336 | ProtocolEra era, |
| 337 | CJSONWriter& entry) { |
| 338 | entry.pushK("asm"); |
| 339 | entry.pushQuote(); |
| 340 | ScriptToAsmStr(scriptPubKey, entry.getWriter()); |
| 341 | entry.pushQuote(); |
| 342 | if (fIncludeHex) |
| 343 | { |
| 344 | entry.pushK("hex"); |
| 345 | entry.pushQuote(); |
| 346 | HexStr(scriptPubKey.begin(), scriptPubKey.end(), entry.getWriter()); |
| 347 | entry.pushQuote(); |
| 348 | } |
| 349 | |
| 350 | txnouttype type{}; |
| 351 | std::vector<CTxDestination> addresses; |
| 352 | int nRequired{}; |
| 353 | if (!ExtractDestinations(scriptPubKey, era, type, addresses, nRequired)) |
| 354 | { |
| 355 | entry.pushKV("type", GetTxnOutputType(type)); |
| 356 | return; |
| 357 | } |
| 358 | |
| 359 | entry.pushKV("reqSigs", nRequired); |
| 360 | entry.pushKV("type", GetTxnOutputType(type)); |
| 361 | |
| 362 | entry.writeBeginArray("addresses"); |
| 363 | for (const CTxDestination& addr : addresses ) |
| 364 | { |
| 365 | entry.pushV(EncodeDestination(addr)); |
| 366 | } |
| 367 | entry.writeEndArray(); |
| 368 | } |
no test coverage detected