MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / BlockUndoToJSON

Function BlockUndoToJSON

src/rest.cpp:295–312  ·  view source on GitHub ↗

* Serialize spent outputs as a list of per-transaction CTxOut lists using JSON format. */

Source from the content-addressed store, hash-verified

293 * Serialize spent outputs as a list of per-transaction CTxOut lists using JSON format.
294 */
295static 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
314static bool rest_spent_txouts(const std::any& context, HTTPRequest* req, const std::string& uri_part)
315{

Callers 1

rest_spent_txoutsFunction · 0.85

Calls 4

ValueFromAmountFunction · 0.85
ScriptToUnivFunction · 0.85
pushKVMethod · 0.80
push_backMethod · 0.45

Tested by

no test coverage detected