diff --git a/crates/bdk/src/descriptor/error.rs b/crates/bdk/src/descriptor/error.rs index 3a704d2ead..b36e69e633 100644 --- a/crates/bdk/src/descriptor/error.rs +++ b/crates/bdk/src/descriptor/error.rs @@ -10,7 +10,6 @@ // licenses. //! Descriptor errors - use core::fmt; /// Errors related to the parsing and usage of descriptors diff --git a/crates/bdk/src/descriptor/policy.rs b/crates/bdk/src/descriptor/policy.rs index 186af8b0bf..b211bc247e 100644 --- a/crates/bdk/src/descriptor/policy.rs +++ b/crates/bdk/src/descriptor/policy.rs @@ -40,6 +40,7 @@ use crate::collections::{BTreeMap, HashSet, VecDeque}; use alloc::string::String; use alloc::vec::Vec; use core::cmp::max; + use core::fmt; use serde::ser::SerializeMap; diff --git a/crates/bdk/src/wallet/coin_selection.rs b/crates/bdk/src/wallet/coin_selection.rs index 2de7aec24c..3cb14acade 100644 --- a/crates/bdk/src/wallet/coin_selection.rs +++ b/crates/bdk/src/wallet/coin_selection.rs @@ -31,6 +31,7 @@ //! # use bdk_chain::PersistBackend; //! # use bdk::*; //! # use bdk::wallet::coin_selection::decide_change; +//! # use anyhow::Error; //! # const TXIN_BASE_WEIGHT: usize = (32 + 4 + 4) * 4; //! #[derive(Debug)] //! struct AlwaysSpendEverything; @@ -96,7 +97,7 @@ //! //! // inspect, sign, broadcast, ... //! -//! # Ok::<(), CreateTxError<<() as PersistBackend>::WriteError>>(()) +//! # Ok::<(), anyhow::Error>(()) //! ``` use crate::types::FeeRate; diff --git a/crates/bdk/src/wallet/error.rs b/crates/bdk/src/wallet/error.rs index 328ab291b6..293cf75a2e 100644 --- a/crates/bdk/src/wallet/error.rs +++ b/crates/bdk/src/wallet/error.rs @@ -119,7 +119,6 @@ pub enum CreateTxError

{ MiniscriptPsbt(MiniscriptPsbtError), } -#[cfg(feature = "std")] impl

fmt::Display for CreateTxError

where P: fmt::Display, @@ -243,7 +242,6 @@ impl

From for CreateTxError

{ } } -#[cfg(feature = "std")] impl std::error::Error for CreateTxError

{} #[derive(Debug)] @@ -263,7 +261,6 @@ pub enum BuildFeeBumpError { FeeRateUnavailable, } -#[cfg(feature = "std")] impl fmt::Display for BuildFeeBumpError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { @@ -304,7 +301,6 @@ pub enum SignError { MiniscriptPsbt(MiniscriptPsbtError), } -#[cfg(feature = "std")] impl fmt::Display for SignError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { @@ -327,7 +323,6 @@ pub enum AddUtxoError { UnknownUtxo(OutPoint), } -#[cfg(feature = "std")] impl fmt::Display for AddUtxoError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { @@ -362,7 +357,6 @@ pub enum AddForeignUtxoError { MissingUtxo, } -#[cfg(feature = "std")] impl fmt::Display for AddForeignUtxoError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { @@ -396,7 +390,6 @@ pub enum AllowShrinkingError { MissingScriptPubKey(ScriptBuf), } -#[cfg(feature = "std")] impl fmt::Display for AllowShrinkingError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { diff --git a/crates/bdk/src/wallet/mod.rs b/crates/bdk/src/wallet/mod.rs index 86a876dfef..696d6718e6 100644 --- a/crates/bdk/src/wallet/mod.rs +++ b/crates/bdk/src/wallet/mod.rs @@ -283,7 +283,6 @@ pub enum InsertTxError { }, } -#[cfg(feature = "std")] impl std::error::Error for NewError

{} impl Wallet { @@ -857,6 +856,7 @@ impl Wallet { /// # use bdk::wallet::ChangeSet; /// # use bdk::wallet::error::CreateTxError; /// # use bdk_chain::PersistBackend; + /// # use anyhow::Error; /// # let descriptor = "wpkh(tpubD6NzVbkrYhZ4Xferm7Pz4VnjdcDPFyjVu5K4iZXQ4pVN8Cks4pHVowTBXBKRhX64pkRyJZJN5xAKj4UDNnLPb5p2sSKXhewoYx5GbTdUFWq/*)"; /// # let mut wallet = doctest_wallet!(); /// # let to_address = Address::from_str("2N4eQYCbKUHCCTUjBJeHcJp9ok6J2GZsTDt").unwrap().assume_checked(); @@ -868,7 +868,7 @@ impl Wallet { /// }; /// /// // sign and broadcast ... - /// # Ok::<(), CreateTxError<<() as PersistBackend>::WriteError>>(()) + /// # Ok::<(), anyhow::Error>(()) /// ``` /// /// [`TxBuilder`]: crate::TxBuilder @@ -1266,7 +1266,7 @@ impl Wallet { /// builder /// .add_recipient(to_address.script_pubkey(), 50_000) /// .enable_rbf(); - /// builder.finish().expect("psbt") + /// builder.finish()? /// }; /// let _ = wallet.sign(&mut psbt, SignOptions::default())?; /// let tx = psbt.extract_tx(); @@ -1275,7 +1275,7 @@ impl Wallet { /// let mut builder = wallet.build_fee_bump(tx.txid())?; /// builder /// .fee_rate(bdk::FeeRate::from_sat_per_vb(5.0)); - /// builder.finish().expect("psbt") + /// builder.finish()? /// }; /// /// let _ = wallet.sign(&mut psbt, SignOptions::default())?; diff --git a/crates/bdk/src/wallet/tx_builder.rs b/crates/bdk/src/wallet/tx_builder.rs index 29d71c668b..f531f1a047 100644 --- a/crates/bdk/src/wallet/tx_builder.rs +++ b/crates/bdk/src/wallet/tx_builder.rs @@ -20,8 +20,9 @@ //! # use bdk::wallet::ChangeSet; //! # use bdk::wallet::error::CreateTxError; //! # use bdk::wallet::tx_builder::CreateTx; -//! # let to_address = Address::from_str("2N4eQYCbKUHCCTUjBJeHcJp9ok6J2GZsTDt").unwrap().assume_checked(); //! # use bdk_chain::PersistBackend; +//! # use anyhow::Error; +//! # let to_address = Address::from_str("2N4eQYCbKUHCCTUjBJeHcJp9ok6J2GZsTDt").unwrap().assume_checked(); //! # let mut wallet = doctest_wallet!(); //! // create a TxBuilder from a wallet //! let mut tx_builder = wallet.build_tx(); @@ -36,7 +37,7 @@ //! // Turn on RBF signaling //! .enable_rbf(); //! let psbt = tx_builder.finish()?; -//! # Ok::<(), CreateTxError<<() as PersistBackend>::WriteError>>(()) +//! # Ok::<(), anyhow::Error>(()) //! ``` use crate::collections::BTreeMap; @@ -87,6 +88,7 @@ impl TxBuilderContext for BumpFee {} /// # use bdk::wallet::ChangeSet; /// # use bdk::wallet::error::CreateTxError; /// # use bdk_chain::PersistBackend; +/// # use anyhow::Error; /// # let mut wallet = doctest_wallet!(); /// # let addr1 = Address::from_str("2N4eQYCbKUHCCTUjBJeHcJp9ok6J2GZsTDt").unwrap().assume_checked(); /// # let addr2 = addr1.clone(); @@ -111,7 +113,7 @@ impl TxBuilderContext for BumpFee {} /// }; /// /// assert_eq!(psbt1.unsigned_tx.output[..2], psbt2.unsigned_tx.output[..2]); -/// # Ok::<(), CreateTxError<<() as PersistBackend>::WriteError>>(()) +/// # Ok::<(), anyhow::Error>(()) /// ``` /// /// At the moment [`coin_selection`] is an exception to the rule as it consumes `self`. @@ -655,6 +657,7 @@ impl<'a, D, Cs: CoinSelectionAlgorithm> TxBuilder<'a, D, Cs, CreateTx> { /// # use bdk::wallet::error::CreateTxError; /// # use bdk::wallet::tx_builder::CreateTx; /// # use bdk_chain::PersistBackend; + /// # use anyhow::Error; /// # let to_address = /// Address::from_str("2N4eQYCbKUHCCTUjBJeHcJp9ok6J2GZsTDt") /// .unwrap() @@ -670,7 +673,7 @@ impl<'a, D, Cs: CoinSelectionAlgorithm> TxBuilder<'a, D, Cs, CreateTx> { /// .fee_rate(bdk::FeeRate::from_sat_per_vb(5.0)) /// .enable_rbf(); /// let psbt = tx_builder.finish()?; - /// # Ok::<(), CreateTxError<<() as PersistBackend>::WriteError>>(()) + /// # Ok::<(), anyhow::Error>(()) /// ``` /// /// [`allow_shrinking`]: Self::allow_shrinking diff --git a/crates/bdk/tests/wallet.rs b/crates/bdk/tests/wallet.rs index dcf6fa06e0..65786319f4 100644 --- a/crates/bdk/tests/wallet.rs +++ b/crates/bdk/tests/wallet.rs @@ -358,9 +358,6 @@ fn test_create_tx_with_default_rbf_csv() { } #[test] -// #[should_panic( -// expected = "Cannot enable RBF with nSequence `Sequence(3)` given a required OP_CSV of `Sequence(6)`" -// )] fn test_create_tx_with_custom_rbf_csv() { let (mut wallet, _) = get_funded_wallet(get_test_single_sig_csv()); let addr = wallet.get_address(New);