Skip to content

Commit 0275928

Browse files
committed
Allow building payjoin crate with no default features
Previously, the payjoin crate would fail to build if none of the features 'v1', 'v2', or 'directory' were enabled, due to an explicit compile_error! macro. This prevented the use of tools like cargo-all-features for comprehensive CI and dead code detection. This change removes the compile_error! and replaces it with a doc-only module that is included when no features are enabled, making the crate a no-op in that configuration. The documentation and Cargo.toml are updated to clarify that at least one of the main features must be enabled for any functionality. This enables better CI, linting, and future modularity, while preserving clear guidance for users and contributors. Closes #921
1 parent 0aa1509 commit 0275928

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@
2626

2727
The Payjoin Dev Kit `payjoin` library implements both [BIP 78 Payjoin V1](https://github.com/bitcoin/bips/blob/master/bip-0078.mediawiki) and [BIP 77 Payjoin V2](https://github.com/bitcoin/bips/blob/master/bip-0077.md).
2828

29+
### Feature Flags
30+
31+
The `payjoin` crate supports the following features:
32+
- `v1`: Enables BIP 78 Payjoin V1 support.
33+
- `v2`: Enables BIP 77 Payjoin V2 support (enabled by default).
34+
- `directory`: Enables Payjoin Directory support.
35+
36+
**Note:**
37+
The crate will now build with no features enabled (e.g., `cargo build --no-default-features`), but in this configuration, no functionality is available. This is intended to support comprehensive CI and linting. To use the library, enable at least one of the features above.
38+
2939
### `payjoin-cli`
3040

3141
The [`payjoin-cli`](https://github.com/payjoin/rust-payjoin/tree/master/payjoin-cli) crate performs no-frills Payjoin as a reference implementation using Bitcoin Core wallet.

payjoin/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ exclude = ["tests"]
1616
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1717

1818
[features]
19+
# The crate will build with no features enabled, but will provide no functionality.
20+
# Enable at least one of: 'v1', 'v2', or 'directory' to use the library.
1921
default = ["v2"]
2022
#[doc = "Core features for payjoin state machines"]
2123
_core = ["bitcoin/rand-std", "serde_json", "url", "bitcoin_uri", "serde", "bitcoin/serde"]

payjoin/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818
//! **Use at your own risk. This crate has not yet been reviewed by independent Rust and Bitcoin security professionals.**
1919
2020
#[cfg(not(any(feature = "directory", feature = "v1", feature = "v2")))]
21-
compile_error!("At least one of the features ['directory', 'v1', 'v2'] must be enabled");
21+
#[doc(hidden)]
22+
pub mod no_features_enabled {
23+
//! This crate was built with no features enabled. No functionality is available.
24+
//! Enable at least one of the features: `directory`, `v1`, or `v2`.
25+
}
2226

2327
#[cfg(any(feature = "v2", feature = "directory"))]
2428
pub(crate) mod bech32;

0 commit comments

Comments
 (0)