Skip to content

Commit b1c47f0

Browse files
committed
Drop the no-std feature from lightning-invoice
Now that we don't have to have everything in our entire ecosystem use the same `std`/`no-std` feature combinations we should start by untangling our own features a bit. This takes another step by removing the `no-std` feature entirely from the `lightning-invoice` crate and removing all feature implications on dependencies from the remaining `std` feature.
1 parent e4086b4 commit b1c47f0

File tree

5 files changed

+13
-11
lines changed

5 files changed

+13
-11
lines changed

ci/ci-tests.sh

+10-3
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,21 @@ grep '^max_level_' lightning/Cargo.toml | awk '{ print $1 }'| while read -r FEAT
7474
RUSTFLAGS="$RUSTFLAGS -A unused_variables -A unused_macros -A unused_imports -A dead_code" cargo check -p lightning --verbose --color always --features "$FEATURE"
7575
done
7676

77+
echo -e "\n\nTesting no-std builds"
78+
for DIR in lightning-invoice lightning-background-processor; do
79+
cargo test -p $DIR --verbose --color always --no-default-features
80+
# check if there is a conflict between no-std and the c_bindings cfg
81+
RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test -p $DIR --verbose --color always --no-default-features
82+
done
83+
7784
echo -e "\n\nTesting no-std flags in various combinations"
78-
for DIR in lightning lightning-invoice lightning-rapid-gossip-sync; do
85+
for DIR in lightning lightning-rapid-gossip-sync; do
7986
cargo test -p $DIR --verbose --color always --no-default-features --features no-std
8087
# check if there is a conflict between no-std and the default std feature
8188
cargo test -p $DIR --verbose --color always --features no-std
8289
done
8390

84-
for DIR in lightning lightning-invoice lightning-rapid-gossip-sync; do
91+
for DIR in lightning lightning-rapid-gossip-sync; do
8592
# check if there is a conflict between no-std and the c_bindings cfg
8693
RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test -p $DIR --verbose --color always --no-default-features --features=no-std
8794
done
@@ -91,7 +98,7 @@ RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test --verbose --color always
9198
cargo test -p lightning --verbose --color always --no-default-features --features=std,_test_vectors
9299
# This one only works for lightning-invoice
93100
# check that compile with no-std and serde works in lightning-invoice
94-
cargo test -p lightning-invoice --verbose --color always --no-default-features --features no-std --features serde
101+
cargo test -p lightning-invoice --verbose --color always --no-default-features --features serde
95102

96103
echo -e "\n\nTesting no-std build on a downstream no-std crate"
97104
# check no-std compatibility across dependencies

lightning-invoice/Cargo.toml

+1-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ all-features = true
1515
rustdoc-args = ["--cfg", "docsrs"]
1616

1717
[features]
18-
default = ["std"]
19-
no-std = []
20-
std = ["bech32/std"]
18+
std = []
2119

2220
[dependencies]
2321
bech32 = { version = "0.9.1", default-features = false }

lightning-invoice/src/lib.rs

-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
2222
//!
2323
//! [`Bolt11Invoice::from_str`]: crate::Bolt11Invoice#impl-FromStr
2424
25-
#[cfg(not(any(feature = "std", feature = "no-std")))]
26-
compile_error!("at least one of the `std` or `no-std` features must be enabled");
27-
2825
extern crate bech32;
2926
extern crate lightning_types;
3027
extern crate alloc;

lightning/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ unsafe_revoked_tx_signing = []
3131
# Override signing to not include randomness when generating signatures for test vectors.
3232
_test_vectors = []
3333

34-
no-std = ["hashbrown", "possiblyrandom", "lightning-invoice/no-std", "libm"]
34+
no-std = ["hashbrown", "possiblyrandom", "libm"]
3535
std = ["lightning-invoice/std", "bech32/std"]
3636

3737
# Generates low-r bitcoin signatures, which saves 1 byte in 50% of the cases

no-std-check/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.1.0"
44
edition = "2021"
55

66
[features]
7-
default = ["lightning/no-std", "lightning-invoice/no-std", "lightning-rapid-gossip-sync/no-std"]
7+
default = ["lightning/no-std", "lightning-rapid-gossip-sync/no-std"]
88

99
[dependencies]
1010
lightning = { path = "../lightning", default-features = false }

0 commit comments

Comments
 (0)