Expand description
§BDK Kyoto
BDK-Kyoto is an extension of Kyoto, a client-side implementation of BIP157/BIP158. These proposals define a way for users to fetch transactions privately, using compact block filters. You may want to read the specification here. Kyoto runs as a psuedo-node, sending messages over the Bitcoin peer-to-peer layer, finding new peers to connect to, and managing a light-weight database of Bitcoin block headers. As such, developing a wallet application using this crate is distinct from a typical client/server relationship. Esplora and Electrum offer proactive APIs, in that the servers will respond to events as they are requested.
In the case of running a node as a background process, the developer experience is far more reactive, in that the node may emit any number of events, and the application may respond to them. BDK-Kyoto curates these events into structures that are easily handled by BDK APIs, making integration of compact block filters easily understood.
§License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
at your option.
§Examples
If you have an existing project that leverages bdk_wallet, building the compact block filter
node and client is simple. You may construct and configure a node to integrate with your
wallet by using the BuilderExt and Builder.
use bdk_wallet::Wallet;
use bdk_wallet::bitcoin::Network;
use bdk_kyoto::builder::{Builder, BuilderExt};
use bdk_kyoto::{LightClient, ScanType};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let mut wallet = Wallet::create(RECEIVE, CHANGE)
.network(Network::Signet)
.create_wallet_no_persist()?;
let LightClient {
requester,
info_subscriber: _,
warning_subscriber: _,
mut update_subscriber,
node
} = Builder::new(Network::Signet).build_with_wallet(&wallet, ScanType::Sync)?;
tokio::task::spawn(async move { node.run().await });
loop {
let update = update_subscriber.update().await?;
wallet.apply_update(update)?;
return Ok(());
}
}Re-exports§
pub extern crate bip157;
Modules§
- builder
- Construct a
LightClientby using a reference to aWallet.
Structs§
- Block
Hash - A bitcoin block hash.
- FeeRate
- Represents fee rate.
- Header
Checkpoint - A known block hash in the chain of most work.
- Light
Client - A node and associated structs to send and receive events to and from the node.
- Node
- A compact block filter node. Nodes download Bitcoin block headers, block filters, and blocks to send relevant events to a client.
- 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.
- Trusted
Peer - A peer on the Bitcoin P2P network
- TxBroadcast
- Broadcast a
Transactionto a set of connected peers. - Unbounded
Receiver - Receive values from the associated
UnboundedSender. - Update
- An update to
Wallet. - Update
Subscriber - Interpret events from a node that is running to apply updates to an underlying wallet.
- Wtxid
- A bitcoin witness transaction ID.
Enums§
- Client
Error - Errors occurring when the client is talking to the node.
- Info
- Informational messages emitted by a node
- Reject
Reason - message rejection reason as a code
- Scan
Type - How to scan compact block filters on start up.
- TxBroadcast
Policy - The strategy for how this transaction should be shared with the network.
- Update
Error - Errors encountered when attempting to construct a wallet update.
- Warning
- Warnings a node may issue while running.
Traits§
- Builder
Ext - Build a compact block filter client and node for a specified wallet