]> Untitled Git - bdk/commitdiff
chore: use `core::error::Error`
authorLuis Schwab <luisschwab@protonmail.com>
Fri, 6 Mar 2026 01:02:06 +0000 (22:02 -0300)
committerLuis Schwab <luisschwab@protonmail.com>
Fri, 6 Mar 2026 01:48:53 +0000 (22:48 -0300)
The `Error` trait is stable as of 1.81.0, so import it from `core` instead.

crates/bitcoind_rpc/src/bip158.rs
crates/chain/src/indexer/keychain_txout.rs
crates/chain/src/indexer/spk_txout.rs
crates/chain/src/local_chain.rs
crates/chain/src/rusqlite_impl.rs
crates/chain/src/tx_graph.rs
crates/file_store/src/lib.rs
crates/file_store/src/store.rs
examples/example_cli/src/lib.rs

index 81963def6d8c1687ed3d8b4c70c1f6a46d5944f9..4caf59fcdc4b6a8d49204523ac1134501ed8f283 100644 (file)
@@ -173,8 +173,7 @@ impl core::fmt::Display for Error {
     }
 }
 
-#[cfg(feature = "std")]
-impl std::error::Error for Error {}
+impl core::error::Error for Error {}
 
 impl From<bitcoincore_rpc::Error> for Error {
     fn from(e: bitcoincore_rpc::Error) -> Self {
index 6f977b8e14f0875675ca089427527c30b4bf31d7..cbad666964d03ca971e073686f8f3d2d265bd257 100644 (file)
@@ -1022,8 +1022,7 @@ impl<K: core::fmt::Display> core::fmt::Display for InsertDescriptorError<K> {
     }
 }
 
-#[cfg(feature = "std")]
-impl<K: core::fmt::Display + core::fmt::Debug> std::error::Error for InsertDescriptorError<K> {}
+impl<K: core::fmt::Display + core::fmt::Debug> core::error::Error for InsertDescriptorError<K> {}
 
 /// `ChangeSet` represents persistent updates to a [`KeychainTxOutIndex`].
 ///
index 2bf78ec2d77b647d1757804065abf166d1103462..e63eb1201ed50ac426b73a64d5acb2632054e475 100644 (file)
@@ -332,7 +332,7 @@ impl<I: Clone + Ord + core::fmt::Debug> SpkTxOutIndex<I> {
     /// # use bitcoin::{Address, Network, Transaction};
     /// # use std::str::FromStr;
     /// #
-    /// # fn example() -> Result<(), Box<dyn std::error::Error>> {
+    /// # fn example() -> Result<(), Box<dyn core::error::Error>> {
     /// let mut index = SpkTxOutIndex::<u32>::default();
     ///
     /// // ... scan transactions to populate the index ...
@@ -382,7 +382,7 @@ impl<I: Clone + Ord + core::fmt::Debug> SpkTxOutIndex<I> {
     /// # use bitcoin::{Address, Network, Transaction};
     /// # use std::str::FromStr;
     /// #
-    /// # fn example() -> Result<(), Box<dyn std::error::Error>> {
+    /// # fn example() -> Result<(), Box<dyn core::error::Error>> {
     /// let mut index = SpkTxOutIndex::<u32>::default();
     ///
     /// // ... scan transactions to populate the index ...
index 81f4a1796db4e66ed50b7833b181dbc4e3cd65e3..5bfff3aa91295952a50d14d7ab3203e996fab40d 100644 (file)
@@ -498,8 +498,7 @@ impl core::fmt::Display for MissingGenesisError {
     }
 }
 
-#[cfg(feature = "std")]
-impl std::error::Error for MissingGenesisError {}
+impl core::error::Error for MissingGenesisError {}
 
 /// Represents a failure when trying to insert/remove a checkpoint to/from [`LocalChain`].
 #[derive(Clone, Debug, PartialEq)]
@@ -529,8 +528,7 @@ impl core::fmt::Display for AlterCheckPointError {
     }
 }
 
-#[cfg(feature = "std")]
-impl std::error::Error for AlterCheckPointError {}
+impl core::error::Error for AlterCheckPointError {}
 
 /// Occurs when an update does not have a common checkpoint with the original chain.
 #[derive(Clone, Debug, PartialEq)]
@@ -549,8 +547,7 @@ impl core::fmt::Display for CannotConnectError {
     }
 }
 
-#[cfg(feature = "std")]
-impl std::error::Error for CannotConnectError {}
+impl core::error::Error for CannotConnectError {}
 
 /// The error type for [`LocalChain::apply_header_connected_to`].
 #[derive(Debug, Clone, PartialEq)]
@@ -573,8 +570,7 @@ impl core::fmt::Display for ApplyHeaderError {
     }
 }
 
-#[cfg(feature = "std")]
-impl std::error::Error for ApplyHeaderError {}
+impl core::error::Error for ApplyHeaderError {}
 
 /// Applies `update_tip` onto `original_tip`.
 ///
index 7e9e2f6f9f8878d1e815b1568eef6df2a3d28a76..ad89f429ec87c55eae2675b8913838f761c12322 100644 (file)
@@ -185,11 +185,11 @@ impl ToSql for Impl<bitcoin::Network> {
     }
 }
 
-fn from_sql_error<E: std::error::Error + Send + Sync + 'static>(err: E) -> FromSqlError {
+fn from_sql_error<E: core::error::Error + Send + Sync + 'static>(err: E) -> FromSqlError {
     FromSqlError::Other(Box::new(err))
 }
 
-fn to_sql_error<E: std::error::Error + Send + Sync + 'static>(err: E) -> rusqlite::Error {
+fn to_sql_error<E: core::error::Error + Send + Sync + 'static>(err: E) -> rusqlite::Error {
     rusqlite::Error::ToSqlConversionFailure(Box::new(err))
 }
 
index 701de335d6005c9c8d51503678ae5c417e6e137c..44c34c2d7786b7eb2fb519caedcd50302762b632 100644 (file)
@@ -287,8 +287,7 @@ impl fmt::Display for CalculateFeeError {
     }
 }
 
-#[cfg(feature = "std")]
-impl std::error::Error for CalculateFeeError {}
+impl core::error::Error for CalculateFeeError {}
 
 impl<A> TxGraph<A> {
     /// Iterate over all tx outputs known by [`TxGraph`].
index 5a7d50304c55146bc9400380d0d6e339e4d2fa88..3731d503098b1df4d73837a0fbfd429a8115e736 100644 (file)
@@ -53,4 +53,4 @@ impl From<io::Error> for StoreError {
     }
 }
 
-impl std::error::Error for StoreError {}
+impl core::error::Error for StoreError {}
index 7e18679265cff8bffedbbd4beebb34e0e72bd7c9..858b9d2cdfd82e032a2d2892f72f22e7d82cb43e 100644 (file)
@@ -278,7 +278,7 @@ impl<C> std::fmt::Display for StoreErrorWithDump<C> {
     }
 }
 
-impl<C: fmt::Debug> std::error::Error for StoreErrorWithDump<C> {}
+impl<C: fmt::Debug> core::error::Error for StoreErrorWithDump<C> {}
 
 #[cfg(test)]
 #[cfg_attr(coverage_nightly, coverage(off))]
index 2b910a1a076983c76cc2614bb6dbc499a74143cb..6745ae6c19d4c3914bbb9ba7f5342e5d807f811b 100644 (file)
@@ -268,7 +268,7 @@ pub fn create_tx<O: ChainOracle>(
     feerate: f32,
 ) -> anyhow::Result<(Psbt, Option<ChangeInfo>)>
 where
-    O::Error: std::error::Error + Send + Sync + 'static,
+    O::Error: core::error::Error + Send + Sync + 'static,
 {
     let mut changeset = keychain_txout::ChangeSet::default();