Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions bdk-ffi/src/bdk.udl
Original file line number Diff line number Diff line change
Expand Up @@ -1119,29 +1119,6 @@ interface AddressData {
Segwit(WitnessProgram witness_program);
};

// ------------------------------------------------------------------------
// bdk-kyoto crate
// ------------------------------------------------------------------------

/// The state of the node with respect to connected peers.
[Remote]
enum NodeState {
/// Behind on block headers according to our peers.
"Behind",

/// Downloading compact block filter headers.
"HeadersSynced",

/// Scanning compact block filters.
"FilterHeadersSynced",

/// Asking for blocks with matches.
"FiltersSynced",

/// Found all known transactions to the wallet.
"TransactionsSynced"
};

// ------------------------------------------------------------------------
// bdk_wallet crate - bitcoin re-exports
// ------------------------------------------------------------------------
Expand Down
32 changes: 18 additions & 14 deletions bdk-ffi/src/kyoto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ use bdk_kyoto::kyoto::AddrV2;
use bdk_kyoto::kyoto::ScriptBuf;
use bdk_kyoto::LightClient as BDKLightClient;
use bdk_kyoto::NodeDefault;
use bdk_kyoto::NodeState;
use bdk_kyoto::Receiver;
use bdk_kyoto::RejectReason;
use bdk_kyoto::Requester;
use bdk_kyoto::ScanType as WalletScanType;
use bdk_kyoto::UnboundedReceiver;
use bdk_kyoto::UpdateSubscriber;
use bdk_kyoto::WalletExt;
Expand All @@ -30,6 +28,8 @@ use crate::FeeRate;
use crate::Update;

type LogLevel = bdk_kyoto::kyoto::LogLevel;
type NodeState = bdk_kyoto::NodeState;
type ScanType = bdk_kyoto::ScanType;

const TIMEOUT: u64 = 10;
const DEFAULT_CONNECTIONS: u8 = 2;
Expand Down Expand Up @@ -184,7 +184,7 @@ impl CbfBuilder {
let mut builder = BDKCbfBuilder::new()
.connections(self.connections)
.data_dir(path_buf)
.scan_type(self.scan_type.into())
.scan_type(self.scan_type)
.log_level(self.log_level)
.timeout_duration(Duration::from_secs(TIMEOUT))
.peers(trusted_peers);
Expand Down Expand Up @@ -401,9 +401,23 @@ pub enum LogLevel {
Warning,
}

/// The state of the node with respect to connected peers.
#[uniffi::remote(Enum)]
pub enum NodeState {
/// We are behind on block headers according to our peers.
Behind,
/// We may start downloading compact block filter headers.
HeadersSynced,
/// We may start scanning compact block filters.
FilterHeadersSynced,
/// We may start asking for blocks with matches.
FiltersSynced,
/// We found all known transactions to the wallet.
TransactionsSynced,
}
/// Sync a wallet from the last known block hash, recover a wallet from a specified height,
/// or perform an expedited block header download for a new wallet.
#[derive(Debug, Clone, Copy, Default, uniffi::Enum)]
#[uniffi::remote(Enum)]
pub enum ScanType {
/// Perform an expedited header and filter download for a new wallet.
/// If this option is not set, and the wallet has no history, the
Expand All @@ -416,16 +430,6 @@ pub enum ScanType {
Recovery { from_height: u32 },
}

impl From<ScanType> for WalletScanType {
fn from(value: ScanType) -> Self {
match value {
ScanType::New => WalletScanType::New,
ScanType::Recovery { from_height } => WalletScanType::Recovery { from_height },
ScanType::Sync => WalletScanType::Sync,
}
}
}

/// A peer to connect to over the Bitcoin peer-to-peer network.
#[derive(Clone, uniffi::Record)]
pub struct Peer {
Expand Down
2 changes: 0 additions & 2 deletions bdk-ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,4 @@ use bdk_wallet::tx_builder::ChangeSpendPolicy;
use bdk_wallet::ChangeSet;
use bdk_wallet::KeychainKind;

use bdk_kyoto::NodeState;

uniffi::include_scaffolding!("bdk");
Loading