Thanks to visit codestin.com
Credit goes to github.com

Skip to content

A tool for tapping into bitcoin-core tracepoints to extract data in realtime

License

jb55/bitcointap

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bitcointap

A rust library and cli tool for tapping into bitcoin-core tracepoints to extract data in realtime.

Status

This is currently a WORK IN PROGRESS, but it works(ish)!

  • switch from nats to mpsc channel
  • cli tool with json events
  • json logger from channel
  • event selection api
  • event selection from cli
  • rust lib docs
  • rust lib example

Usage

$ sudo bitcointap
{
  "timestamp": 1747158913,
  "timestamp_subsec_micros": 356600,
  "event": {
    "Msg": {
      "meta": {
        "peer_id": 11,
        "addr": "111.100.246.24:8333",
        "conn_type": 2,
        "command": "inv",
        "inbound": true,
        "size": 37
      },
      "msg": { "Inv": { "items": [ { "item": { "Wtx": [..] } } ] } }
    }
  }
}
{
  "timestamp": 1747158913,
  "timestamp_subsec_micros": 356608,
  "event": {
    "Msg": {
      "meta": {
        "peer_id": 11,
        "addr": "111.100.246.24:8333",
        "conn_type": 2,
        "command": "getdata",
        "inbound": false,
        "size": 37
      },
      "msg": { "Getdata": { "items": [ { "item": { "Wtx": [ ... ] } } ] } }
    }
  }
}
{
  "timestamp": 1747158913,
  "timestamp_subsec_micros": 408313,
  "event": {
    "Msg": {
      "meta": {
        "peer_id": 12,
        "addr": "bvymttfo4axni5n2lfu5y3ymhxmsmkatynmc4sthyutjujbyjft47cqd.onion:8333",
        "conn_type": 2,
        "command": "inv",
        "inbound": true,
        "size": 73
      },
      "msg": { "Inv": { "items": [ { "item": { "Wtx": [ .. ] } }, { "item": { "Wtx": [ ... ] } } ] }
      }
    }
  }
}

How it works

bitcointap is written in Rust and uses the Bitcoin Core tracepoints to extract events like received and send P2P messages, open and closed P2P connections, mempool changes, and more. This is implemented using the USDT capabilites of libbpf-rs. The Bitcoin P2P protocol messages are deserialized using rust-bitcoin.

              Tracepoints
┌───────────┐ via libbpf
│  Bitcoin  │          ┌────────────┐
│ Core Node ├──────────► bitcointap ├────────►raw data/json
└───────────┘          └────────────┘

Credits

Most of the hard work here was done by @0xb10c's peer-observer. I am simply swapping out the protobuf and nats code with json and stdout.

About

A tool for tapping into bitcoin-core tracepoints to extract data in realtime

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 96.5%
  • Rust 2.6%
  • HTML 0.8%
  • JavaScript 0.1%
  • Python 0.0%
  • Nix 0.0%