{"id":19375487,"url":"https://github.com/oleonardolima/block-events","last_synced_at":"2026-05-19T14:11:15.602Z","repository":{"id":38195149,"uuid":"481029452","full_name":"oleonardolima/block-events","owner":"oleonardolima","description":"A real-time stream block events library, covering connected and disconnected blocks. This a work in progress project for Summer of Bitcoin 2022.","archived":false,"fork":false,"pushed_at":"2022-08-11T18:03:10.000Z","size":142,"stargazers_count":2,"open_issues_count":6,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-13T01:22:55.033Z","etag":null,"topics":["bdk","bitcoin","blockchain","rust","summer-of-bitcoin"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oleonardolima.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-04-13T01:30:25.000Z","updated_at":"2025-05-17T21:04:55.000Z","dependencies_parsed_at":"2022-07-12T17:12:24.871Z","dependency_job_id":null,"html_url":"https://github.com/oleonardolima/block-events","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/oleonardolima/block-events","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleonardolima%2Fblock-events","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleonardolima%2Fblock-events/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleonardolima%2Fblock-events/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleonardolima%2Fblock-events/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oleonardolima","download_url":"https://codeload.github.com/oleonardolima/block-events/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleonardolima%2Fblock-events/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279016869,"owners_count":26085884,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bdk","bitcoin","blockchain","rust","summer-of-bitcoin"],"created_at":"2024-11-10T08:39:11.466Z","updated_at":"2025-10-13T19:11:30.971Z","avatar_url":"https://github.com/oleonardolima.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Real-time stream of block events library\n\nA library for consuming and subscribing to new block events in real-time from different sources:\n - [ ] mempool.space - [WebSocket](https://mempool.space/docs/api/websocket) and [REST](https://mempool.space/docs/api/rest) APIs (under development)\n - [ ] bitcoin core RPC `#TODO`\n - [ ] bitcoin P2P `#TODO`\n\nIt's useful for projects to get notified for connected and disconnected new blocks, currently using the following as output in async manner:\n``` rust\npub enum BlockEvent {\n    Connected(BlockExtended),\n    Disconnected((u32, BlockHash)),\n    Error(),\n}\n```\n\nCan be also used through command-line interface (CLI), as `block-explorer-cli` and just passing the network: Regtest, Signet, Testnet and Mainnet.\n\n\u003e **NOTE**: The previous implemented track-address feature and other data, such as: mempool-blocks, stats... has been deprecated and it's not refactored yet.\n## Requirements:\nTo use the library as CLI or to contribute you must have rust and cargo installed in your computer, you can check it with:\n\n``` sh\n# check rust version, it should return its version if installed\nrustc --version\n# check cargo version, it should return its version if installed\ncargo --version\n```\nIf you do not have it installed, you can follow this tutorial from [The Rust Programming Language book](https://doc.rust-lang.org/book/ch01-01-installation.html)\n\n## Compiling and using the CLI:\nTo compile and use it as a command in terminal with no need of cargo, you can use the following command:\n``` sh\n# from inside this repo\ncargo install --path .\n```\n## Examples:\n### Consuming new block events through the CLI:\n``` sh\n# testnet connection is set by default\ncargo run -- data-stream --blocks\n\n# to use regtest, you need to pass it as a parameter\ncargo run -- --base-url localhost:8999/testnet/api/v1 data-stream --blocks\n```\n### Subscribing and consuming new block events through the lib:\n``` rust\nuse anyhow::{self, Ok};\nuse futures::{pin_mut, StreamExt};\n\n#[tokio::main]\nasync fn main() -\u003e anyhow::Result\u003c()\u003e {\n    env_logger::init();\n\n    // for mempool.space testnet network\n    let http_base_url = \"http://mempool.space/testnet/api/\";\n    let ws_base_url = \"wss://mempool.space/testnet\";\n\n    // no checkpoint for this example, but you could use the following one to test it by yourself (in mainnet).\n    // checkpoint for first BDK Taproot transaction on mainnet (base_url update needed)\n    // let checkpoint = (709635, bitcoin::BlockHash::from(\"00000000000000000001f9ee4f69cbc75ce61db5178175c2ad021fe1df5bad8f\"));\n    let checkpoint = None;\n\n    // async fetch the block-events stream through the lib\n    let block_events =\n        block_events::subscribe_to_block_headers(http_base_url, ws_base_url, checkpoint).await?;\n\n    // consume and execute your code (current only matching and printing) in async manner for each new block-event\n    pin_mut!(block_events);\n    while let Some(block_event) = block_events.next().await {\n        match block_event? {\n            block_events::api::BlockEvent::Connected(block_header) =\u003e {\n                println!(\"[connected][block_header] {:#?}\", block_header);\n            }\n            block_events::api::BlockEvent::Disconnected((height, block_hash)) =\u003e {\n                println!(\n                    \"[disconnected][height: {:#?}][block_hash: {:#?}]\",\n                    height, block_hash\n                );\n            }\n        }\n    }\n    Ok(())\n}\n\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foleonardolima%2Fblock-events","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foleonardolima%2Fblock-events","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foleonardolima%2Fblock-events/lists"}