From 295b2cea8153652522aa2e642111d52e692525c3 Mon Sep 17 00:00:00 2001 From: Chuks Agbakuru Date: Sun, 11 Jan 2026 13:39:46 +0100 Subject: [PATCH 1/2] Handle conditional NodeEntropy types for UniFFI 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. --- tests/integration_tests_rust.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/integration_tests_rust.rs b/tests/integration_tests_rust.rs index 4b82d1f4f..3d9f04e38 100644 --- a/tests/integration_tests_rust.rs +++ b/tests/integration_tests_rust.rs @@ -2445,6 +2445,9 @@ async fn persistence_backwards_compatibility() { let storage_path = common::random_storage_path().to_str().unwrap().to_owned(); let seed_bytes = [42u8; 64]; + #[cfg(feature = "uniffi")] + let node_entropy = Arc::new(NodeEntropy::from_seed_bytes(seed_bytes.to_vec()).unwrap()); + #[cfg(not(feature = "uniffi"))] let node_entropy = NodeEntropy::from_seed_bytes(seed_bytes); // Setup a v0.6.2 `Node` From 168be274b41c1cde85cc0bf1c8c217e5471d0c39 Mon Sep 17 00:00:00 2001 From: Chuks Agbakuru Date: Sun, 11 Jan 2026 23:04:01 +0100 Subject: [PATCH 2/2] fixup! Handle conditional NodeEntropy types for UniFFI --- tests/common/mod.rs | 12 ++++++++++++ tests/integration_tests_rust.rs | 13 +++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 96f58297c..a998217b2 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -1288,6 +1288,18 @@ pub(crate) async fn do_channel_full_cycle( println!("\nB stopped"); } +// Helper to unify entropy creation +pub(crate) fn create_test_entropy(seed: [u8; 64]) -> NodeEntropy { + #[cfg(feature = "uniffi")] + { + NodeEntropy::from_seed_bytes(seed.to_vec()).unwrap() + } + #[cfg(not(feature = "uniffi"))] + { + NodeEntropy::from_seed_bytes(seed) + } +} + // A `KVStore` impl for testing purposes that wraps all our `KVStore`s and asserts their synchronicity. #[derive(Clone)] pub(crate) struct TestSyncStore { diff --git a/tests/integration_tests_rust.rs b/tests/integration_tests_rust.rs index 3d9f04e38..e642c0713 100644 --- a/tests/integration_tests_rust.rs +++ b/tests/integration_tests_rust.rs @@ -17,8 +17,8 @@ use bitcoin::hashes::Hash; use bitcoin::{Address, Amount, ScriptBuf}; use common::logging::{init_log_logger, validate_log_entry, MultiNodeLogger, TestLogWriter}; use common::{ - bump_fee_and_broadcast, distribute_funds_unconfirmed, do_channel_full_cycle, - expect_channel_pending_event, expect_channel_ready_event, expect_event, + bump_fee_and_broadcast, create_test_entropy, distribute_funds_unconfirmed, + do_channel_full_cycle, expect_channel_pending_event, expect_channel_ready_event, expect_event, expect_payment_claimable_event, expect_payment_received_event, expect_payment_successful_event, expect_splice_pending_event, generate_blocks_and_wait, open_channel, open_channel_push_amt, premine_and_distribute_funds, premine_blocks, prepare_rbf, random_config, @@ -27,7 +27,6 @@ use common::{ TestSyncStore, }; use ldk_node::config::{AsyncPaymentsRole, EsploraSyncConfig}; -use ldk_node::entropy::NodeEntropy; use ldk_node::liquidity::LSPS2ServiceConfig; use ldk_node::payment::{ ConfirmationStatus, PaymentDetails, PaymentDirection, PaymentKind, PaymentStatus, @@ -2445,10 +2444,8 @@ async fn persistence_backwards_compatibility() { let storage_path = common::random_storage_path().to_str().unwrap().to_owned(); let seed_bytes = [42u8; 64]; - #[cfg(feature = "uniffi")] - let node_entropy = Arc::new(NodeEntropy::from_seed_bytes(seed_bytes.to_vec()).unwrap()); - #[cfg(not(feature = "uniffi"))] - let node_entropy = NodeEntropy::from_seed_bytes(seed_bytes); + + let node_entropy = create_test_entropy(seed_bytes); // Setup a v0.6.2 `Node` let (old_balance, old_node_id) = { @@ -2485,7 +2482,7 @@ async fn persistence_backwards_compatibility() { 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(); + let node_new = builder_new.build(node_entropy.into()).unwrap(); node_new.start().unwrap(); node_new.sync_wallets().unwrap();