Crates.io | pushtx |
lib.rs | pushtx |
version | 0.4.0 |
source | src |
created_at | 2024-05-21 12:27:05.56938 |
updated_at | 2024-06-03 02:42:41.004361 |
description | Bitcoin Transaction Broadcast Library |
homepage | |
repository | https://github.com/alfred-hodler/pushtx |
max_upload_size | |
id | 1246801 |
size | 102,019 |
This is a Rust crate that broadcasts Bitcoin transactions directly into the P2P network by connecting to a set of random Bitcoin nodes. This differs from other broadcast tools in that it does not not interact with any centralized services, such as block explorers.
The library is entirely self-contained and does not require Bitcoin Core or other dependencies.
If Tor is running on the same system, connectivity to the P2P network is established through a newly created circuit. Having Tor Browser running in the background is sufficient. Tor daemon also works.
// this is our hex-encoded transaction that we want to parse and broadcast
let tx = "6afcc7949dd500000....".parse().unwrap();
// we start the broadcast process and acquire a receiver to the info events
let receiver = pushtx::broadcast(vec![tx], pushtx::Opts::default());
// start reading info events until `Done` is received
loop {
match receiver.recv().unwrap() {
pushtx::Info::Done(Ok(report)) => {
println!("{} transactions broadcast successfully", report.success.len());
break;
}
pushtx::Info::Done(Err(err)) => {
println!("we failed to broadcast to any peers, reason = {err}");
break;
}
_ => {}
}
}
An executable is also available (pushtx-cli
).
This project comes with no warranty whatsoever. Please refer to the license for details.