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 NodeBuilder
.
use bdk_wallet::Wallet;
use bdk_wallet::bitcoin::Network;
use bdk_kyoto::builder::{NodeBuilder, NodeBuilderExt};
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,
log_subscriber: _,
info_subscriber: _,
warning_subscriber: _,
mut update_subscriber,
node
} = NodeBuilder::new(Network::Signet).build_with_wallet(&wallet, ScanType::New)?;
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 kyoto;
Modules§
- builder
- Construct a
LightClient
by using a reference to aWallet
.
Structs§
- FeeRate
- Represents fee rate.
- Light
Client - A node and associated structs to send and receive events to and from the node.
- 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.
- Sync
Update - The node has synced to a new tip of the chain.
- Trusted
Peer - A peer on the Bitcoin P2P network
- TxBroadcast
- Broadcast a
Transaction
to a set of connected peers. - Txid
- A bitcoin transaction hash/transaction ID.
- 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.
Enums§
- Client
Error - Errors occuring when the client is talking to the node.
- Info
- Informational messages emitted by a node
- Node
State - The state of the node with respect to connected peers.
- 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§
- Node
Builder Ext - Build a compact block filter client and node for a specified wallet
- Requester
Ext - Extend the
Requester
functionality to work conveniently with aWallet
. - Wallet
Ext - Extend the functionality of
Wallet
for interoperablility with the light client.
Type Aliases§
- Node
Default - The default node returned from the
NodeBuilder
.