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# Per-Peer Message Capture3## Purpose5This feature allows for message capture on a per-peer basis. It answers the simple question: "Can I see what messages my node is sending and receiving?"7## Usage and Functionality9* Run `bitcoind` with the `-capturemessages` option.10* Look in the `message_capture` folder in your datadir.11* Typically this will be `~/.bitcoin/message_capture`.12* See that there are many folders inside, one for each peer names with its IP address and port.13* Inside each peer's folder there are two `.dat` files: one is for received messages (`msgs_recv.dat`) and the other is for sent messages (`msgs_sent.dat`).14* Run `contrib/message-capture/message-capture-parser.py` with the proper arguments.15* See the `-h` option for help.16* To see all messages, both sent and received, for all peers use:17```18./contrib/message-capture/message-capture-parser.py -o out.json \19~/.bitcoin/message_capture/**/*.dat20```21* Note: The messages in the given `.dat` files will be interleaved in chronological order. So, giving both received and sent `.dat` files (as above with `*.dat`) will result in all messages being interleaved in chronological order.22* If an output file is not provided (i.e. the `-o` option is not used), then the output prints to `stdout`.23* View the resulting output.24* The output file is `JSON` formatted.25* Suggestion: use `jq` to view the output, with `jq . out.json`
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.