Crate bdk_kyoto

Source
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

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 a Wallet.

Structs§

FeeRate
Represents fee rate.
LightClient
A node and associated structs to send and receive events to and from the node.
Receiver
Receives values from the associated Sender.
RejectPayload
An attempt to broadcast a transaction failed.
Requester
Send messages to a node that is running so the node may complete a task.
ScriptBuf
An owned, growable script.
SyncUpdate
The node has synced to a new tip of the chain.
TrustedPeer
A peer on the Bitcoin P2P network
TxBroadcast
Broadcast a Transaction to a set of connected peers.
Txid
A bitcoin transaction hash/transaction ID.
UnboundedReceiver
Receive values from the associated UnboundedSender.
Update
An update to Wallet.
UpdateSubscriber
Interpret events from a node that is running to apply updates to an underlying wallet.

Enums§

ClientError
Errors occuring when the client is talking to the node.
Info
Informational messages emitted by a node
NodeState
The state of the node with respect to connected peers.
RejectReason
message rejection reason as a code
ScanType
How to scan compact block filters on start up.
TxBroadcastPolicy
The strategy for how this transaction should be shared with the network.
UpdateError
Errors encountered when attempting to construct a wallet update.
Warning
Warnings a node may issue while running.

Traits§

NodeBuilderExt
Build a compact block filter client and node for a specified wallet
RequesterExt
Extend the Requester functionality to work conveniently with a Wallet.
WalletExt
Extend the functionality of Wallet for interoperablility with the light client.

Type Aliases§

NodeDefault
The default node returned from the NodeBuilder.