Skip to content

Commit 31a9cd2

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 5e37074 commit 31a9cd2

File tree

5 files changed

+13
-11
lines changed

5 files changed

+13
-11
lines changed

ci/ci-tests.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,21 @@ grep '^max_level_' lightning/Cargo.toml | awk '{ print $1 }'| while read -r FEAT
7777
RUSTFLAGS="$RUSTFLAGS -A unused_variables -A unused_macros -A unused_imports -A dead_code" cargo check -p lightning --verbose --color always --features "$FEATURE"
7878
done
7979

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

87-
for DIR in lightning lightning-invoice lightning-rapid-gossip-sync; do
94+
for DIR in lightning lightning-rapid-gossip-sync; do
8895
# check if there is a conflict between no-std and the c_bindings cfg
8996
RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test -p $DIR --verbose --color always --no-default-features --features=no-std
9097
done
@@ -94,7 +101,7 @@ RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test --verbose --color always
94101
cargo test -p lightning --verbose --color always --no-default-features --features=std,_test_vectors
95102
# This one only works for lightning-invoice
96103
# check that compile with no-std and serde works in lightning-invoice
97-
cargo test -p lightning-invoice --verbose --color always --no-default-features --features no-std --features serde
104+
cargo test -p lightning-invoice --verbose --color always --no-default-features --features serde
98105

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

lightning-invoice/Cargo.toml

Lines changed: 1 addition & 3 deletions
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

Lines changed: 0 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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)