Skip to content

Commit fb9b0b6

Browse files
committed
chore: use core::error::Error
The `Error` trait is stable as of 1.81.0, so import it from `core` instead.
1 parent c4a3b8c commit fb9b0b6

File tree

16 files changed

+43
-57
lines changed

16 files changed

+43
-57
lines changed

examples/compiler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extern crate bitcoin;
1414
extern crate miniscript;
1515
extern crate serde_json;
1616

17-
use std::error::Error;
17+
use core::error::Error;
1818
use std::str::FromStr;
1919

2020
use bitcoin::Network;

examples/policy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
extern crate bdk_wallet;
1313

14-
use std::error::Error;
14+
use core::error::Error;
1515

1616
use bdk_wallet::descriptor::{policy::BuildSatisfaction, ExtractPolicy, IntoWalletDescriptor};
1717
use bdk_wallet::signer::SignersContainer;

src/descriptor/dsl.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ macro_rules! apply_modifier {
440440
/// ```
441441
/// # use std::str::FromStr;
442442
/// let (my_descriptor, my_keys_map, network_kinds) = bdk_wallet::descriptor!(sh(wsh(and_v(v:pk("cVt4o7BGAig1UXywgGSmARhxMdzP5qvQsxKkSsc1XEkw3tDTQFpy"),older(50)))))?;
443-
/// # Ok::<(), Box<dyn std::error::Error>>(())
443+
/// # Ok::<(), Box<dyn core::error::Error>>(())
444444
/// ```
445445
///
446446
/// -------
@@ -478,7 +478,7 @@ macro_rules! apply_modifier {
478478
///
479479
/// assert_eq!(descriptor_a, descriptor_b);
480480
/// assert_eq!(key_map_a.len(), key_map_b.len());
481-
/// # Ok::<(), Box<dyn std::error::Error>>(())
481+
/// # Ok::<(), Box<dyn core::error::Error>>(())
482482
/// ```
483483
///
484484
/// ------
@@ -498,7 +498,7 @@ macro_rules! apply_modifier {
498498
/// multi(2, my_key_1, my_key_2)
499499
/// )
500500
/// }?;
501-
/// # Ok::<(), Box<dyn std::error::Error>>(())
501+
/// # Ok::<(), Box<dyn core::error::Error>>(())
502502
/// ```
503503
///
504504
/// ------
@@ -510,7 +510,7 @@ macro_rules! apply_modifier {
510510
/// bitcoin::PrivateKey::from_wif("cVt4o7BGAig1UXywgGSmARhxMdzP5qvQsxKkSsc1XEkw3tDTQFpy")?;
511511
///
512512
/// let (descriptor, key_map, networks_kinds) = bdk_wallet::descriptor!(wpkh(my_key))?;
513-
/// # Ok::<(), Box<dyn std::error::Error>>(())
513+
/// # Ok::<(), Box<dyn core::error::Error>>(())
514514
/// ```
515515
///
516516
/// [`Vec`]: alloc::vec::Vec

src/descriptor/error.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ impl fmt::Display for Error {
8888
}
8989
}
9090

91-
#[cfg(feature = "std")]
92-
impl std::error::Error for Error {}
91+
impl core::error::Error for Error {}
9392

9493
impl From<bitcoin::bip32::Error> for Error {
9594
fn from(err: bitcoin::bip32::Error) -> Self {

src/descriptor/policy.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,8 +545,7 @@ impl From<IndexOutOfBoundsError> for PolicyError {
545545
}
546546
}
547547

548-
#[cfg(feature = "std")]
549-
impl std::error::Error for PolicyError {}
548+
impl core::error::Error for PolicyError {}
550549

551550
impl Policy {
552551
fn new(item: SatisfiableItem) -> Self {

src/descriptor/template.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl<T: DescriptorTemplate> IntoWalletDescriptor for T {
9494
/// .to_string(),
9595
/// "mwJ8hxFYW19JLuc65RCTaP4v1rzVU8cVMT"
9696
/// );
97-
/// # Ok::<_, Box<dyn std::error::Error>>(())
97+
/// # Ok::<_, Box<dyn core::error::Error>>(())
9898
/// ```
9999
#[derive(Debug, Clone)]
100100
pub struct P2Pkh<K: IntoDescriptorKey<Legacy>>(pub K);
@@ -129,7 +129,7 @@ impl<K: IntoDescriptorKey<Legacy>> DescriptorTemplate for P2Pkh<K> {
129129
/// .to_string(),
130130
/// "2NB4ox5VDRw1ecUv6SnT3VQHPXveYztRqk5"
131131
/// );
132-
/// # Ok::<_, Box<dyn std::error::Error>>(())
132+
/// # Ok::<_, Box<dyn core::error::Error>>(())
133133
/// ```
134134
#[allow(non_camel_case_types)]
135135
#[derive(Debug, Clone)]
@@ -165,7 +165,7 @@ impl<K: IntoDescriptorKey<Segwitv0>> DescriptorTemplate for P2Wpkh_P2Sh<K> {
165165
/// .to_string(),
166166
/// "tb1q4525hmgw265tl3drrl8jjta7ayffu6jf68ltjd"
167167
/// );
168-
/// # Ok::<_, Box<dyn std::error::Error>>(())
168+
/// # Ok::<_, Box<dyn core::error::Error>>(())
169169
/// ```
170170
#[derive(Debug, Clone)]
171171
pub struct P2Wpkh<K: IntoDescriptorKey<Segwitv0>>(pub K);
@@ -200,7 +200,7 @@ impl<K: IntoDescriptorKey<Segwitv0>> DescriptorTemplate for P2Wpkh<K> {
200200
/// .to_string(),
201201
/// "tb1pvjf9t34fznr53u5tqhejz4nr69luzkhlvsdsdfq9pglutrpve2xq7hps46"
202202
/// );
203-
/// # Ok::<_, Box<dyn std::error::Error>>(())
203+
/// # Ok::<_, Box<dyn core::error::Error>>(())
204204
/// ```
205205
#[derive(Debug, Clone)]
206206
pub struct P2TR<K: IntoDescriptorKey<Tap>>(pub K);
@@ -233,7 +233,7 @@ impl<K: IntoDescriptorKey<Tap>> DescriptorTemplate for P2TR<K> {
233233
///
234234
/// assert_eq!(wallet.next_unused_address(KeychainKind::External).to_string(), "mmogjc7HJEZkrLqyQYqJmxUqFaC7i4uf89");
235235
/// assert_eq!(wallet.public_descriptor(KeychainKind::External).to_string(), "pkh([c55b303f/44'/1'/0']tpubDCuorCpzvYS2LCD75BR46KHE8GdDeg1wsAgNZeNr6DaB5gQK1o14uErKwKLuFmeemkQ6N2m3rNgvctdJLyr7nwu2yia7413Hhg8WWE44cgT/0/*)#5wrnv0xt");
236-
/// # Ok::<_, Box<dyn std::error::Error>>(())
236+
/// # Ok::<_, Box<dyn core::error::Error>>(())
237237
/// ```
238238
#[derive(Debug, Clone)]
239239
pub struct Bip44<K: DerivableKey<Legacy>>(pub K, pub KeychainKind);
@@ -279,7 +279,7 @@ impl<K: DerivableKey<Legacy>> DescriptorTemplate for Bip44<K> {
279279
///
280280
/// assert_eq!(wallet.next_unused_address(KeychainKind::External).to_string(), "miNG7dJTzJqNbFS19svRdTCisC65dsubtR");
281281
/// assert_eq!(wallet.public_descriptor(KeychainKind::External).to_string(), "pkh([c55b303f/44'/1'/0']tpubDDDzQ31JkZB7VxUr9bjvBivDdqoFLrDPyLWtLapArAi51ftfmCb2DPxwLQzX65iNcXz1DGaVvyvo6JQ6rTU73r2gqdEo8uov9QKRb7nKCSU/0/*)#cfhumdqz");
282-
/// # Ok::<_, Box<dyn std::error::Error>>(())
282+
/// # Ok::<_, Box<dyn core::error::Error>>(())
283283
/// ```
284284
#[derive(Debug, Clone)]
285285
pub struct Bip44Public<K: DerivableKey<Legacy>>(pub K, pub bip32::Fingerprint, pub KeychainKind);
@@ -322,7 +322,7 @@ impl<K: DerivableKey<Legacy>> DescriptorTemplate for Bip44Public<K> {
322322
///
323323
/// assert_eq!(wallet.next_unused_address(KeychainKind::External).to_string(), "2N4zkWAoGdUv4NXhSsU8DvS5MB36T8nKHEB");
324324
/// assert_eq!(wallet.public_descriptor(KeychainKind::External).to_string(), "sh(wpkh([c55b303f/49'/1'/0']tpubDDYr4kdnZgjjShzYNjZUZXUUtpXaofdkMaipyS8ThEh45qFmhT4hKYways7UXmg6V7het1QiFo9kf4kYUXyDvV4rHEyvSpys9pjCB3pukxi/0/*))#s9vxlc8e");
325-
/// # Ok::<_, Box<dyn std::error::Error>>(())
325+
/// # Ok::<_, Box<dyn core::error::Error>>(())
326326
/// ```
327327
#[derive(Debug, Clone)]
328328
pub struct Bip49<K: DerivableKey<Segwitv0>>(pub K, pub KeychainKind);
@@ -368,7 +368,7 @@ impl<K: DerivableKey<Segwitv0>> DescriptorTemplate for Bip49<K> {
368368
///
369369
/// assert_eq!(wallet.next_unused_address(KeychainKind::External).to_string(), "2N3K4xbVAHoiTQSwxkZjWDfKoNC27pLkYnt");
370370
/// assert_eq!(wallet.public_descriptor(KeychainKind::External).to_string(), "sh(wpkh([c55b303f/49'/1'/0']tpubDC49r947KGK52X5rBWS4BLs5m9SRY3pYHnvRrm7HcybZ3BfdEsGFyzCMzayi1u58eT82ZeyFZwH7DD6Q83E3fM9CpfMtmnTygnLfP59jL9L/0/*))#3tka9g0q");
371-
/// # Ok::<_, Box<dyn std::error::Error>>(())
371+
/// # Ok::<_, Box<dyn core::error::Error>>(())
372372
/// ```
373373
#[derive(Debug, Clone)]
374374
pub struct Bip49Public<K: DerivableKey<Segwitv0>>(pub K, pub bip32::Fingerprint, pub KeychainKind);
@@ -411,7 +411,7 @@ impl<K: DerivableKey<Segwitv0>> DescriptorTemplate for Bip49Public<K> {
411411
///
412412
/// assert_eq!(wallet.next_unused_address(KeychainKind::External).to_string(), "tb1qhl85z42h7r4su5u37rvvw0gk8j2t3n9y7zsg4n");
413413
/// assert_eq!(wallet.public_descriptor(KeychainKind::External).to_string(), "wpkh([c55b303f/84'/1'/0']tpubDDc5mum24DekpNw92t6fHGp8Gr2JjF9J7i4TZBtN6Vp8xpAULG5CFaKsfugWa5imhrQQUZKXe261asP5koDHo5bs3qNTmf3U3o4v9SaB8gg/0/*)#6kfecsmr");
414-
/// # Ok::<_, Box<dyn std::error::Error>>(())
414+
/// # Ok::<_, Box<dyn core::error::Error>>(())
415415
/// ```
416416
#[derive(Debug, Clone)]
417417
pub struct Bip84<K: DerivableKey<Segwitv0>>(pub K, pub KeychainKind);
@@ -457,7 +457,7 @@ impl<K: DerivableKey<Segwitv0>> DescriptorTemplate for Bip84<K> {
457457
///
458458
/// assert_eq!(wallet.next_unused_address(KeychainKind::External).to_string(), "tb1qedg9fdlf8cnnqfd5mks6uz5w4kgpk2pr6y4qc7");
459459
/// assert_eq!(wallet.public_descriptor(KeychainKind::External).to_string(), "wpkh([c55b303f/84'/1'/0']tpubDC2Qwo2TFsaNC4ju8nrUJ9mqVT3eSgdmy1yPqhgkjwmke3PRXutNGRYAUo6RCHTcVQaDR3ohNU9we59brGHuEKPvH1ags2nevW5opEE9Z5Q/0/*)#dhu402yv");
460-
/// # Ok::<_, Box<dyn std::error::Error>>(())
460+
/// # Ok::<_, Box<dyn core::error::Error>>(())
461461
/// ```
462462
#[derive(Debug, Clone)]
463463
pub struct Bip84Public<K: DerivableKey<Segwitv0>>(pub K, pub bip32::Fingerprint, pub KeychainKind);
@@ -500,7 +500,7 @@ impl<K: DerivableKey<Segwitv0>> DescriptorTemplate for Bip84Public<K> {
500500
///
501501
/// assert_eq!(wallet.next_unused_address(KeychainKind::External).to_string(), "tb1p5unlj09djx8xsjwe97269kqtxqpwpu2epeskgqjfk4lnf69v4tnqpp35qu");
502502
/// assert_eq!(wallet.public_descriptor(KeychainKind::External).to_string(), "tr([c55b303f/86'/1'/0']tpubDCiHofpEs47kx358bPdJmTZHmCDqQ8qw32upCSxHrSEdeeBs2T5Mq6QMB2ukeMqhNBiyhosBvJErteVhfURPGXPv3qLJPw5MVpHUewsbP2m/0/*)#dkgvr5hm");
503-
/// # Ok::<_, Box<dyn std::error::Error>>(())
503+
/// # Ok::<_, Box<dyn core::error::Error>>(())
504504
/// ```
505505
#[derive(Debug, Clone)]
506506
pub struct Bip86<K: DerivableKey<Tap>>(pub K, pub KeychainKind);
@@ -546,7 +546,7 @@ impl<K: DerivableKey<Tap>> DescriptorTemplate for Bip86<K> {
546546
///
547547
/// assert_eq!(wallet.next_unused_address(KeychainKind::External).to_string(), "tb1pwjp9f2k5n0xq73ecuu0c5njvgqr3vkh7yaylmpqvsuuaafymh0msvcmh37");
548548
/// assert_eq!(wallet.public_descriptor(KeychainKind::External).to_string(), "tr([c55b303f/86'/1'/0']tpubDC2Qwo2TFsaNC4ju8nrUJ9mqVT3eSgdmy1yPqhgkjwmke3PRXutNGRYAUo6RCHTcVQaDR3ohNU9we59brGHuEKPvH1ags2nevW5opEE9Z5Q/0/*)#2p65srku");
549-
/// # Ok::<_, Box<dyn std::error::Error>>(())
549+
/// # Ok::<_, Box<dyn core::error::Error>>(())
550550
/// ```
551551
#[derive(Debug, Clone)]
552552
pub struct Bip86Public<K: DerivableKey<Tap>>(pub K, pub bip32::Fingerprint, pub KeychainKind);

src/keys/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ impl<Ctx: ScriptContext + 'static> ExtScriptContext for Ctx {
304304
/// let (descriptor, _, _) = bdk_wallet::descriptor!(pkh(key))?;
305305
/// // ^^^^^ changing this to `wpkh` would make it compile
306306
///
307-
/// # Ok::<_, Box<dyn std::error::Error>>(())
307+
/// # Ok::<_, Box<dyn core::error::Error>>(())
308308
/// ```
309309
pub trait IntoDescriptorKey<Ctx: ScriptContext>: Sized {
310310
/// Turn the key into a [`DescriptorKey`] within the requested [`ScriptContext`]
@@ -472,7 +472,7 @@ use bdk_wallet::bitcoin::NetworkKind;
472472
use bdk_wallet::keys::{DerivableKey, ExtendedKey};
473473
use bdk_wallet::keys::bip39::{Mnemonic, Language};
474474
475-
# fn main() -> Result<(), Box<dyn std::error::Error>> {
475+
# fn main() -> Result<(), Box<dyn core::error::Error>> {
476476
let xkey: ExtendedKey =
477477
Mnemonic::parse_in(
478478
Language::English,
@@ -1038,8 +1038,7 @@ impl fmt::Display for KeyError {
10381038
}
10391039
}
10401040

1041-
#[cfg(feature = "std")]
1042-
impl std::error::Error for KeyError {}
1041+
impl core::error::Error for KeyError {}
10431042

10441043
#[cfg_attr(coverage_nightly, coverage(off))]
10451044
#[cfg(test)]

src/types.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,5 +171,4 @@ impl fmt::Display for IndexOutOfBoundsError {
171171
}
172172
}
173173

174-
#[cfg(feature = "std")]
175-
impl std::error::Error for IndexOutOfBoundsError {}
174+
impl core::error::Error for IndexOutOfBoundsError {}

src/wallet/coin_selection.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ impl fmt::Display for InsufficientFunds {
141141
}
142142
}
143143

144-
#[cfg(feature = "std")]
145-
impl std::error::Error for InsufficientFunds {}
144+
impl core::error::Error for InsufficientFunds {}
146145

147146
#[derive(Debug)]
148147
/// Remaining amount after performing coin selection

src/wallet/error.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ impl fmt::Display for LoadError {
5151
}
5252
}
5353

54-
#[cfg(feature = "std")]
55-
impl std::error::Error for LoadError {}
54+
impl core::error::Error for LoadError {}
5655

5756
/// Represents a mismatch with what is loaded and what is expected from [`LoadParams`].
5857
#[derive(Debug, PartialEq)]
@@ -148,8 +147,7 @@ impl fmt::Display for MiniscriptPsbtError {
148147
}
149148
}
150149

151-
#[cfg(feature = "std")]
152-
impl std::error::Error for MiniscriptPsbtError {}
150+
impl core::error::Error for MiniscriptPsbtError {}
153151

154152
#[derive(Debug)]
155153
/// Error returned from [`TxBuilder::finish`]
@@ -312,8 +310,7 @@ impl From<coin_selection::InsufficientFunds> for CreateTxError {
312310
}
313311
}
314312

315-
#[cfg(feature = "std")]
316-
impl std::error::Error for CreateTxError {}
313+
impl core::error::Error for CreateTxError {}
317314

318315
#[derive(Debug)]
319316
/// Error returned from [`Wallet::build_fee_bump`]
@@ -362,5 +359,4 @@ impl fmt::Display for BuildFeeBumpError {
362359
}
363360
}
364361

365-
#[cfg(feature = "std")]
366-
impl std::error::Error for BuildFeeBumpError {}
362+
impl core::error::Error for BuildFeeBumpError {}

0 commit comments

Comments
 (0)