Skip to content

Commit e29a4c1

Browse files
committed
refactor(kyoto): use uniffi::Remote where applicable
1 parent 807fd9f commit e29a4c1

File tree

3 files changed

+18
-39
lines changed

3 files changed

+18
-39
lines changed

bdk-ffi/src/bdk.udl

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,29 +1119,6 @@ interface AddressData {
11191119
Segwit(WitnessProgram witness_program);
11201120
};
11211121

1122-
// ------------------------------------------------------------------------
1123-
// bdk-kyoto crate
1124-
// ------------------------------------------------------------------------
1125-
1126-
/// The state of the node with respect to connected peers.
1127-
[Remote]
1128-
enum NodeState {
1129-
/// Behind on block headers according to our peers.
1130-
"Behind",
1131-
1132-
/// Downloading compact block filter headers.
1133-
"HeadersSynced",
1134-
1135-
/// Scanning compact block filters.
1136-
"FilterHeadersSynced",
1137-
1138-
/// Asking for blocks with matches.
1139-
"FiltersSynced",
1140-
1141-
/// Found all known transactions to the wallet.
1142-
"TransactionsSynced"
1143-
};
1144-
11451122
// ------------------------------------------------------------------------
11461123
// bdk_wallet crate - bitcoin re-exports
11471124
// ------------------------------------------------------------------------

bdk-ffi/src/kyoto.rs

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ use bdk_kyoto::kyoto::AddrV2;
66
use bdk_kyoto::kyoto::ScriptBuf;
77
use bdk_kyoto::LightClient as BDKLightClient;
88
use bdk_kyoto::NodeDefault;
9-
use bdk_kyoto::NodeState;
109
use bdk_kyoto::Receiver;
1110
use bdk_kyoto::RejectReason;
1211
use bdk_kyoto::Requester;
13-
use bdk_kyoto::ScanType as WalletScanType;
1412
use bdk_kyoto::UnboundedReceiver;
1513
use bdk_kyoto::UpdateSubscriber;
1614
use bdk_kyoto::WalletExt;
@@ -30,6 +28,8 @@ use crate::FeeRate;
3028
use crate::Update;
3129

3230
type LogLevel = bdk_kyoto::kyoto::LogLevel;
31+
type NodeState = bdk_kyoto::NodeState;
32+
type ScanType = bdk_kyoto::ScanType;
3333

3434
const TIMEOUT: u64 = 10;
3535
const DEFAULT_CONNECTIONS: u8 = 2;
@@ -184,7 +184,7 @@ impl CbfBuilder {
184184
let mut builder = BDKCbfBuilder::new()
185185
.connections(self.connections)
186186
.data_dir(path_buf)
187-
.scan_type(self.scan_type.into())
187+
.scan_type(self.scan_type)
188188
.log_level(self.log_level)
189189
.timeout_duration(Duration::from_secs(TIMEOUT))
190190
.peers(trusted_peers);
@@ -401,9 +401,23 @@ pub enum LogLevel {
401401
Warning,
402402
}
403403

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

419-
impl From<ScanType> for WalletScanType {
420-
fn from(value: ScanType) -> Self {
421-
match value {
422-
ScanType::New => WalletScanType::New,
423-
ScanType::Recovery { from_height } => WalletScanType::Recovery { from_height },
424-
ScanType::Sync => WalletScanType::Sync,
425-
}
426-
}
427-
}
428-
429433
/// A peer to connect to over the Bitcoin peer-to-peer network.
430434
#[derive(Clone, uniffi::Record)]
431435
pub struct Peer {

bdk-ffi/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,4 @@ use bdk_wallet::tx_builder::ChangeSpendPolicy;
9595
use bdk_wallet::ChangeSet;
9696
use bdk_wallet::KeychainKind;
9797

98-
use bdk_kyoto::NodeState;
99-
10098
uniffi::include_scaffolding!("bdk");

0 commit comments

Comments
 (0)