Crate kyoto

Crate kyoto 

Source
Expand description

Kyoto is a conservative, private, and vetted Bitcoin client built in accordance with the BIP157 and BIP158 standards. Conservative, as in Kyoto makes very little assumptions about the underlying memory requirements of the device running the software. Private, as in the Bitcoin nodes that serve Kyoto nodes 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 kyoto::{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()
        .unwrap();
    // 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.
db
Traits and structures that define the data persistence required for 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.
BlockFilter
A block filter, as described by BIP 158.
BlockHash
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.
HeaderCheckpoint
A known block hash in the chain of most work.
IndexedBlock
A Bitcoin Block with associated height.
IndexedFilter
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.
PeerTimeoutConfig
Configuration for peer connection timeouts
Progress
The progress of the node during the block filter download process.
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.
ServiceFlags
Flags to indicate which network services a node supports.
SqliteHeaderDb
Header storage implementation with SQL Lite.
SqlitePeerDb
Structure to create a SQL Lite backend to store peers.
SyncUpdate
The node has synced to a new tip of the chain.
Transaction
Bitcoin transaction.
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.

Enums§

AddrV2
Supported networks for use in BIP155 addrv2 message
ClientError
Errors occuring 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.
NodeError
Errors that prevent the node from running.
PeerStoreSizeConfig
Configure how many peers will be stored.
RejectReason
message rejection reason as a code
TxBroadcastPolicy
The strategy for how this transaction should be shared with the network.
Warning
Warnings a node may issue while running.

Traits§

HeaderStore
Methods required to persist the chain of block headers.
PeerStore
Methods that define a list of peers on the Bitcoin P2P network.

Functions§

lookup_host
Query a Bitcoin DNS seeder using the configured resolver.