Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1#!/usr/bin/env bpftrace3/*5USAGE:7bpftrace contrib/tracing/log_utxos.bt9This script requires a 'bitcoind' binary compiled with eBPF support and the10'utxocache' tracepoints. By default, it's assumed that 'bitcoind' is11located in './build/bin/bitcoind'. This can be modified in the script below.13NOTE: requires bpftrace v0.12.0 or above.14*/16BEGIN17{18printf("%-7s %-71s %16s %7s %8s\n",19"OP", "Outpoint", "Value", "Height", "Coinbase");20}22/*23Attaches to the 'utxocache:add' tracepoint and prints additions to the UTXO set cache.24*/25usdt:./build/bin/bitcoind:utxocache:add26{27$txid = arg0;28$index = (uint32)arg1;29$height = (uint32)arg2;30$value = (int64)arg3;31$isCoinbase = arg4;33printf("Added ");34$p = $txid + 31;35unroll(32) {36$b = *(uint8*)$p;37printf("%02x", $b);38$p-=1;39}41printf(":%-6d %16ld %7d %s\n", $index, $value, $height, ($isCoinbase ? "Yes" : "No" ));42}44/*45Attaches to the 'utxocache:spent' tracepoint and prints spents from the UTXO set cache.46*/47usdt:./build/bin/bitcoind:utxocache:spent48{49$txid = arg0;50$index = (uint32)arg1;51$height = (uint32)arg2;52$value = (int64)arg3;53$isCoinbase = arg4;55printf("Spent ");56$p = $txid + 31;57unroll(32) {58$b = *(uint8*)$p;59printf("%02x", $b);60$p-=1;61}63printf(":%-6d %16ld %7d %s\n", $index, $value, $height, ($isCoinbase ? "Yes" : "No" ));64}66/*67Attaches to the 'utxocache:uncache' tracepoint and uncache UTXOs from the UTXO set cache.68*/69usdt:./build/bin/bitcoind:utxocache:uncache70{71$txid = arg0;72$index = (uint32)arg1;73$height = (uint32)arg2;74$value = (int64)arg3;75$isCoinbase = arg4;77printf("Uncache ");78$p = $txid + 31;79unroll(32) {80$b = *(uint8*)$p;81printf("%02x", $b);82$p-=1;83}85printf(":%-6d %16ld %7d %s\n", $index, $value, $height, ($isCoinbase ? "Yes" : "No" ));86}
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.