diff --git a/lightning/src/ln/functional_test_utils.rs b/lightning/src/ln/functional_test_utils.rs index de0b4c7d4bb..50bbb9fdcea 100644 --- a/lightning/src/ln/functional_test_utils.rs +++ b/lightning/src/ln/functional_test_utils.rs @@ -3193,6 +3193,10 @@ pub fn fail_payment<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expected_path: & } pub fn create_chanmon_cfgs(node_count: usize) -> Vec { + create_chanmon_cfgs_with_params(node_count, false) +} + +pub fn create_chanmon_cfgs_with_params(node_count: usize, legacy_channel_keys_derivation: bool) -> Vec { let mut chan_mon_cfgs = Vec::new(); for i in 0..node_count { let tx_broadcaster = test_utils::TestBroadcaster::new(Network::Testnet); @@ -3201,7 +3205,8 @@ pub fn create_chanmon_cfgs(node_count: usize) -> Vec { let logger = test_utils::TestLogger::with_id(format!("node {}", i)); let persister = test_utils::TestPersister::new(); let seed = [i as u8; 32]; - let keys_manager = test_utils::TestKeysInterface::new(&seed, Network::Testnet); + let mut keys_manager = test_utils::TestKeysInterface::new(&seed, Network::Testnet); + keys_manager.legacy_channel_keys_derivation = legacy_channel_keys_derivation; let scorer = RwLock::new(test_utils::TestScorer::new()); chan_mon_cfgs.push(TestChanMonCfg { tx_broadcaster, fee_estimator, chain_source, logger, persister, keys_manager, scorer }); diff --git a/lightning/src/ln/monitor_tests.rs b/lightning/src/ln/monitor_tests.rs index 4aad8f569fc..2d36c74e245 100644 --- a/lightning/src/ln/monitor_tests.rs +++ b/lightning/src/ln/monitor_tests.rs @@ -2242,8 +2242,9 @@ fn test_claimable_balance_correct_while_payment_pending() { fn do_test_restored_packages_retry(check_old_monitor_retries_after_upgrade: bool) { // Tests that we'll retry packages that were previously timelocked after we've restored them. - let chanmon_cfgs = create_chanmon_cfgs(2); - let node_cfgs = create_node_cfgs(2, &chanmon_cfgs); + let chanmon_cfgs = create_chanmon_cfgs_with_params(2, true); + let mut node_cfgs = create_node_cfgs(2, &chanmon_cfgs); + let persister; let new_chain_monitor; diff --git a/lightning/src/util/test_utils.rs b/lightning/src/util/test_utils.rs index 122d7f0af48..229e97e1c63 100644 --- a/lightning/src/util/test_utils.rs +++ b/lightning/src/util/test_utils.rs @@ -1240,6 +1240,7 @@ pub struct TestKeysInterface { enforcement_states: Mutex>>>, expectations: Mutex>>, pub unavailable_signers_ops: Mutex>>, + pub legacy_channel_keys_derivation: bool, } impl EntropySource for TestKeysInterface { @@ -1292,7 +1293,11 @@ impl SignerProvider for TestKeysInterface { type TaprootSigner = TestChannelSigner; fn generate_channel_keys_id(&self, inbound: bool, channel_value_satoshis: u64, user_channel_id: u128) -> [u8; 32] { - self.backing.generate_channel_keys_id(inbound, channel_value_satoshis, user_channel_id) + let mut channel_keys_id = self.backing.generate_channel_keys_id(inbound, channel_value_satoshis, user_channel_id); + if self.legacy_channel_keys_derivation { + channel_keys_id[0] = 0; + } + channel_keys_id } fn derive_channel_signer(&self, channel_value_satoshis: u64, channel_keys_id: [u8; 32]) -> TestChannelSigner { @@ -1344,6 +1349,7 @@ impl TestKeysInterface { enforcement_states: Mutex::new(new_hash_map()), expectations: Mutex::new(None), unavailable_signers_ops: Mutex::new(new_hash_map()), + legacy_channel_keys_derivation: false, } }