#zmq #bitcoin #bitcoin-core

bitcoincore-zmq

Bitcoin Core ZMQ subscriber with minimal dependencies

16 stable releases

1.5.2 Aug 6, 2024
1.5.1 Jul 10, 2024
1.5.0 May 17, 2024
1.4.0 Jan 23, 2024
1.2.0 Jul 28, 2023

#3 in #bitcoin-core

Download history 3/week @ 2024-08-15 5/week @ 2024-08-22 14/week @ 2024-08-29 15/week @ 2024-09-05 18/week @ 2024-09-12 90/week @ 2024-09-19 117/week @ 2024-09-26 91/week @ 2024-10-03 65/week @ 2024-10-10 63/week @ 2024-10-17 12/week @ 2024-10-24 57/week @ 2024-10-31 44/week @ 2024-11-07 44/week @ 2024-11-14 61/week @ 2024-11-21 49/week @ 2024-11-28

208 downloads per month

MIT license

57KB
1.5K SLoC

Build and test Integration tests crates.io docs.rs

Rust Bitcoin Core ZMQ Subscriber

Usage example

fn main() {
    for msg in bitcoincore_zmq::subscribe_receiver(&["tcp://127.0.0.1:28359"]).unwrap() {
        match msg {
            Ok(msg) => println!("Received message: {msg}"),
            Err(err) => println!("Error receiving message: {err}"),
        }
    }
}

For more examples, have a look in the examples directory.

Features

  • Minimal dependencies: the 2 crates bitcoin and zmq, optionally 2 additional crates are needed for the async subscriber, async_zmq and futures-util.
  • Handles all message types from Bitcoin Core: hashblock, hashtx, block, tx and sequence.
  • Flexible: choose between blocking functions with a callback, reading from a Receiver or reading from an asynchronous Stream without locking to a specific async runtime.

Testing

Tests run on every push and pull request. Integration tests use the latest version of the 5 most recent major Bitcoin Core versions, see integration_tests.yml.

Useful resources


TODO:

  • This README
  • SequenceMessage itest
  • Easy addEventListener like functionality with help of the getzmqnotifications rpc
  • raw messages
  • zmq publisher
  • include source in message

Dependencies

~9.5MB
~127K SLoC