From b93fe327d25627742584e288dc785283850bd33b Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Wed, 14 Sep 2022 01:05:11 +0000 Subject: [PATCH] Remove all remaining references to `*Features::known` As we move towards specify supported/required feature bits in the module(s) where they are supported, the global `known` feature set constructors no longer make sense. In anticipation of removing the `known` constructor, this commit removes all remaining references to it outside of features.rs. --- lightning/src/chain/chainmonitor.rs | 9 +++---- lightning/src/chain/channelmonitor.rs | 7 +++--- lightning/src/ln/msgs.rs | 2 +- lightning/src/ln/script.rs | 25 ++++++++++++------- .../src/onion_message/functional_tests.rs | 2 +- lightning/src/routing/router.rs | 2 +- lightning/src/util/test_utils.rs | 2 +- 7 files changed, 27 insertions(+), 22 deletions(-) diff --git a/lightning/src/chain/chainmonitor.rs b/lightning/src/chain/chainmonitor.rs index 3d84fdf93..9f15a2a27 100644 --- a/lightning/src/chain/chainmonitor.rs +++ b/lightning/src/chain/chainmonitor.rs @@ -725,8 +725,7 @@ mod tests { use ::{get_htlc_update_msgs, get_local_commitment_txn, get_revoke_commit_msgs, get_route_and_payment_hash, unwrap_send_err}; use chain::{ChannelMonitorUpdateErr, Confirm, Watch}; use chain::channelmonitor::LATENCY_GRACE_PERIOD_BLOCKS; - use ln::channelmanager::PaymentSendFailure; - use ln::features::InitFeatures; + use ln::channelmanager::{self, PaymentSendFailure}; use ln::functional_test_utils::*; use ln::msgs::ChannelMessageHandler; use util::errors::APIError; @@ -741,7 +740,7 @@ mod tests { let node_cfgs = create_node_cfgs(2, &chanmon_cfgs); let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]); let nodes = create_network(2, &node_cfgs, &node_chanmgrs); - create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known()); + create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features()); // Route two payments to be claimed at the same time. let (payment_preimage_1, payment_hash_1, _) = route_payment(&nodes[0], &[&nodes[1]], 1_000_000); @@ -818,7 +817,7 @@ mod tests { let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]); let nodes = create_network(2, &node_cfgs, &node_chanmgrs); let channel = create_announced_chan_between_nodes( - &nodes, 0, 1, InitFeatures::known(), InitFeatures::known()); + &nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features()); // Get a route for later and rebalance the channel somewhat send_payment(&nodes[0], &[&nodes[1]], 10_000_000); @@ -894,7 +893,7 @@ mod tests { let node_cfgs = create_node_cfgs(2, &chanmon_cfgs); let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]); let nodes = create_network(2, &node_cfgs, &node_chanmgrs); - create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known()); + create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features()); chanmon_cfgs[0].persister.chain_sync_monitor_persistences.lock().unwrap().clear(); chanmon_cfgs[0].persister.set_update_ret(Err(ChannelMonitorUpdateErr::PermanentFailure)); diff --git a/lightning/src/chain/channelmonitor.rs b/lightning/src/chain/channelmonitor.rs index 28f3b5999..748adbd03 100644 --- a/lightning/src/chain/channelmonitor.rs +++ b/lightning/src/chain/channelmonitor.rs @@ -3767,8 +3767,7 @@ mod tests { use ln::{PaymentPreimage, PaymentHash}; use ln::chan_utils; use ln::chan_utils::{HTLCOutputInCommitment, ChannelPublicKeys, ChannelTransactionParameters, HolderCommitmentTransaction, CounterpartyChannelTransactionParameters}; - use ln::channelmanager::PaymentSendFailure; - use ln::features::InitFeatures; + use ln::channelmanager::{self, PaymentSendFailure}; use ln::functional_test_utils::*; use ln::script::ShutdownScript; use util::errors::APIError; @@ -3797,9 +3796,9 @@ mod tests { let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]); let nodes = create_network(3, &node_cfgs, &node_chanmgrs); let channel = create_announced_chan_between_nodes( - &nodes, 0, 1, InitFeatures::known(), InitFeatures::known()); + &nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features()); create_announced_chan_between_nodes( - &nodes, 1, 2, InitFeatures::known(), InitFeatures::known()); + &nodes, 1, 2, channelmanager::provided_init_features(), channelmanager::provided_init_features()); // Rebalance somewhat send_payment(&nodes[0], &[&nodes[1]], 10_000_000); diff --git a/lightning/src/ln/msgs.rs b/lightning/src/ln/msgs.rs index 6f2d25a2b..4c103e119 100644 --- a/lightning/src/ln/msgs.rs +++ b/lightning/src/ln/msgs.rs @@ -2063,7 +2063,7 @@ mod tests { let sig_2 = get_sig_on!(privkey_2, secp_ctx, String::from("01010101010101010101010101010101")); let sig_3 = get_sig_on!(privkey_3, secp_ctx, String::from("01010101010101010101010101010101")); let sig_4 = get_sig_on!(privkey_4, secp_ctx, String::from("01010101010101010101010101010101")); - let mut features = ChannelFeatures::known(); + let mut features = ChannelFeatures::empty(); if unknown_features_bits { features = ChannelFeatures::from_le_bytes(vec![0xFF, 0xFF]); } diff --git a/lightning/src/ln/script.rs b/lightning/src/ln/script.rs index 595085114..09363b6b5 100644 --- a/lightning/src/ln/script.rs +++ b/lightning/src/ln/script.rs @@ -7,6 +7,7 @@ use bitcoin::hash_types::{WPubkeyHash, WScriptHash}; use bitcoin::secp256k1::PublicKey; use bitcoin::util::address::WitnessVersion; +use ln::channelmanager; use ln::features::InitFeatures; use ln::msgs::DecodeError; use util::ser::{Readable, Writeable, Writer}; @@ -134,7 +135,7 @@ impl TryFrom