Expand description
This crate is a conservative, private, and vetted Bitcoin client built in accordance with the BIP157 and BIP158 standards. Conservative, as in this crate makes very little assumptions about the underlying memory requirements of the device running the software. Private, as in the Bitcoin nodes that serve this client data do not know what transactions the client is querying for, only the entire Bitcoin block. Vetted, as in the dependencies of the core library are meant to remain limited, rigorously tested, and absolutely necessary.
§Example usage
use bip157::{Builder, Event, Client, Network, BlockHash};
#[tokio::main]
async fn main() {
// Add third-party logging
let subscriber = tracing_subscriber::FmtSubscriber::new();
tracing::subscriber::set_global_default(subscriber).unwrap();
// Create a new node builder
let builder = Builder::new(Network::Signet);
// Add node preferences and build the node/client
let (node, client) = builder
// The number of connections we would like to maintain
.required_peers(2)
.build();
// Run the node and wait for the sync message;
tokio::task::spawn(async move { node.run().await });
// Split the client into components that send messages and listen to messages
let Client { requester, info_rx: _, warn_rx: _, mut event_rx } = client;
loop {
if let Some(event) = event_rx.recv().await {
match event {
Event::FiltersSynced(_) => {
tracing::info!("Sync complete!");
break;
},
_ => (),
}
}
}
requester.shutdown();
}
§Features
rusqlite
: use the default rusqlite
database implementations. Default and recommend feature.
Re-exports§
pub extern crate tokio;
Modules§
- builder
- Convenient way to build a compact filters node.
- chain
- Structures and checkpoints related to the blockchain.
- client
- Structures to communicate with a node.
- error
- Errors associated with a node.
- messages
- Messages the node may send a client.
- node
- The structure that communicates with the Bitcoin P2P network and collects data.
Structs§
- Address
- A Bitcoin address.
- Block
- Bitcoin block.
- Block
Filter - A block filter, as described by BIP 158.
- Block
Hash - A bitcoin block hash.
- Builder
- Build a
Node
in an additive way. - Client
- A
Client
allows for communication with a running node. - FeeRate
- Represents fee rate.
- Header
- Bitcoin block header.
- Header
Checkpoint - A known block hash in the chain of most work.
- Indexed
Block - A Bitcoin
Block
with associated height. - Indexed
Filter - A compact block filter with associated height.
- Node
- A compact block filter node. Nodes download Bitcoin block headers, block filters, and blocks to send relevant events to a client.
- Progress
- The progress of the node during the block filter download process.
- Receiver
- Receives values from the associated
Sender
. - Reject
Payload - An attempt to broadcast a transaction failed.
- Requester
- Send messages to a node that is running so the node may complete a task.
- Script
Buf - An owned, growable script.
- Service
Flags - Flags to indicate which network services a node supports.
- Sync
Update - The node has synced to a new tip of the chain.
- Transaction
- Bitcoin transaction.
- Trusted
Peer - A peer on the Bitcoin P2P network
- TxBroadcast
- Broadcast a
Transaction
to a set of connected peers. - Unbounded
Receiver - Receive values from the associated
UnboundedSender
. - Wtxid
- A bitcoin witness transaction ID.
Enums§
- AddrV2
- Supported networks for use in BIP155 addrv2 message
- Client
Error - Errors occurring when the client is talking to the node.
- Event
- Data and structures useful for a consumer, such as a wallet.
- Info
- Informational messages emitted by a node
- Network
- The cryptocurrency network to act on.
- Node
Error - Errors that prevent the node from running.
- Reject
Reason - message rejection reason as a code
- TxBroadcast
Policy - The strategy for how this transaction should be shared with the network.
- Warning
- Warnings a node may issue while running.
Functions§
- lookup_
host - Query a Bitcoin DNS seeder.