Skip to content

Introduce Rust features - #1061

Merged
tnull merged 14 commits into
lightningdevkit:mainfrom
tnull:2026-08-rust-features
Aug 21, 2026
Merged

Introduce Rust features#1061
tnull merged 14 commits into
lightningdevkit:mainfrom
tnull:2026-08-rust-features

Conversation

@tnull

@tnull tnull commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Closes #900

Previously, we omitted making use of Rust features to dis-/enable specific functionality, with the exception of uniffi and most recently adding a tentative postgres feature.

Here we finally change that and allow users to selectively disable and enable specific parts of the code base, hence also reducing their dependency tree.

@tnull tnull added this to the 0.8 milestone Aug 19, 2026
@tnull
tnull requested a review from benthecarman August 19, 2026 12:35
@ldk-reviews-bot

ldk-reviews-bot commented Aug 19, 2026

Copy link
Copy Markdown

👋 Thanks for assigning @benthecarman as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@tnull
tnull force-pushed the 2026-08-rust-features branch from 9b4022f to 7f339e5 Compare August 19, 2026 13:40

@benthecarman benthecarman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to have CI cover the missed feature configs that claude caught

Comment thread src/lib.rs
feature = "chain-electrum",
feature = "chain-bitcoind"
)))]
compile_error!("at least one chain source feature must be enabled");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should do same with db

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't do it exactly the same as we also support supplying a custom store via build_with_store, so can't enforce at compile time.

Comment thread bindings/ldk_node.udl
Comment thread src/chain/mod.rs
Comment thread src/wallet/mod.rs
Comment thread tests/common/mod.rs
Comment thread src/io/fs_store.rs Outdated
Comment thread src/io/fs_store.rs Outdated
tnull added 7 commits August 20, 2026 12:04
Allow integration runs to constrain randomized chain sources through
the LDK_NODE_TEST_CHAIN_SOURCES environment variable.

This makes backend-specific feature builds deterministic while
preserving all-backend randomization by default.

Co-Authored-By: HAL 9000
Let tests with custom node construction reuse the common chain source
configuration.

Co-Authored-By: HAL 9000
Exercise PostgreSQL-backed nodes with the configured or randomly
selected chain backend instead of always using Esplora.

Co-Authored-By: HAL 9000
Keep filesystem-specific code together so generic storage utilities can
compile without that backend. This commit only relocates the existing
migration behavior and tests.

Co-Authored-By: HAL 9000
Hide the concrete Bitcoin Core gossip verifier behind the LDK UTXO
lookup trait. This lets common gossip types compile independently of
the Bitcoin Core backend without changing verification behavior.

Co-Authored-By: HAL 9000
Keep human-readable-name resolution beside the unified payment code
that consumes it. This commit only relocates the existing resolver and
updates its internal import paths.

Co-Authored-By: HAL 9000
Define the cfg-selected Builder name next to the implementation it
represents. Feature-specific binding exports can now live there without
changing the native and lock-wrapped builder APIs.

Co-Authored-By: HAL 9000
@tnull
tnull force-pushed the 2026-08-rust-features branch from 7f339e5 to 3185f51 Compare August 20, 2026 11:07
@tnull
tnull requested a review from benthecarman August 20, 2026 11:12
@tnull

tnull commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator Author

Rebased to address minor conflicts, let me know if I can squash fixups.

@benthecarman benthecarman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mostly small things otherwise looks good

Comment thread scripts/uniffi_bindgen_generate_kotlin.sh
Comment thread bindings/ldk_node.udl
Comment thread bindings/ldk_node.udl
Comment thread Cargo.toml
Comment thread src/builder.rs Outdated
Comment thread src/builder.rs Outdated
@tnull
tnull force-pushed the 2026-08-rust-features branch from 3185f51 to 7b144ab Compare August 21, 2026 08:51
@tnull
tnull requested a review from benthecarman August 21, 2026 08:51
@tnull

tnull commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator Author

Added fixups to address comments, let me know if good for squashing.

@benthecarman benthecarman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm on squash

@tnull
tnull force-pushed the 2026-08-rust-features branch from 7b144ab to 76e826a Compare August 21, 2026 08:57
@tnull

tnull commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator Author

lgtm on squash

Squashed without furhter changes.

@tnull
tnull force-pushed the 2026-08-rust-features branch from 76e826a to d5a6554 Compare August 21, 2026 09:31
@tnull

tnull commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator Author

Amended with fixes for CI.

@tnull
tnull requested a review from benthecarman August 21, 2026 09:32
tnull added 5 commits August 21, 2026 11:38
Keep the native defaults while letting applications select only required
chain sources, storage backends, and unified payment support.
At least one chain source remains mandatory.
PostgreSQL now has a storage-prefixed feature name.

Co-Authored-By: HAL 9000
Separate backend-specific binding methods into cfg-gated implementation
blocks. Method bodies and availability remain unchanged, making later
conditional exports easier to review.

Co-Authored-By: HAL 9000
Keep binding signatures and documentation next to their Rust
implementations. Leave only the UDL object declaration so backend
features can add methods without failure stubs.

Co-Authored-By: HAL 9000
Build published bindings with uniffi-default and without native
default features. Let local builds add backend features through
LDK_NODE_EXTRA_FEATURES.

Co-Authored-By: HAL 9000
Build and test UniFFI with its lean preset so excluded backends stay
excluded. Check all features and test targets to catch incompatible
optional dependencies without running the suite twice.

Co-Authored-By: HAL 9000
tnull added 2 commits August 21, 2026 11:39
List each chain, storage, payment, and binding feature and explain
the unchanged native defaults. Show both lean and custom binding builds
so optional backend dependencies can be selected deliberately.

Co-Authored-By: HAL 9000
Avoid allocating paths before filesystem operations that only need
borrowed paths.

Co-Authored-By: HAL 9000
@tnull
tnull force-pushed the 2026-08-rust-features branch from d5a6554 to 1c1063b Compare August 21, 2026 09:44
@tnull

tnull commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator Author

Amended once more to include guidance on Postgres prerequisites, and add a new vendored-tls feature:

> git diff-tree -U2  d5a65547 1c1063bd
diff --git a/Cargo.toml b/Cargo.toml
index 6770fea2..0110c027 100755
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -14,5 +14,5 @@ categories = ["cryptography::cryptocurrencies"]

 [package.metadata.docs.rs]
-features = ["storage-postgres", "native-tls/vendored"]
+features = ["storage-postgres-vendored-tls"]
 rustdoc-args = ["--cfg", "docsrs"]

@@ -57,4 +57,5 @@ storage-filesystem = ["dep:lightning-persister"]
 storage-vss = ["dep:vss-client", "dep:prost"]
 storage-postgres = ["dep:tokio-postgres", "dep:native-tls", "dep:postgres-native-tls"]
+storage-postgres-vendored-tls = ["storage-postgres", "native-tls/vendored"]
 unified-payments = [
 	"dep:bip21",
diff --git a/README.md b/README.md
index 55c0f56e..ec9de516 100644
--- a/README.md
+++ b/README.md
@@ -82,4 +82,5 @@ LDK Node's optional dependencies are grouped by the functionality they provide:
 | `storage-vss` | Versioned Storage Service storage |
 | `storage-postgres` | PostgreSQL storage |
+| `storage-postgres-vendored-tls` | PostgreSQL storage with vendored OpenSSL |
 | `unified-payments` | BIP 21 and human-readable-name payment support |
 | `uniffi` | UniFFI language bindings |
@@ -90,4 +91,8 @@ chain sources, SQLite, filesystem and VSS storage, and unified payments. Postgre
 remain opt-in. Every build must enable at least one chain source feature.

+On Linux, `storage-postgres` uses the system OpenSSL installation and requires the OpenSSL
+development headers and `pkg-config`. Enable `storage-postgres-vendored-tls` instead to build
+OpenSSL from source. Vendored builds require a C compiler, `make`, and Perl.
+
 Disable the default features to select only the functionality and dependencies an application
 needs. For example:

@tnull
tnull merged commit 77f9564 into lightningdevkit:main Aug 21, 2026
21 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Introduce Rust features

3 participants