diff --git a/bdk-ffi/src/error.rs b/bdk-ffi/src/error.rs index 443e6c3..6a78e92 100644 --- a/bdk-ffi/src/error.rs +++ b/bdk-ffi/src/error.rs @@ -20,6 +20,8 @@ use bdk::miniscript::descriptor::DescriptorKeyParseError as BdkDescriptorKeyPars use bdk::bitcoin::bip32; +use bdk::chain; + use bdk::wallet::error::CreateTxError as BdkCreateTxError; use std::convert::TryInto; @@ -547,6 +549,14 @@ impl From for CalculateFeeError { } } +impl From for CannotConnectError { + fn from(error: chain::local_chain::CannotConnectError) -> Self { + CannotConnectError::Include { + height: error.try_include_height, + } + } +} + impl From> for CreateTxError { fn from(error: BdkCreateTxError) -> Self { match error { diff --git a/bdk-ffi/src/wallet.rs b/bdk-ffi/src/wallet.rs index ff784d0..abd739a 100644 --- a/bdk-ffi/src/wallet.rs +++ b/bdk-ffi/src/wallet.rs @@ -59,9 +59,7 @@ impl Wallet { pub fn apply_update(&self, update: Arc) -> Result<(), CannotConnectError> { self.get_wallet() .apply_update(update.0.clone()) - .map_err(|e| CannotConnectError::Include { - height: e.try_include_height, - }) + .map_err(CannotConnectError::from) } // TODO: This is the fallible version of get_internal_address; should I rename it to get_internal_address?