* Serialize spent outputs as a list of per-transaction CTxOut lists using JSON format. */
| 293 | * Serialize spent outputs as a list of per-transaction CTxOut lists using JSON format. |
| 294 | */ |
| 295 | static void BlockUndoToJSON(const CBlockUndo& block_undo, UniValue& result) |
| 296 | { |
| 297 | result.push_back({UniValue::VARR}); // block_undo.vtxundo doesn't contain coinbase tx |
| 298 | for (const CTxUndo& tx_undo : block_undo.vtxundo) { |
| 299 | UniValue tx_prevouts(UniValue::VARR); |
| 300 | for (const Coin& coin : tx_undo.vprevout) { |
| 301 | UniValue prevout(UniValue::VOBJ); |
| 302 | prevout.pushKV("value", ValueFromAmount(coin.out.nValue)); |
| 303 | |
| 304 | UniValue script_pub_key(UniValue::VOBJ); |
| 305 | ScriptToUniv(coin.out.scriptPubKey, /*out=*/script_pub_key, /*include_hex=*/true, /*include_address=*/true); |
| 306 | prevout.pushKV("scriptPubKey", std::move(script_pub_key)); |
| 307 | |
| 308 | tx_prevouts.push_back(std::move(prevout)); |
| 309 | } |
| 310 | result.push_back(std::move(tx_prevouts)); |
| 311 | } |
| 312 | } |
| 313 | |
| 314 | static bool rest_spent_txouts(const std::any& context, HTTPRequest* req, const std::string& uri_part) |
| 315 | { |
no test coverage detected