From 677a60e3667a55bd5613db9b6407f43116f3036f Mon Sep 17 00:00:00 2001 From: rustaceanrob Date: Tue, 2 Dec 2025 14:41:29 +0000 Subject: [PATCH] feat(kyoto): Add optional new wallet sync height For users recovering an old wallet, it is best to used the pre-defined points like segwit or taproot; however, new users that have definitely not used their descriptor may be caught off guard if they have to wait for their wallet to sync for more than a couple seconds. This change allows for a recovery from any hash and height, with the idea being the developer can provide a recent block via a service like mempool(dot)space --- bdk-ffi/src/kyoto.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/bdk-ffi/src/kyoto.rs b/bdk-ffi/src/kyoto.rs index 3008df69..2323e94d 100644 --- a/bdk-ffi/src/kyoto.rs +++ b/bdk-ffi/src/kyoto.rs @@ -27,6 +27,7 @@ use crate::bitcoin::BlockHash; use crate::bitcoin::Transaction; use crate::bitcoin::Wtxid; use crate::error::CbfError; +use crate::types::BlockId; use crate::types::Update; use crate::wallet::Wallet; use crate::FeeRate; @@ -185,7 +186,7 @@ impl CbfBuilder { trusted_peers.push(peer.clone().into()); } - let scan_type = match self.scan_type { + let scan_type = match self.scan_type.clone() { ScanType::Sync => bdk_kyoto::ScanType::Sync, ScanType::Recovery { used_script_index, @@ -212,6 +213,10 @@ impl CbfBuilder { used_script_index, checkpoint: HeaderCheckpoint::taproot_activation(), }, + RecoveryPoint::Other { birthday } => bdk_kyoto::ScanType::Recovery { + used_script_index, + checkpoint: HeaderCheckpoint::new(birthday.height, birthday.hash.0), + }, } } } @@ -457,7 +462,7 @@ impl From for Warning { /// Sync a wallet from the last known block hash or recover a wallet from a specified recovery /// point. -#[derive(Debug, Clone, Copy, Default, uniffi::Enum)] +#[derive(Debug, Clone, Default, uniffi::Enum)] pub enum ScanType { /// Sync an existing wallet from the last stored chain checkpoint. #[default] @@ -472,12 +477,15 @@ pub enum ScanType { }, } -#[derive(Debug, Clone, Copy, Default, uniffi::Enum)] +#[derive(Debug, Clone, Default, uniffi::Enum)] pub enum RecoveryPoint { GenesisBlock, #[default] SegwitActivation, TaprootActivation, + Other { + birthday: BlockId, + }, } /// A peer to connect to over the Bitcoin peer-to-peer network.