Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add from to CannotConnectError #525

Merged
merged 1 commit into from
May 2, 2024
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
10 changes: 10 additions & 0 deletions bdk-ffi/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -547,6 +549,14 @@ impl From<BdkCalculateFeeError> for CalculateFeeError {
}
}

impl From<chain::local_chain::CannotConnectError> for CannotConnectError {
fn from(error: chain::local_chain::CannotConnectError) -> Self {
CannotConnectError::Include {
height: error.try_include_height,
}
}
}

impl From<BdkCreateTxError<std::io::Error>> for CreateTxError {
fn from(error: BdkCreateTxError<std::io::Error>) -> Self {
match error {
Expand Down
4 changes: 1 addition & 3 deletions bdk-ffi/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ impl Wallet {
pub fn apply_update(&self, update: Arc<Update>) -> 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?
Expand Down
Loading