Better no-std support
- Use `default-features = false` for `miniscript`,`bitcoin`,and `bdk_chain` - Introduce `bdk_chain/std` feature - Add GitHub workflow `check-no-std` (not yet completly working) - Update GitHub workflow `check-wasm` to disable default `std` features
This commit is contained in:
@@ -15,11 +15,11 @@ rust-version = "1.57"
|
||||
[dependencies]
|
||||
log = "=0.4.18"
|
||||
rand = "^0.8"
|
||||
miniscript = { version = "9", features = ["serde"] }
|
||||
bitcoin = { version = "0.29", features = ["serde", "base64", "rand"] }
|
||||
miniscript = { version = "9", features = ["serde"], default-features = false }
|
||||
bitcoin = { version = "0.29", features = ["serde", "base64", "rand"], default-features = false }
|
||||
serde = { version = "^1.0", features = ["derive"] }
|
||||
serde_json = { version = "^1.0" }
|
||||
bdk_chain = { path = "../chain", version = "0.4.0", features = ["miniscript", "serde"] }
|
||||
bdk_chain = { path = "../chain", version = "0.4.0", features = ["miniscript", "serde"], default-features = false }
|
||||
|
||||
# Optional dependencies
|
||||
hwi = { version = "0.5", optional = true, features = [ "use-miniscript"] }
|
||||
@@ -29,17 +29,15 @@ bip39 = { version = "1.0.1", optional = true }
|
||||
getrandom = "0.2"
|
||||
js-sys = "0.3"
|
||||
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = []
|
||||
std = ["bitcoin/std", "miniscript/std", "bdk_chain/std"]
|
||||
compiler = ["miniscript/compiler"]
|
||||
all-keys = ["keys-bip39"]
|
||||
keys-bip39 = ["bip39"]
|
||||
hardware-signer = ["hwi"]
|
||||
test-hardware-signer = ["hardware-signer"]
|
||||
|
||||
|
||||
# This feature is used to run `cargo check` in our CI targeting wasm. It's not recommended
|
||||
# for libraries to explicitly include the "getrandom/js" feature, so we only do it when
|
||||
# necessary for running our CI. See: https://docs.rs/getrandom/0.2.8/getrandom/#webassembly-support
|
||||
@@ -52,12 +50,10 @@ env_logger = "0.7"
|
||||
base64 = "^0.13"
|
||||
assert_matches = "1.5.0"
|
||||
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
rustdoc-args = ["--cfg", "docsrs"]
|
||||
|
||||
|
||||
[[example]]
|
||||
name = "mnemonic_to_descriptors"
|
||||
path = "examples/mnemonic_to_descriptors.rs"
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
//! Descriptor errors
|
||||
|
||||
use core::fmt;
|
||||
|
||||
/// Errors related to the parsing and usage of descriptors
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
@@ -51,8 +53,8 @@ impl From<crate::keys::KeyError> for Error {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Error {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
impl fmt::Display for Error {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::InvalidHdKeyPath => write!(f, "Invalid HD key path"),
|
||||
Self::InvalidDescriptorChecksum => {
|
||||
|
||||
@@ -107,8 +107,10 @@ impl fmt::Display for MiniscriptPsbtError {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl std::error::Error for MiniscriptPsbtError {}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl fmt::Display for Error {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
|
||||
@@ -15,6 +15,7 @@ use crate::collections::HashSet;
|
||||
use alloc::string::{String, ToString};
|
||||
use alloc::vec::Vec;
|
||||
use core::any::TypeId;
|
||||
use core::fmt;
|
||||
use core::marker::PhantomData;
|
||||
use core::ops::Deref;
|
||||
use core::str::FromStr;
|
||||
@@ -934,8 +935,8 @@ pub enum KeyError {
|
||||
impl_error!(miniscript::Error, Miniscript, KeyError);
|
||||
impl_error!(bitcoin::util::bip32::Error, Bip32, KeyError);
|
||||
|
||||
impl std::fmt::Display for KeyError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
impl fmt::Display for KeyError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::InvalidScriptContext => write!(f, "Invalid script context"),
|
||||
Self::InvalidNetwork => write!(f, "Invalid network"),
|
||||
|
||||
@@ -170,9 +170,9 @@ pub enum NewError<P> {
|
||||
Persist(P),
|
||||
}
|
||||
|
||||
impl<P> core::fmt::Display for NewError<P>
|
||||
impl<P> fmt::Display for NewError<P>
|
||||
where
|
||||
P: core::fmt::Display,
|
||||
P: fmt::Display,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
|
||||
Reference in New Issue
Block a user