Skip to content

Conversation

@chuksys
Copy link
Contributor

@chuksys chuksys commented Jan 11, 2026

Context

In 06a8108, persistence_backwards_compatibility was introduced. Currently, the from_seed_bytes constructor and the subsequent build method have diverging signatures depending on whether the uniffi feature is enabled.

Changes

  • A helper function is added to unify entropy creation.
  • into() is used to conditionally wrap node_entropy with an Arc or not.

Why this is necessary

UniFFI requires Arc wrappers for cross-language memory management. Without this change, the integration tests fail to compile when the uniffi feature is active because the builder receives a raw struct instead of the expected shared pointer.

Adapt the NodeEntropy initialization to account for diverging
constructor signatures when the uniffi feature is active.

The UniFFI layer requires shared ownership (Arc) and dynamic byte
validation (Result/Vec) to facilitate memory management and error
handling across the FFI boundary. This change ensures the builder
receives the expected pointer type in UniFFI builds while
maintaining the zero-cost stack allocation for standard Rust usage.
@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Jan 11, 2026

👋 Thanks for assigning @tnull 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.

@ldk-reviews-bot ldk-reviews-bot requested a review from tnull January 11, 2026 13:08
Copy link
Collaborator

@tnull tnull left a comment

Choose a reason for hiding this comment

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

Ah, thanks, seems this slipped through.

One comment.

builder_new.set_storage_dir_path(storage_path);
builder_new.set_chain_source_esplora(esplora_url, None);

let node_new = builder_new.build(node_entropy).unwrap();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, rather than adding extra cfg flags above, can we just follow the pattern we did elswhere and add an into() here?

Suggested change
let node_new = builder_new.build(node_entropy.into()).unwrap();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a helper function to unify entropy creation. Also used into() as suggested.

@chuksys chuksys requested a review from tnull January 11, 2026 23:46
Copy link
Collaborator

@tnull tnull left a comment

Choose a reason for hiding this comment

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

Ah, excuse the back-and-forth, but IMO would be good to avoid the extra boilerplate here. Let's just switch the test to use a Mnemonic, which is what we did elsewhere.

println!("\nB stopped");
}

// Helper to unify entropy creation
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, actually, if need this let's rather just avoid the issue altogether by using what we do elsewhere (i.e., in TestConfig::default):

		let mnemonic = generate_entropy_mnemonic(None);
		let node_entropy = NodeEntropy::from_bip39_mnemonic(mnemonic, None);

rather than seed bytes in fn persistence_backwards_compatibility.

Copy link
Collaborator

@tnull tnull left a comment

Choose a reason for hiding this comment

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

Landing this to unbreak CI, might make minor changes in a follow-up.

@tnull tnull merged commit ee617ef into lightningdevkit:main Jan 13, 2026
17 of 18 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.

3 participants