Remove automatic channel acceptance
What changed, and why it matters
This commit removes the automatic acceptance of incoming Lightning channels in the LDK library. Previously, users could set a flag to automatically accept inbound channel requests. Now, every inbound channel request must be explicitly approved by the user through an OpenChannelRequest event. This is a deliberate design change to ensure users verify they have enough on-chain funds to cover fees, especially with upcoming anchor channel defaults. It is not a fix for an active vulnerability, but it prevents accidental or unsafe channel acceptance.
Review downstream applications using LDK to ensure they handle `Event::OpenChannelRequest` and call `accept_inbound_channel` (or reject) for every inbound channel. Update configuration code that sets `manually_accept_inbound_channels`, as the field no longer exists. Consider this a breaking API/behavior change rather than an emergency patch.
Security signals we found
Removal of automatic inbound channel acceptance path
Mandatory manual approval via Event::OpenChannelRequest
Preparation for anchor channels default, requiring on-chain fee reserve awareness
Prevents accidental acceptance of zero-conf or anchor channels without user review
No CVE, advisory, or exploit code present in commit or references
Evidence from the diff
The commit removes the manually_accept_inbound_channels configuration option from UserConfig and changes ChannelManager::internal_open_channel so that all inbound OpenChannel messages now generate an Event::OpenChannelRequest and store the request in inbound_channel_request_by_id instead of immediately creating and accepting the channel. The previous automatic acceptance path (which created InboundV1Channel/PendingV2Channel directly and sent AcceptChannel) is deleted. Documentation, serialization/deserialization, and many tests are updated to reflect the new mandatory manual acceptance flow. The change is framed by the authors as preparation for defaulting to anchor channels, which require users to confirm adequate on-chain reserves for force-close fee bumping.
Changed components
lightning/src/ln/channelmanager.rslightning/src/util/config.rslightning/src/events/mod.rslightning/src/ln/channel_state.rslightning/src/ln/functional_test_utils.rsfuzz targets and integration testsInspect captured patch +323 / −466
diff --git a/fuzz/src/chanmon_consistency.rs b/fuzz/src/chanmon_consistency.rs
index 5fb0743..30b95c2 100644
--- a/fuzz/src/chanmon_consistency.rs
+++ b/fuzz/src/chanmon_consistency.rs
@@ -712,7 +712,6 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out, anchors: bool) {
config.reject_inbound_splices = false;
if anchors {
config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
- config.manually_accept_inbound_channels = true;
}
let network = Network::Bitcoin;
let best_block_timestamp = genesis_block(network).header.time;
@@ -763,7 +762,6 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out, anchors: bool) {
config.reject_inbound_splices = false;
if anchors {
config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
- config.manually_accept_inbound_channels = true;
}
let mut monitors = new_hash_map();
@@ -874,30 +872,28 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out, anchors: bool) {
$dest.handle_open_channel($source.get_our_node_id(), &open_channel);
let accept_channel = {
- if anchors {
- let events = $dest.get_and_clear_pending_events();
- assert_eq!(events.len(), 1);
- if let events::Event::OpenChannelRequest {
- ref temporary_channel_id,
- ref counterparty_node_id,
- ..
- } = events[0]
- {
- let mut random_bytes = [0u8; 16];
- random_bytes
- .copy_from_slice(&$dest_keys_manager.get_secure_random_bytes()[..16]);
- let user_channel_id = u128::from_be_bytes(random_bytes);
- $dest
- .accept_inbound_channel(
- temporary_channel_id,
- counterparty_node_id,
- user_channel_id,
- None,
- )
- .unwrap();
- } else {
- panic!("Wrong event type");
- }
+ let events = $dest.get_and_clear_pending_events();
+ assert_eq!(events.len(), 1);
+ if let events::Event::OpenChannelRequest {
+ ref temporary_channel_id,
+ ref counterparty_node_id,
+ ..
+ } = events[0]
+ {
+ let mut random_bytes = [0u8; 16];
+ random_bytes
+ .copy_from_slice(&$dest_keys_manager.get_secure_random_bytes()[..16]);
+ let user_channel_id = u128::from_be_bytes(random_bytes);
+ $dest
+ .accept_inbound_channel(
+ temporary_channel_id,
+ counterparty_node_id,
+ user_channel_id,
+ None,
+ )
+ .unwrap();
+ } else {
+ panic!("Wrong event type");
}
let events = $dest.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 1);
diff --git a/fuzz/src/full_stack.rs b/fuzz/src/full_stack.rs
index 600335b..3bcc9fc 100644
--- a/fuzz/src/full_stack.rs
+++ b/fuzz/src/full_stack.rs
@@ -42,15 +42,13 @@ use lightning::chain::{BestBlock, ChannelMonitorUpdateStatus, Confirm, Listen};
use lightning::events::bump_transaction::sync::WalletSourceSync;
use lightning::events::Event;
use lightning::ln::channel_state::ChannelDetails;
-use lightning::ln::channelmanager::{
- ChainParameters, ChannelManager, InterceptId, PaymentId,
-};
+use lightning::ln::channelmanager::{ChainParameters, ChannelManager, InterceptId, PaymentId};
use lightning::ln::functional_test_utils::*;
use lightning::ln::inbound_payment::ExpandedKey;
+use lightning::ln::outbound_payment::{RecipientOnionFields, Retry};
use lightning::ln::peer_handler::{
IgnoringMessageHandler, MessageHandler, PeerManager, SocketDescriptor,
};
-use lightning::ln::outbound_payment::{RecipientOnionFields, Retry};
use lightning::ln::script::ShutdownScript;
use lightning::ln::types::ChannelId;
use lightning::offers::invoice::UnsignedBolt12Invoice;
@@ -1122,6 +1120,17 @@ pub fn do_test(mut data: &[u8], logger: &Arc<dyn Logger>) {
Event::SpliceFailed { .. } => {
// Splice failed, inputs can be re-spent
},
+ Event::OpenChannelRequest {
+ temporary_channel_id, counterparty_node_id, ..
+ } => {
+ let _ = loss_detector.manager.accept_inbound_channel(
+ &temporary_channel_id,
+ &counterparty_node_id,
+ 0,
+ None,
+ );
+ loss_detector.handler.process_events();
+ },
_ => {},
}
}
@@ -1159,7 +1168,7 @@ fn two_peer_forwarding_seed() -> Vec<u8> {
// our network key
ext_from_hex("0100000000000000000000000000000000000000000000000000000000000000", &mut test);
// config
- ext_from_hex("000000000090000000000000000064000100000000000100ffff0000000000000000ffffffffffffffffffffffffffffffff0000000000000000ffffffffffffffff000000ffffffff00ffff1a000400010000020400000000040200000a08ffffffffffffffff000100000000000000", &mut test);
+ ext_from_hex("000000000090000000000000000064000100000000000100ffff0000000000000000ffffffffffffffffffffffffffffffff0000000000000000ffffffffffffffff000000ffffffff00ffff1a000400010000020400000000040200000a08ffffffffffffffff0001000000000000", &mut test);
// new outbound connection with id 0
ext_from_hex("00", &mut test);
@@ -1613,7 +1622,7 @@ fn gossip_exchange_seed() -> Vec<u8> {
// our network key
ext_from_hex("0100000000000000000000000000000000000000000000000000000000000000", &mut test);
// config
- ext_from_hex("000000000090000000000000000064000100000000000100ffff0000000000000000ffffffffffffffffffffffffffffffff0000000000000000ffffffffffffffff000000ffffffff00ffff1a000400010000020400000000040200000a08ffffffffffffffff000100000000000000", &mut test);
+ ext_from_hex("000000000090000000000000000064000100000000000100ffff0000000000000000ffffffffffffffffffffffffffffffff0000000000000000ffffffffffffffff000000ffffffff00ffff1a000400010000020400000000040200000a08ffffffffffffffff0001000000000000", &mut test);
// new outbound connection with id 0
ext_from_hex("00", &mut test);
@@ -1695,7 +1704,7 @@ fn splice_seed() -> Vec<u8> {
// our network key
ext_from_hex("0100000000000000000000000000000000000000000000000000000000000000", &mut test);
// config
- ext_from_hex("000000000090000000000000000064000100000000000100ffff0000000000000000ffffffffffffffffffffffffffffffff0000000000000000ffffffffffffffff000000ffffffff00ffff1a000400010000020400000000040200000a08ffffffffffffffff000100000000000000", &mut test);
+ ext_from_hex("000000000090000000000000000064000100000000000100ffff0000000000000000ffffffffffffffffffffffffffffffff0000000000000000ffffffffffffffff000000ffffffff00ffff1a000400010000020400000000040200000a08ffffffffffffffff0001000000000000", &mut test);
// new outbound connection with id 0
ext_from_hex("00", &mut test);
diff --git a/lightning-background-processor/src/lib.rs b/lightning-background-processor/src/lib.rs
index bb99d65..659e281 100644
--- a/lightning-background-processor/src/lib.rs
+++ b/lightning-background-processor/src/lib.rs
@@ -2610,6 +2610,25 @@ mod tests {
$node_b.node.get_our_node_id()
);
$node_b.node.handle_open_channel($node_a.node.get_our_node_id(), &msg_a);
+ let events = $node_b.node.get_and_clear_pending_events();
+ assert_eq!(events.len(), 1);
+ match &events[0] {
+ Event::OpenChannelRequest {
+ temporary_channel_id, counterparty_node_id, ..
+ } => {
+ $node_b
+ .node
+ .accept_inbound_channel(
+ temporary_channel_id,
+ counterparty_node_id,
+ 42,
+ None,
+ )
+ .unwrap();
+ },
+ _ => panic!("Unexpected event"),
+ };
+
let msg_b = get_event_msg!(
$node_b,
MessageSendEvent::SendAcceptChannel,
diff --git a/lightning-liquidity/tests/lsps2_integration_tests.rs b/lightning-liquidity/tests/lsps2_integration_tests.rs
index 312199e..33a6dd6 100644
--- a/lightning-liquidity/tests/lsps2_integration_tests.rs
+++ b/lightning-liquidity/tests/lsps2_integration_tests.rs
@@ -1155,7 +1155,6 @@ fn client_trusts_lsp_end_to_end_test() {
service_node_config.htlc_interception_flags = HTLCInterceptionFlags::ToInterceptSCIDs as u8;
let mut client_node_config = test_default_channel_config();
- client_node_config.manually_accept_inbound_channels = true;
client_node_config.channel_config.accept_underpaying_htlcs = true;
let node_chanmgrs = create_node_chanmgrs(
3,
@@ -1627,7 +1626,6 @@ fn late_payment_forwarded_and_safe_after_force_close_does_not_broadcast() {
service_node_config.htlc_interception_flags = HTLCInterceptionFlags::ToInterceptSCIDs as u8;
let mut client_node_config = test_default_channel_config();
- client_node_config.manually_accept_inbound_channels = true;
client_node_config.channel_config.accept_underpaying_htlcs = true;
let node_chanmgrs = create_node_chanmgrs(
@@ -1817,7 +1815,6 @@ fn htlc_timeout_before_client_claim_results_in_handling_failed() {
service_node_config.htlc_interception_flags = HTLCInterceptionFlags::ToInterceptSCIDs as u8;
let mut client_node_config = test_default_channel_config();
- client_node_config.manually_accept_inbound_channels = true;
client_node_config.channel_config.accept_underpaying_htlcs = true;
let node_chanmgrs = create_node_chanmgrs(
@@ -2152,7 +2149,6 @@ fn client_trusts_lsp_partial_fee_does_not_trigger_broadcast() {
service_node_config.htlc_interception_flags = HTLCInterceptionFlags::ToInterceptSCIDs as u8;
let mut client_node_config = test_default_channel_config();
- client_node_config.manually_accept_inbound_channels = true;
client_node_config.channel_config.accept_underpaying_htlcs = true;
let node_chanmgrs = create_node_chanmgrs(
diff --git a/lightning/src/events/mod.rs b/lightning/src/events/mod.rs
index 3d860e9..60d934c 100644
--- a/lightning/src/events/mod.rs
+++ b/lightning/src/events/mod.rs
@@ -245,9 +245,7 @@ pub struct ClaimedHTLC {
pub channel_id: ChannelId,
/// The `user_channel_id` of the channel over which the HTLC was received. This is the value
/// passed in to [`ChannelManager::create_channel`] for outbound channels, or to
- /// [`ChannelManager::accept_inbound_channel`] for inbound channels if
- /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
- /// `user_channel_id` will be randomized for an inbound channel.
+ /// [`ChannelManager::accept_inbound_channel`] for inbound channels.
///
/// This field will be zero for a payment that was serialized prior to LDK version 0.0.117. (This
/// should only happen in the case that a payment was claimable prior to LDK version 0.0.117, but
@@ -255,7 +253,6 @@ pub struct ClaimedHTLC {
///
/// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
- /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
pub user_channel_id: u128,
/// The block height at which this HTLC expires.
pub cltv_expiry: u32,
@@ -765,14 +762,11 @@ pub enum Event {
/// The script which should be used in the transaction output.
output_script: ScriptBuf,
/// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
- /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
- /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
- /// `user_channel_id` will be randomized for an inbound channel. This may be zero for objects
- /// serialized with LDK versions prior to 0.0.113.
+ /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels.
+ /// This may be zero for objects serialized with LDK versions prior to 0.0.113.
///
/// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
- /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
user_channel_id: u128,
},
/// Used to indicate that the counterparty node has provided the signature(s) required to
@@ -1404,13 +1398,10 @@ pub enum Event {
/// The `channel_id` of the channel that is pending confirmation.
channel_id: ChannelId,
/// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
- /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
- /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
- /// `user_channel_id` will be randomized for an inbound channel.
+ /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels.
///
/// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
- /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
user_channel_id: u128,
/// The `temporary_channel_id` this channel used to be known by during channel establishment.
///
@@ -1444,13 +1435,10 @@ pub enum Event {
/// The `channel_id` of the channel that is ready.
channel_id: ChannelId,
/// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
- /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
- /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
- /// `user_channel_id` will be randomized for an inbound channel.
+ /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels.
///
/// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
- /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
user_channel_id: u128,
/// The `node_id` of the channel counterparty.
counterparty_node_id: PublicKey,
@@ -1466,11 +1454,10 @@ pub enum Event {
/// process of closure. This includes previously opened channels, and channels that time out from not being funded.
///
/// Note that this event is only triggered for accepted channels: if the
- /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true and the channel is
- /// rejected, no `ChannelClosed` event will be sent.
+ /// [`Event::OpenChannelRequest`] was rejected, no `ChannelClosed` event will be sent.
///
/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
- /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
+ /// [`Event::OpenChannelRequest`]: Event::OpenChannelRequest
///
/// # Failure Behavior and Persistence
/// This event will eventually be replayed after failures-to-handle (i.e., the event handler
@@ -1480,15 +1467,12 @@ pub enum Event {
/// resolving the channel are likely still awaiting confirmation.
channel_id: ChannelId,
/// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
- /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
- /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
- /// `user_channel_id` will be randomized for inbound channels.
+ /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels.
/// This may be zero for inbound channels serialized prior to 0.0.113 and will always be
/// zero for objects serialized with LDK versions prior to 0.0.102.
///
/// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
- /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
user_channel_id: u128,
/// The reason the channel was closed.
reason: ClosureReason,
@@ -1532,13 +1516,10 @@ pub enum Event {
/// The `channel_id` of the channel that has a pending splice funding transaction.
channel_id: ChannelId,
/// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
- /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
- /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
- /// `user_channel_id` will be randomized for an inbound channel.
+ /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels.
///
/// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
- /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
user_channel_id: u128,
/// The `node_id` of the channel counterparty.
counterparty_node_id: PublicKey,
@@ -1565,13 +1546,10 @@ pub enum Event {
/// The `channel_id` of the channel for which the splice failed.
channel_id: ChannelId,
/// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
- /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
- /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
- /// `user_channel_id` will be randomized for an inbound channel.
+ /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels.
///
/// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
- /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
user_channel_id: u128,
/// The `node_id` of the channel counterparty.
counterparty_node_id: PublicKey,
@@ -1604,14 +1582,12 @@ pub enum Event {
},
/// Indicates a request to open a new channel by a peer.
///
+ /// This event is triggered for all inbound requests to open a new channel.
/// To accept the request (and in the case of a dual-funded channel, not contribute funds),
/// call [`ChannelManager::accept_inbound_channel`].
/// To reject the request, call [`ChannelManager::force_close_broadcasting_latest_txn`].
/// Note that a [`ChannelClosed`] event will _not_ be triggered if the channel is rejected.
///
- /// The event is only triggered when a new open channel request is received and the
- /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true.
- ///
/// # Failure Behavior and Persistence
/// This event will eventually be replayed after failures-to-handle (i.e., the event handler
/// returning `Err(ReplayEvent ())`) and won't be persisted across restarts.
@@ -1619,7 +1595,6 @@ pub enum Event {
/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
/// [`ChannelClosed`]: Event::ChannelClosed
/// [`ChannelManager::force_close_broadcasting_latest_txn`]: crate::ln::channelmanager::ChannelManager::force_close_broadcasting_latest_txn
- /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
OpenChannelRequest {
/// The temporary channel ID of the channel requested to be opened.
///
@@ -1861,11 +1836,11 @@ pub enum Event {
///
/// [`ChannelManager::funding_transaction_signed`]: crate::ln::channelmanager::ChannelManager::funding_transaction_signed
counterparty_node_id: PublicKey,
- /// The `user_channel_id` value passed in for outbound channels, or for inbound channels if
- /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
- /// `user_channel_id` will be randomized for inbound channels.
+ /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
+ /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels.
///
- /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
+ /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
+ /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
user_channel_id: u128,
/// The unsigned transaction to be signed and passed back to
/// [`ChannelManager::funding_transaction_signed`].
diff --git a/lightning/src/ln/async_payments_tests.rs b/lightning/src/ln/async_payments_tests.rs
index 528cec4..8a991b1 100644
--- a/lightning/src/ln/async_payments_tests.rs
+++ b/lightning/src/ln/async_payments_tests.rs
@@ -3057,7 +3057,6 @@ fn intercepted_hold_htlc() {
let chanmon_cfgs = create_chanmon_cfgs(4);
let node_cfgs = create_node_cfgs(4, &chanmon_cfgs);
let (sender_cfg, mut recipient_cfg) = (often_offline_node_cfg(), often_offline_node_cfg());
- recipient_cfg.manually_accept_inbound_channels = true;
recipient_cfg.channel_handshake_limits.force_announced_channel_preference = false;
let mut lsp_cfg = test_default_channel_config();
diff --git a/lightning/src/ln/async_signer_tests.rs b/lightning/src/ln/async_signer_tests.rs
index 53187c1..adaf976 100644
--- a/lightning/src/ln/async_signer_tests.rs
+++ b/lightning/src/ln/async_signer_tests.rs
@@ -37,12 +37,9 @@ fn test_open_channel() {
fn do_test_open_channel(zero_conf: bool) {
// Simulate acquiring the commitment point for `open_channel` and `accept_channel` asynchronously.
- let mut manually_accept_config = test_default_channel_config();
- manually_accept_config.manually_accept_inbound_channels = zero_conf;
-
let chanmon_cfgs = create_chanmon_cfgs(2);
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
- let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, Some(manually_accept_config)]);
+ let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
let node_a_id = nodes[0].node.get_our_node_id();
let node_b_id = nodes[1].node.get_our_node_id();
@@ -89,8 +86,15 @@ fn do_test_open_channel(zero_conf: bool) {
ev => panic!("Expected OpenChannelRequest, not {:?}", ev),
}
} else {
- let msgs = nodes[1].node.get_and_clear_pending_msg_events();
- assert!(msgs.is_empty(), "Expected no message events; got {:?}", msgs);
+ let events = nodes[1].node.get_and_clear_pending_events();
+ assert_eq!(events.len(), 1, "Expected one event, got {}", events.len());
+ match &events[0] {
+ Event::OpenChannelRequest { temporary_channel_id, .. } => nodes[1]
+ .node
+ .accept_inbound_channel(temporary_channel_id, &node_a_id, 0, None)
+ .unwrap(),
+ ev => panic!("Expected OpenChannelRequest, not {:?}", ev),
+ }
}
let channel_id_1 = {
@@ -131,7 +135,7 @@ fn do_test_funding_created(signer_ops: Vec<SignerOp>) {
// nodes[0] --- open_channel --> nodes[1]
let mut open_chan_msg = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, node_b_id);
- nodes[1].node.handle_open_channel(node_a_id, &open_chan_msg);
+ handle_and_accept_open_channel(&nodes[1], node_a_id, &open_chan_msg);
// nodes[0] <-- accept_channel --- nodes[1]
nodes[0].node.handle_accept_channel(
@@ -208,7 +212,7 @@ fn do_test_funding_signed(signer_ops: Vec<SignerOp>) {
// nodes[0] --- open_channel --> nodes[1]
let mut open_chan_msg = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, node_b_id);
- nodes[1].node.handle_open_channel(node_a_id, &open_chan_msg);
+ handle_and_accept_open_channel(&nodes[1], node_a_id, &open_chan_msg);
// nodes[0] <-- accept_channel --- nodes[1]
nodes[0].node.handle_accept_channel(
@@ -365,7 +369,6 @@ fn test_funding_signed_0conf() {
fn do_test_funding_signed_0conf(signer_ops: Vec<SignerOp>) {
// Simulate acquiring the signature for `funding_signed` asynchronously for a zero-conf channel.
let mut manually_accept_config = test_default_channel_config();
- manually_accept_config.manually_accept_inbound_channels = true;
let chanmon_cfgs = create_chanmon_cfgs(2);
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
@@ -999,7 +1002,6 @@ fn do_test_async_holder_signatures(keyed_anchors: bool, p2a_anchor: bool, remote
let mut config = test_default_channel_config();
config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = keyed_anchors;
config.channel_handshake_config.negotiate_anchor_zero_fee_commitments = p2a_anchor;
- config.manually_accept_inbound_channels = keyed_anchors || p2a_anchor;
let chanmon_cfgs = create_chanmon_cfgs(2);
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
diff --git a/lightning/src/ln/chanmon_update_fail_tests.rs b/lightning/src/ln/chanmon_update_fail_tests.rs
index 3fa2073..6cf7bce 100644
--- a/lightning/src/ln/chanmon_update_fail_tests.rs
+++ b/lightning/src/ln/chanmon_update_fail_tests.rs
@@ -2129,10 +2129,8 @@ fn do_during_funding_monitor_fail(
let node_b_id = nodes[1].node.get_our_node_id();
nodes[0].node.create_channel(node_b_id, 100000, 10001, 43, None, None).unwrap();
- nodes[1].node.handle_open_channel(
- node_a_id,
- &get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, node_b_id),
- );
+ let open_channel_msg = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, node_b_id);
+ handle_and_accept_open_channel(&nodes[1], node_a_id, &open_channel_msg);
nodes[0].node.handle_accept_channel(
node_b_id,
&get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, node_a_id),
@@ -3218,7 +3216,6 @@ fn do_test_outbound_reload_without_init_mon(use_0conf: bool) {
let new_chain_monitor;
let mut chan_config = test_default_channel_config();
- chan_config.manually_accept_inbound_channels = true;
chan_config.channel_handshake_limits.trust_own_funding_0conf = true;
let node_chanmgrs =
@@ -3328,7 +3325,6 @@ fn do_test_inbound_reload_without_init_mon(use_0conf: bool, lock_commitment: boo
let new_chain_monitor;
let mut chan_config = test_default_channel_config();
- chan_config.manually_accept_inbound_channels = true;
chan_config.channel_handshake_limits.trust_own_funding_0conf = true;
let node_chanmgrs =
diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs
index 042b388..be86d32 100644
--- a/lightning/src/ln/channel.rs
+++ b/lightning/src/ln/channel.rs
@@ -17516,7 +17516,6 @@ mod tests {
// Node id for alice and bob doesn't matter to our test vectors.
let bob_node_id = crate::util::test_utils::pubkey(2);
let mut config = UserConfig::default();
- config.manually_accept_inbound_channels = true;
config.channel_handshake_config.negotiate_anchor_zero_fee_commitments = true;
let mut chan = OutboundV1Channel::<&Keys>::new(
diff --git a/lightning/src/ln/channel_open_tests.rs b/lightning/src/ln/channel_open_tests.rs
index 572aa0c..7c2a51e 100644
--- a/lightning/src/ln/channel_open_tests.rs
+++ b/lightning/src/ln/channel_open_tests.rs
@@ -62,7 +62,7 @@ fn test_outbound_chans_unlimited() {
let mut open_channel_msg = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, node_b);
for _ in 0..MAX_UNFUNDED_CHANS_PER_PEER {
- nodes[1].node.handle_open_channel(node_a, &open_channel_msg);
+ handle_and_accept_open_channel(&nodes[1], node_a, &open_channel_msg);
get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, node_a);
open_channel_msg.common_fields.temporary_channel_id =
ChannelId::temporary_from_entropy_source(&nodes[0].keys_manager);
@@ -90,13 +90,10 @@ fn test_outbound_chans_unlimited() {
#[test]
fn test_0conf_limiting() {
- // Tests that we properly limit inbound channels when we have the manual-channel-acceptance
- // flag set and (sometimes) accept channels as 0conf.
+ // Tests that we properly limit inbound channels but accept channels as 0conf.
let chanmon_cfgs = create_chanmon_cfgs(2);
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
- let mut settings = test_default_channel_config();
- settings.manually_accept_inbound_channels = true;
- let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, Some(settings)]);
+ let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
// Note that create_network connects the nodes together for us
@@ -117,17 +114,7 @@ fn test_0conf_limiting() {
);
nodes[1].node.peer_connected(random_pk, init_msg, true).unwrap();
- nodes[1].node.handle_open_channel(random_pk, &open_channel_msg);
- let events = nodes[1].node.get_and_clear_pending_events();
- match events[0] {
- Event::OpenChannelRequest { temporary_channel_id, .. } => {
- nodes[1]
- .node
- .accept_inbound_channel(&temporary_channel_id, &random_pk, 23, None)
- .unwrap();
- },
- _ => panic!("Unexpected event"),
- }
+ handle_and_accept_open_channel(&nodes[1], random_pk, &open_channel_msg);
get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, random_pk);
open_channel_msg.common_fields.temporary_channel_id =
ChannelId::temporary_from_entropy_source(&nodes[0].keys_manager);
@@ -191,7 +178,7 @@ fn test_inbound_anchors_manual_acceptance() {
}
#[test]
-fn test_inbound_anchors_manual_acceptance_overridden() {
+fn test_inbound_anchors_config_overridden() {
let overrides = ChannelConfigOverrides {
handshake_overrides: Some(ChannelHandshakeConfigUpdate {
max_inbound_htlc_value_in_flight_percent_of_channel: Some(5),
@@ -226,15 +213,12 @@ fn test_inbound_zero_fee_commitments_manual_acceptance() {
fn do_test_manual_inbound_accept_with_override(
start_cfg: UserConfig, config_overrides: Option<ChannelConfigOverrides>,
) -> AcceptChannel {
- let mut mannual_accept_cfg = start_cfg.clone();
- mannual_accept_cfg.manually_accept_inbound_channels = true;
-
let chanmon_cfgs = create_chanmon_cfgs(3);
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
let node_chanmgrs = create_node_chanmgrs(
3,
&node_cfgs,
- &[Some(start_cfg.clone()), Some(start_cfg.clone()), Some(mannual_accept_cfg.clone())],
+ &[Some(start_cfg.clone()), Some(start_cfg.clone()), Some(start_cfg)],
);
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
@@ -243,22 +227,6 @@ fn do_test_manual_inbound_accept_with_override(
nodes[0].node.create_channel(node_b, 100_000, 0, 42, None, None).unwrap();
let open_channel_msg = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, node_b);
- nodes[1].node.handle_open_channel(node_a, &open_channel_msg);
- assert!(nodes[1].node.get_and_clear_pending_events().is_empty());
- let msg_events = nodes[1].node.get_and_clear_pending_msg_events();
- match &msg_events[0] {
- MessageSendEvent::HandleError { node_id, action } => {
- assert_eq!(*node_id, node_a);
- match action {
- ErrorAction::SendErrorMessage { msg } => {
- assert_eq!(msg.data, "No channels with anchor outputs accepted".to_owned())
- },
- _ => panic!("Unexpected error action"),
- }
- },
- _ => panic!("Unexpected event"),
- }
-
nodes[2].node.handle_open_channel(node_a, &open_channel_msg);
let events = nodes[2].node.get_and_clear_pending_events();
match events[0] {
@@ -281,7 +249,6 @@ fn test_anchors_zero_fee_htlc_tx_downgrade() {
let mut receiver_cfg = test_default_channel_config();
receiver_cfg.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
- receiver_cfg.manually_accept_inbound_channels = true;
let start_type = ChannelTypeFeatures::anchors_zero_htlc_fee_and_dependencies();
let end_type = ChannelTypeFeatures::only_static_remote_key();
@@ -303,7 +270,6 @@ fn test_scid_privacy_downgrade() {
receiver_cfg.channel_handshake_config.negotiate_anchor_zero_fee_commitments = true;
receiver_cfg.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
receiver_cfg.channel_handshake_config.negotiate_scid_privacy = true;
- receiver_cfg.manually_accept_inbound_channels = true;
let mut start_type = ChannelTypeFeatures::anchors_zero_fee_commitments();
start_type.set_scid_privacy_required();
@@ -328,7 +294,6 @@ fn test_zero_fee_commitments_downgrade() {
let mut receiver_cfg = test_default_channel_config();
receiver_cfg.channel_handshake_config.negotiate_anchor_zero_fee_commitments = true;
receiver_cfg.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
- receiver_cfg.manually_accept_inbound_channels = true;
let start_type = ChannelTypeFeatures::anchors_zero_fee_commitments();
let downgrade_types = vec![
@@ -348,7 +313,6 @@ fn test_zero_fee_commitments_downgrade_to_static_remote() {
let mut receiver_cfg = test_default_channel_config();
receiver_cfg.channel_handshake_config.negotiate_anchor_zero_fee_commitments = true;
- receiver_cfg.manually_accept_inbound_channels = true;
let start_type = ChannelTypeFeatures::anchors_zero_fee_commitments();
let end_type = ChannelTypeFeatures::only_static_remote_key();
@@ -409,7 +373,6 @@ fn test_no_channel_downgrade() {
let initiator_cfg = test_default_channel_config();
let mut receiver_cfg = test_default_channel_config();
receiver_cfg.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
- receiver_cfg.manually_accept_inbound_channels = true;
let chanmon_cfgs = create_chanmon_cfgs(2);
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
@@ -469,7 +432,7 @@ fn test_channel_resumption_fail_post_funding() {
nodes[0].node.create_channel(node_b_id, 1_000_000, 0, 42, None, None).unwrap();
let open_chan = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, node_b_id);
- nodes[1].node.handle_open_channel(node_a_id, &open_chan);
+ handle_and_accept_open_channel(&nodes[1], node_a_id, &open_chan);
let accept_chan = get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, node_a_id);
nodes[0].node.handle_accept_channel(node_b_id, &accept_chan);
@@ -529,6 +492,22 @@ pub fn test_insane_channel_opens() {
|expected_error_str: &str, message_mutator: fn(msgs::OpenChannel) -> msgs::OpenChannel| {
let open_channel_mutated = message_mutator(open_channel_message.clone());
nodes[1].node.handle_open_channel(node_a_id, &open_channel_mutated);
+ let events = nodes[1].node.get_and_clear_pending_events();
+ match events[0] {
+ Event::OpenChannelRequest {
+ temporary_channel_id, counterparty_node_id, ..
+ } => match nodes[1].node.accept_inbound_channel(
+ &temporary_channel_id,
+ &counterparty_node_id,
+ 42,
+ None,
+ ) {
+ Err(_) => {},
+ _ => panic!(),
+ },
+ _ => panic!("Unexpected event"),
+ }
+
let msg_events = nodes[1].node.get_and_clear_pending_msg_events();
assert_eq!(msg_events.len(), 1);
let expected_regex = regex::Regex::new(expected_error_str).unwrap();
@@ -625,7 +604,6 @@ pub fn test_insane_channel_opens() {
#[xtest(feature = "_externalize_tests")]
fn test_insane_zero_fee_channel_open() {
let mut cfg = UserConfig::default();
- cfg.manually_accept_inbound_channels = true;
cfg.channel_handshake_config.negotiate_anchor_zero_fee_commitments = true;
let chanmon_cfgs = create_chanmon_cfgs(2);
@@ -746,7 +724,7 @@ fn do_test_sanity_on_in_flight_opens(steps: u8) {
if steps & 0x0f == 1 {
return;
}
- nodes[1].node.handle_open_channel(node_a_id, &open_channel);
+ handle_and_accept_open_channel(&nodes[1], node_a_id, &open_channel);
let accept_channel = get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, node_a_id);
if steps & 0x0f == 2 {
@@ -925,17 +903,24 @@ pub fn bolt2_open_channel_sane_dust_limit() {
node0_to_1_send_open_channel.channel_reserve_satoshis = 100001;
nodes[1].node.handle_open_channel(node_a_id, &node0_to_1_send_open_channel);
- let events = nodes[1].node.get_and_clear_pending_msg_events();
- let err_msg = match events[0] {
- MessageSendEvent::HandleError {
- action: ErrorAction::SendErrorMessage { ref msg }, ..
- } => msg.clone(),
+ let events = nodes[1].node.get_and_clear_pending_events();
+ match events[0] {
+ Event::OpenChannelRequest { temporary_channel_id, counterparty_node_id, .. } => match nodes
+ [1]
+ .node
+ .accept_inbound_channel(&temporary_channel_id, &counterparty_node_id, 42, None)
+ {
+ Err(APIError::ChannelUnavailable { err }) => assert_eq!(
+ err,
+ "dust_limit_satoshis (547) is greater than the implementation limit (546)"
+ ),
+ _ => panic!(),
+ },
_ => panic!("Unexpected event"),
- };
- assert_eq!(
- err_msg.data,
- "dust_limit_satoshis (547) is greater than the implementation limit (546)"
- );
+ }
+ let events = nodes[1].node.get_and_clear_pending_msg_events();
+ assert_eq!(events.len(), 1);
+ assert!(matches!(events[0], MessageSendEvent::HandleError { .. }));
}
#[xtest(feature = "_externalize_tests")]
@@ -1022,7 +1007,7 @@ pub fn test_user_configurable_csv_delay() {
// We test msg.to_self_delay <= config.their_to_self_delay is enforced in Chanel::accept_channel()
nodes[0].node.create_channel(node_b_id, 1000000, 1000000, 42, None, None).unwrap();
let open_channel = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, node_b_id);
- nodes[1].node.handle_open_channel(node_a_id, &open_channel);
+ handle_and_accept_open_channel(&nodes[1], node_a_id, &open_channel);
let mut accept_channel =
get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, node_a_id);
@@ -1078,24 +1063,19 @@ pub fn test_user_configurable_csv_delay() {
}
#[xtest(feature = "_externalize_tests")]
-pub fn test_manually_accept_inbound_channel_request() {
- let mut manually_accept_conf = UserConfig::default();
- manually_accept_conf.manually_accept_inbound_channels = true;
- manually_accept_conf.channel_handshake_config.minimum_depth = 1;
+pub fn test_accept_inbound_channel_config_override() {
+ let mut conf = UserConfig::default();
+ conf.channel_handshake_config.minimum_depth = 1;
let chanmon_cfgs = create_chanmon_cfgs(2);
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
- let node_chanmgrs =
- create_node_chanmgrs(2, &node_cfgs, &[None, Some(manually_accept_conf.clone())]);
+ let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, Some(conf.clone())]);
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
let node_a_id = nodes[0].node.get_our_node_id();
let node_b_id = nodes[1].node.get_our_node_id();
- nodes[0]
- .node
- .create_channel(node_b_id, 100000, 10001, 42, None, Some(manually_accept_conf))
- .unwrap();
+ nodes[0].node.create_channel(node_b_id, 100000, 10001, 42, None, Some(conf)).unwrap();
let res = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, node_b_id);
nodes[1].node.handle_open_channel(node_a_id, &res);
@@ -1203,28 +1183,19 @@ pub fn test_manually_accept_inbound_channel_request() {
}
#[xtest(feature = "_externalize_tests")]
-pub fn test_manually_reject_inbound_channel_request() {
- let mut manually_accept_conf = UserConfig::default();
- manually_accept_conf.manually_accept_inbound_channels = true;
+pub fn test_reject_inbound_channel_request() {
let chanmon_cfgs = create_chanmon_cfgs(2);
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
- let node_chanmgrs =
- create_node_chanmgrs(2, &node_cfgs, &[None, Some(manually_accept_conf.clone())]);
+ let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
let node_a_id = nodes[0].node.get_our_node_id();
let node_b_id = nodes[1].node.get_our_node_id();
- nodes[0]
- .node
- .create_channel(node_b_id, 100000, 10001, 42, None, Some(manually_accept_conf))
- .unwrap();
+ nodes[0].node.create_channel(node_b_id, 100000, 10001, 42, None, None).unwrap();
let res = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, node_b_id);
nodes[1].node.handle_open_channel(node_a_id, &res);
-
- // Assert that `nodes[1]` has no `MessageSendEvent::SendAcceptChannel` in `msg_events` before
- // rejecting the inbound channel request.
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
let err = "Channel force-closed".to_string();
let events = nodes[1].node.get_and_clear_pending_events();
@@ -1254,29 +1225,19 @@ pub fn test_manually_reject_inbound_channel_request() {
#[xtest(feature = "_externalize_tests")]
pub fn test_can_not_accept_inbound_channel_twice() {
- let mut manually_accept_conf = UserConfig::default();
- manually_accept_conf.manually_accept_inbound_channels = true;
let chanmon_cfgs = create_chanmon_cfgs(2);
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
- let node_chanmgrs =
- create_node_chanmgrs(2, &node_cfgs, &[None, Some(manually_accept_conf.clone())]);
+ let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
let node_a_id = nodes[0].node.get_our_node_id();
let node_b_id = nodes[1].node.get_our_node_id();
- nodes[0]
- .node
- .create_channel(node_b_id, 100000, 10001, 42, None, Some(manually_accept_conf))
- .unwrap();
+ nodes[0].node.create_channel(node_b_id, 100000, 10001, 42, None, None).unwrap();
let res = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, node_b_id);
nodes[1].node.handle_open_channel(node_a_id, &res);
-
- // Assert that `nodes[1]` has no `MessageSendEvent::SendAcceptChannel` in `msg_events` before
- // accepting the inbound channel request.
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
-
let events = nodes[1].node.get_and_clear_pending_events();
match events[0] {
Event::OpenChannelRequest { temporary_channel_id, .. } => {
@@ -1359,7 +1320,7 @@ pub fn test_duplicate_temporary_channel_id_from_different_peers() {
// Assert that `nodes[0]` can accept both `OpenChannel` requests, even though they use the same
// `temporary_channel_id` as they are from different peers.
- nodes[0].node.handle_open_channel(node_b_id, &open_chan_msg_chan_1_0);
+ handle_and_accept_open_channel(&nodes[0], node_b_id, &open_chan_msg_chan_1_0);
{
let events = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 1);
@@ -1375,7 +1336,7 @@ pub fn test_duplicate_temporary_channel_id_from_different_peers() {
}
}
- nodes[0].node.handle_open_channel(node_c_id, &open_chan_msg_chan_2_0);
+ handle_and_accept_open_channel(&nodes[0], node_c_id, &open_chan_msg_chan_2_0);
{
let events = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 1);
@@ -1416,7 +1377,8 @@ pub fn test_duplicate_funding_err_in_funding() {
let mut open_chan_msg = get_event_msg!(nodes[2], MessageSendEvent::SendOpenChannel, node_b_id);
let node_c_temp_chan_id = open_chan_msg.common_fields.temporary_channel_id;
open_chan_msg.common_fields.temporary_channel_id = real_channel_id;
- nodes[1].node.handle_open_channel(node_c_id, &open_chan_msg);
+ handle_and_accept_open_channel(&nodes[1], node_c_id, &open_chan_msg);
+
let mut accept_chan_msg =
get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, node_c_id);
accept_chan_msg.common_fields.temporary_channel_id = node_c_temp_chan_id;
@@ -1461,7 +1423,7 @@ pub fn test_duplicate_chan_id() {
// Create an initial channel
nodes[0].node.create_channel(node_b_id, 100000, 10001, 42, None, None).unwrap();
let mut open_chan_msg = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, node_b_id);
- nodes[1].node.handle_open_channel(node_a_id, &open_chan_msg);
+ handle_and_accept_open_channel(&nodes[1], node_a_id, &open_chan_msg);
nodes[0].node.handle_accept_channel(
node_b_id,
&get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, node_a_id),
@@ -1548,7 +1510,7 @@ pub fn test_duplicate_chan_id() {
// Now try to create a second channel which has a duplicate funding output.
nodes[0].node.create_channel(node_b_id, 100000, 10001, 42, None, None).unwrap();
let open_chan_2_msg = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, node_b_id);
- nodes[1].node.handle_open_channel(node_a_id, &open_chan_2_msg);
+ handle_and_accept_open_channel(&nodes[1], node_a_id, &open_chan_2_msg);
nodes[0].node.handle_accept_channel(
node_b_id,
&get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, node_a_id),
@@ -1652,10 +1614,8 @@ pub fn test_invalid_funding_tx() {
let node_b_id = nodes[1].node.get_our_node_id();
nodes[0].node.create_channel(node_b_id, 100_000, 10_000, 42, None, None).unwrap();
- nodes[1].node.handle_open_channel(
- node_a_id,
- &get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, node_b_id),
- );
+ let open_channel_msg = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, node_b_id);
+ handle_and_accept_open_channel(&nodes[1], node_a_id, &open_channel_msg);
nodes[0].node.handle_accept_channel(
node_b_id,
&get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, node_a_id),
@@ -1769,10 +1729,9 @@ pub fn test_coinbase_funding_tx() {
nodes[0].node.create_channel(node_b_id, 100000, 10001, 42, None, None).unwrap();
let open_channel = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, node_b_id);
+ handle_and_accept_open_channel(&nodes[1], node_a_id, &open_channel);
- nodes[1].node.handle_open_channel(node_a_id, &open_channel);
let accept_channel = get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, node_a_id);
-
nodes[0].node.handle_accept_channel(node_b_id, &accept_channel);
// Create the coinbase funding transaction.
@@ -1831,7 +1790,8 @@ pub fn test_non_final_funding_tx() {
nodes[0].node.create_channel(node_b_id, 100_000, 0, 42, None, None).unwrap();
let open_channel_message =
get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, node_b_id);
- nodes[1].node.handle_open_channel(node_a_id, &open_channel_message);
+ handle_and_accept_open_channel(&nodes[1], node_a_id, &open_channel_message);
+
let accept_channel_message =
get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, node_a_id);
nodes[0].node.handle_accept_channel(node_b_id, &accept_channel_message);
@@ -1890,7 +1850,7 @@ pub fn test_non_final_funding_tx_within_headroom() {
nodes[0].node.create_channel(node_b_id, 100_000, 0, 42, None, None).unwrap();
let open_channel_message =
get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, node_b_id);
- nodes[1].node.handle_open_channel(node_a_id, &open_channel_message);
+ handle_and_accept_open_channel(&nodes[1], node_a_id, &open_channel_message);
let accept_channel_message =
get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, node_a_id);
nodes[0].node.handle_accept_channel(node_b_id, &accept_channel_message);
@@ -2364,7 +2324,6 @@ pub fn test_accept_inbound_channel_errors_queued() {
let mut config0 = test_default_channel_config();
let mut config1 = config0.clone();
config1.channel_handshake_limits.their_to_self_delay = 1000;
- config1.manually_accept_inbound_channels = true;
config0.channel_handshake_config.our_to_self_delay = 2000;
let chanmon_cfgs = create_chanmon_cfgs(2);
@@ -2410,8 +2369,8 @@ pub fn test_manual_funding_abandon() {
assert!(nodes[0].node.create_channel(node_b_id, 100_000, 0, 42, None, None).is_ok());
let open_channel = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, node_b_id);
+ handle_and_accept_open_channel(&nodes[1], node_a_id, &open_channel);
- nodes[1].node.handle_open_channel(node_a_id, &open_channel);
let accept_channel = get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, node_a_id);
nodes[0].node.handle_accept_channel(node_b_id, &accept_channel);
@@ -2459,10 +2418,9 @@ pub fn test_funding_signed_event() {
assert!(nodes[0].node.create_channel(node_b_id, 100_000, 0, 42, None, None).is_ok());
let open_channel = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, node_b_id);
+ handle_and_accept_open_channel(&nodes[1], node_a_id, &open_channel);
- nodes[1].node.handle_open_channel(node_a_id, &open_channel);
let accept_channel = get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, node_a_id);
-
nodes[0].node.handle_accept_channel(node_b_id, &accept_channel);
let (temp_channel_id, tx, funding_outpoint) =
create_funding_transaction(&nodes[0], &node_b_id, 100_000, 42);
diff --git a/lightning/src/ln/channel_state.rs b/lightning/src/ln/channel_state.rs
index 86e53ba..9f6a4b0 100644
--- a/lightning/src/ln/channel_state.rs
+++ b/lightning/src/ln/channel_state.rs
@@ -366,14 +366,11 @@ pub struct ChannelDetails {
/// [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat
pub unspendable_punishment_reserve: Option<u64>,
/// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
- /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
- /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
- /// `user_channel_id` will be randomized for an inbound channel. This may be zero for objects
- /// serialized with LDK versions prior to 0.0.113.
+ /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels.
+ /// This may be zero for objects serialized with LDK versions prior to 0.0.113.
///
/// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
- /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
pub user_channel_id: u128,
/// The currently negotiated fee rate denominated in satoshi per 1000 weight units,
/// which is applied to commitment and HTLC transactions.
diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs
index 1e6dae5..f38245b 100644
--- a/lightning/src/ln/channelmanager.rs
+++ b/lightning/src/ln/channelmanager.rs
@@ -1582,10 +1582,10 @@ pub(super) struct PeerState<SP: SignerProvider> {
pub(super) channel_by_id: HashMap<ChannelId, Channel<SP>>,
/// `temporary_channel_id` -> `InboundChannelRequest`.
///
- /// When manual channel acceptance is enabled, this holds all unaccepted inbound channels where
- /// the peer is the counterparty. If the channel is accepted, then the entry in this table is
- /// removed, and an InboundV1Channel is created and placed in the `inbound_v1_channel_by_id` table. If
- /// the channel is rejected, then the entry is simply removed.
+ /// Holds all unaccepted inbound channels where the peer is the counterparty.
+ /// If the channel is accepted, then the entry in this table is removed and a Channel is
+ /// created and placed in the `channel_by_id` table. If the channel is rejected, then
+ /// the entry is simply removed.
pub(super) inbound_channel_request_by_id: HashMap<ChannelId, InboundChannelRequest>,
/// The latest `InitFeatures` we heard from the peer.
latest_features: InitFeatures,
@@ -2092,9 +2092,8 @@ impl<
///
/// ## Accepting Channels
///
-/// Inbound channels are initiated by peers and are automatically accepted unless [`ChannelManager`]
-/// has [`UserConfig::manually_accept_inbound_channels`] set. In that case, the channel may be
-/// either accepted or rejected when handling [`Event::OpenChannelRequest`].
+/// Inbound channels are initiated by peers and must be manually accepted or rejected when
+/// handling [`Event::OpenChannelRequest`].
///
/// ```
/// # use bitcoin::secp256k1::PublicKey;
@@ -10382,7 +10381,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
)
}
- /// Accepts a request to open a channel after a [`events::Event::OpenChannelRequest`], treating
+ /// Accepts a request to open a channel after a [`Event::OpenChannelRequest`], treating
/// it as confirmed immediately.
///
/// The `user_channel_id` parameter will be provided back in
@@ -10672,8 +10671,9 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
num_unfunded_channels + peer.inbound_channel_request_by_id.len()
}
- #[rustfmt::skip]
- fn internal_open_channel(&self, counterparty_node_id: &PublicKey, msg: OpenChannelMessageRef<'_>) -> Result<(), MsgHandleErrInternal> {
+ fn internal_open_channel(
+ &self, counterparty_node_id: &PublicKey, msg: OpenChannelMessageRef<'_>,
+ ) -> Result<(), MsgHandleErrInternal> {
let common_fields = match msg {
OpenChannelMessageRef::V1(msg) => &msg.common_fields,
OpenChannelMessageRef::V2(msg) => &msg.common_fields,
@@ -10684,49 +10684,37 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
// Note that the ChannelManager is NOT re-persisted on disk after this, so any changes are
// likely to be lost on restart!
if common_fields.chain_hash != self.chain_hash {
- return Err(MsgHandleErrInternal::send_err_msg_no_close("Unknown genesis block hash".to_owned(),
- common_fields.temporary_channel_id));
+ return Err(MsgHandleErrInternal::send_err_msg_no_close(
+ "Unknown genesis block hash".to_owned(),
+ common_fields.temporary_channel_id,
+ ));
}
if !self.config.read().unwrap().accept_inbound_channels {
- return Err(MsgHandleErrInternal::send_err_msg_no_close("No inbound channels accepted".to_owned(),
- common_fields.temporary_channel_id));
+ return Err(MsgHandleErrInternal::send_err_msg_no_close(
+ "No inbound channels accepted".to_owned(),
+ common_fields.temporary_channel_id,
+ ));
}
- // Get the number of peers with channels, but without funded ones. We don't care too much
- // about peers that never open a channel, so we filter by peers that have at least one
- // channel, and then limit the number of those with unfunded channels.
- let channeled_peers_without_funding =
- self.peers_without_funded_channels(|node| node.total_channel_count() > 0);
-
let per_peer_state = self.per_peer_state.read().unwrap();
- let peer_state_mutex = per_peer_state.get(counterparty_node_id)
- .ok_or_else(|| {
- debug_assert!(false);
- MsgHandleErrInternal::send_err_msg_no_close(
+ let peer_state_mutex = per_peer_state.get(counterparty_node_id).ok_or_else(|| {
+ debug_assert!(false);
+ MsgHandleErrInternal::send_err_msg_no_close(
format!("Can't find a peer matching the passed counterparty node_id {counterparty_node_id}"),
common_fields.temporary_channel_id)
- })?;
+ })?;
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
let peer_state = &mut *peer_state_lock;
- // If this peer already has some channels, a new channel won't increase our number of peers
- // with unfunded channels, so as long as we aren't over the maximum number of unfunded
- // channels per-peer we can accept channels from a peer with existing ones.
- if peer_state.total_channel_count() == 0 &&
- channeled_peers_without_funding >= MAX_UNFUNDED_CHANNEL_PEERS &&
- !self.config.read().unwrap().manually_accept_inbound_channels
- {
- return Err(MsgHandleErrInternal::send_err_msg_no_close(
- "Have too many peers with unfunded channels, not accepting new ones".to_owned(),
- common_fields.temporary_channel_id));
- }
-
let best_block_height = self.best_block.read().unwrap().height;
- if Self::unfunded_channel_count(peer_state, best_block_height) >= MAX_UNFUNDED_CHANS_PER_PEER {
+ if Self::unfunded_channel_count(peer_state, best_block_height)
+ >= MAX_UNFUNDED_CHANS_PER_PEER
+ {
return Err(MsgHandleErrInternal::send_err_msg_no_close(
format!("Refusing more than {} unfunded channels.", MAX_UNFUNDED_CHANS_PER_PEER),
- common_fields.temporary_channel_id));
+ common_fields.temporary_channel_id,
+ ));
}
let channel_id = common_fields.temporary_channel_id;
@@ -10734,20 +10722,20 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
if channel_exists {
return Err(MsgHandleErrInternal::send_err_msg_no_close(
"temporary_channel_id collision for the same peer!".to_owned(),
- common_fields.temporary_channel_id));
+ common_fields.temporary_channel_id,
+ ));
}
- // We can get the channel type at this point already as we'll need it immediately in both the
- // manual and the automatic acceptance cases.
- let channel_type = channel::channel_type_from_open_channel(
- common_fields, &self.channel_type_features()
- ).map_err(|e| MsgHandleErrInternal::from_chan_no_close(e, common_fields.temporary_channel_id))?;
+ let channel_type =
+ channel::channel_type_from_open_channel(common_fields, &self.channel_type_features())
+ .map_err(|e| {
+ MsgHandleErrInternal::from_chan_no_close(e, common_fields.temporary_channel_id)
+ })?;
- // If we're doing manual acceptance checks on the channel, then defer creation until we're sure we want to accept.
- if self.config.read().unwrap().manually_accept_inbound_channels {
- let mut pending_events = self.pending_events.lock().unwrap();
- let is_announced = (common_fields.channel_flags & 1) == 1;
- pending_events.push_back((events::Event::OpenChannelRequest {
+ let mut pending_events = self.pending_events.lock().unwrap();
+ let is_announced = (common_fields.channel_flags & 1) == 1;
+ pending_events.push_back((
+ events::Event::OpenChannelRequest {
temporary_channel_id: common_fields.temporary_channel_id,
counterparty_node_id: *counterparty_node_id,
funding_satoshis: common_fields.funding_satoshis,
@@ -10758,67 +10746,19 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
channel_type,
is_announced,
params: common_fields.channel_parameters(),
- }, None));
- peer_state.inbound_channel_request_by_id.insert(channel_id, InboundChannelRequest {
+ },
+ None,
+ ));
+ peer_state.inbound_channel_request_by_id.insert(
+ channel_id,
+ InboundChannelRequest {
open_channel_msg: match msg {
OpenChannelMessageRef::V1(msg) => OpenChannelMessage::V1(msg.clone()),
OpenChannelMessageRef::V2(msg) => OpenChannelMessage::V2(msg.clone()),
},
ticks_remaining: UNACCEPTED_INBOUND_CHANNEL_AGE_LIMIT_TICKS,
- });
- return Ok(());
- }
-
- // Otherwise create the channel right now.
- let mut random_bytes = [0u8; 16];
- random_bytes.copy_from_slice(&self.entropy_source.get_secure_random_bytes()[..16]);
- let user_channel_id = u128::from_be_bytes(random_bytes);
-
- if channel_type.requires_zero_conf() {
- return Err(MsgHandleErrInternal::send_err_msg_no_close("No zero confirmation channels accepted".to_owned(), common_fields.temporary_channel_id));
- }
- if channel_type.requires_anchors_zero_fee_htlc_tx() || channel_type.requires_anchor_zero_fee_commitments() {
- return Err(MsgHandleErrInternal::send_err_msg_no_close("No channels with anchor outputs accepted".to_owned(), common_fields.temporary_channel_id));
- }
-
- let (mut channel, message_send_event) = match msg {
- OpenChannelMessageRef::V1(msg) => {
- let mut channel = InboundV1Channel::new(
- &self.fee_estimator, &self.entropy_source, &self.signer_provider, *counterparty_node_id,
- &self.channel_type_features(), &peer_state.latest_features, msg, user_channel_id,
- &self.config.read().unwrap(), best_block_height, &self.logger, /*is_0conf=*/false
- ).map_err(|e| MsgHandleErrInternal::from_chan_no_close(e, msg.common_fields.temporary_channel_id))?;
- let logger = WithChannelContext::from(&self.logger, &channel.context, None);
- let message_send_event = channel.accept_inbound_channel(&&logger).map(|msg| {
- MessageSendEvent::SendAcceptChannel {
- node_id: *counterparty_node_id,
- msg,
- }
- });
- (Channel::from(channel), message_send_event)
},
- OpenChannelMessageRef::V2(msg) => {
- let channel = PendingV2Channel::new_inbound(
- &self.fee_estimator, &self.entropy_source, &self.signer_provider,
- self.get_our_node_id(), *counterparty_node_id, &self.channel_type_features(),
- &peer_state.latest_features, msg, user_channel_id,
- &self.config.read().unwrap(), best_block_height, &self.logger,
- ).map_err(|e| MsgHandleErrInternal::from_chan_no_close(e, msg.common_fields.temporary_channel_id))?;
- let message_send_event = MessageSendEvent::SendAcceptChannelV2 {
- node_id: *counterparty_node_id,
- msg: channel.accept_inbound_dual_funded_channel(),
- };
- (Channel::from(channel), Some(message_send_event))
- },
- };
-
- let outbound_scid_alias = self.create_and_insert_outbound_scid_alias();
- channel.context_mut().set_outbound_scid_alias(outbound_scid_alias);
-
- if let Some(message_send_event) = message_send_event {
- peer_state.pending_msg_events.push(message_send_event);
- }
- peer_state.channel_by_id.insert(channel.context().channel_id(), channel);
+ );
Ok(())
}
@@ -20168,7 +20108,7 @@ mod tests {
let mut funding_tx = None;
for idx in 0..super::MAX_UNFUNDED_CHANS_PER_PEER {
- nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &open_channel_msg);
+ handle_and_accept_open_channel(&nodes[1], nodes[0].node.get_our_node_id(), &open_channel_msg);
let accept_channel = get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, nodes[0].node.get_our_node_id());
if idx == 0 {
@@ -20242,11 +20182,22 @@ mod tests {
// open channels.
assert!(peer_pks.len() > super::MAX_UNFUNDED_CHANNEL_PEERS - 1);
for i in 0..super::MAX_UNFUNDED_CHANNEL_PEERS - 1 {
- nodes[1].node.handle_open_channel(peer_pks[i], &open_channel_msg);
+ handle_and_accept_open_channel(&nodes[1], peer_pks[i], &open_channel_msg);
get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, peer_pks[i]);
open_channel_msg.common_fields.temporary_channel_id = ChannelId::temporary_from_entropy_source(&nodes[0].keys_manager);
}
nodes[1].node.handle_open_channel(last_random_pk, &open_channel_msg);
+ let events = nodes[1].node.get_and_clear_pending_events();
+ match events[0] {
+ Event::OpenChannelRequest { temporary_channel_id, .. } => {
+ assert!(nodes[1]
+ .node
+ .accept_inbound_channel(&temporary_channel_id, &last_random_pk, 23, None,)
+ .is_err())
+ },
+ _ => panic!("Unexpected event"),
+ }
+
assert_eq!(get_err_msg(&nodes[1], &last_random_pk).channel_id,
open_channel_msg.common_fields.temporary_channel_id);
@@ -20264,7 +20215,7 @@ mod tests {
// Further, because the first channel was funded, we can open another channel with
// last_random_pk.
- nodes[1].node.handle_open_channel(last_random_pk, &open_channel_msg);
+ handle_and_accept_open_channel(&nodes[1], last_random_pk, &open_channel_msg);
get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, last_random_pk);
}
@@ -20625,6 +20576,16 @@ pub mod bench {
}, false).unwrap();
node_a.create_channel(node_b.get_our_node_id(), 8_000_000, 100_000_000, 42, None, None).unwrap();
node_b.handle_open_channel(node_a.get_our_node_id(), &get_event_msg!(node_a_holder, MessageSendEvent::SendOpenChannel, node_b.get_our_node_id()));
+ let events = node_b.get_and_clear_pending_events();
+ assert_eq!(events.len(), 1);
+ match &events[0] {
+ Event::OpenChannelRequest { temporary_channel_id, counterparty_node_id, .. } => {
+ node_b
+ .accept_inbound_channel(temporary_channel_id, counterparty_node_id, 42, None)
+ .unwrap();
+ },
+ _ => panic!("Unexpected event"),
+ };
node_a.handle_accept_channel(node_b.get_our_node_id(), &get_event_msg!(node_b_holder, MessageSendEvent::SendAcceptChannel, node_a.get_our_node_id()));
let tx;
diff --git a/lightning/src/ln/functional_test_utils.rs b/lightning/src/ln/functional_test_utils.rs
index e896575..165c08f 100644
--- a/lightning/src/ln/functional_test_utils.rs
+++ b/lightning/src/ln/functional_test_utils.rs
@@ -30,7 +30,7 @@ use crate::ln::channelmanager::{
RAACommitmentOrder, MIN_CLTV_EXPIRY_DELTA,
};
use crate::ln::funding::FundingTxInput;
-use crate::ln::msgs;
+use crate::ln::msgs::{self, OpenChannel};
use crate::ln::msgs::{
BaseMessageHandler, ChannelMessageHandler, MessageSendEvent, RoutingMessageHandler,
};
@@ -1552,7 +1552,6 @@ pub fn sign_funding_transaction<'a, 'b, 'c>(
tx
}
-// Receiver must have been initialized with manually_accept_inbound_channels set to true.
pub fn open_zero_conf_channel<'a, 'b, 'c, 'd>(
initiator: &'a Node<'b, 'c, 'd>, receiver: &'a Node<'b, 'c, 'd>,
initiator_config: Option<UserConfig>,
@@ -1600,7 +1599,6 @@ pub fn exchange_open_accept_zero_conf_chan<'a, 'b, 'c, 'd>(
accept_channel.common_fields.temporary_channel_id
}
-// Receiver must have been initialized with manually_accept_inbound_channels set to true.
pub fn open_zero_conf_channel_with_value<'a, 'b, 'c, 'd>(
initiator: &'a Node<'b, 'c, 'd>, receiver: &'a Node<'b, 'c, 'd>,
initiator_config: Option<UserConfig>, channel_value_sat: u64, push_msat: u64,
@@ -1698,18 +1696,8 @@ pub fn exchange_open_accept_chan<'a, 'b, 'c>(
.user_channel_id,
42
);
- node_b.node.handle_open_channel(node_a_id, &open_channel_msg);
- if node_b.node.get_current_config().manually_accept_inbound_channels {
- let events = node_b.node.get_and_clear_pending_events();
- assert_eq!(events.len(), 1);
- match &events[0] {
- Event::OpenChannelRequest { temporary_channel_id, counterparty_node_id, .. } => node_b
- .node
- .accept_inbound_channel(temporary_channel_id, counterparty_node_id, 42, None)
- .unwrap(),
- _ => panic!("Unexpected event"),
- };
- }
+ handle_and_accept_open_channel(&node_b, node_a_id, &open_channel_msg);
+
let accept_channel_msg = get_event_msg!(node_b, MessageSendEvent::SendAcceptChannel, node_a_id);
assert_eq!(accept_channel_msg.common_fields.temporary_channel_id, create_chan_id);
node_a.node.handle_accept_channel(node_b_id, &accept_channel_msg);
@@ -1990,7 +1978,8 @@ pub fn create_unannounced_chan_between_nodes_with_value<'a, 'b, 'c, 'd>(
.create_channel(node_b_id, channel_value, push_msat, 42, None, Some(no_announce_cfg))
.unwrap();
let open_channel = get_event_msg!(nodes[a], MessageSendEvent::SendOpenChannel, node_b_id);
- nodes[b].node.handle_open_channel(node_a_id, &open_channel);
+ handle_and_accept_open_channel(&nodes[b], node_a_id, &open_channel);
+
let accept_channel = get_event_msg!(nodes[b], MessageSendEvent::SendAcceptChannel, node_a_id);
nodes[a].node.handle_accept_channel(node_b_id, &accept_channel);
@@ -2058,6 +2047,20 @@ pub fn create_unannounced_chan_between_nodes_with_value<'a, 'b, 'c, 'd>(
(as_channel_ready, tx)
}
+pub fn handle_and_accept_open_channel(node: &Node, counterparty_id: PublicKey, msg: &OpenChannel) {
+ node.node.handle_open_channel(counterparty_id, &msg);
+ let events = node.node.get_and_clear_pending_events();
+ assert_eq!(events.len(), 1);
+ match &events[0] {
+ Event::OpenChannelRequest { temporary_channel_id, counterparty_node_id, .. } => {
+ node.node
+ .accept_inbound_channel(temporary_channel_id, counterparty_node_id, 42, None)
+ .unwrap();
+ },
+ _ => panic!("Unexpected event"),
+ };
+}
+
pub fn update_nodes_with_chan_announce<'a, 'b, 'c, 'd>(
nodes: &'a Vec<Node<'b, 'c, 'd>>, a: usize, b: usize, ann: &msgs::ChannelAnnouncement,
upd_1: &msgs::ChannelUpdate, upd_2: &msgs::ChannelUpdate,
@@ -4551,7 +4554,6 @@ pub fn test_default_channel_config() -> UserConfig {
pub fn test_default_anchors_channel_config() -> UserConfig {
let mut config = test_default_channel_config();
config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
- config.manually_accept_inbound_channels = true;
config
}
@@ -5559,7 +5561,8 @@ pub fn create_batch_channel_funding<'a, 'b, 'c>(
.unwrap();
let open_channel_msg =
get_event_msg!(funding_node, MessageSendEvent::SendOpenChannel, other_node_id);
- other_node.node.handle_open_channel(funding_node_id, &open_channel_msg);
+ handle_and_accept_open_channel(other_node, funding_node_id, &open_channel_msg);
+
let accept_channel_msg =
get_event_msg!(other_node, MessageSendEvent::SendAcceptChannel, funding_node_id);
funding_node.node.handle_accept_channel(other_node_id, &accept_channel_msg);
diff --git a/lightning/src/ln/functional_tests.rs b/lightning/src/ln/functional_tests.rs
index 8e854b3..990f1d5 100644
--- a/lightning/src/ln/functional_tests.rs
+++ b/lightning/src/ln/functional_tests.rs
@@ -1164,7 +1164,6 @@ pub fn do_test_multiple_package_conflicts(p2a_anchor: bool) {
// transaction.
user_cfg.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
user_cfg.channel_handshake_config.negotiate_anchor_zero_fee_commitments = p2a_anchor;
- user_cfg.manually_accept_inbound_channels = true;
let configs = [Some(user_cfg.clone()), Some(user_cfg.clone()), Some(user_cfg)];
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &configs);
@@ -2506,7 +2505,7 @@ pub fn test_peer_disconnected_before_funding_broadcasted() {
let expected_temporary_channel_id =
nodes[0].node.create_channel(node_b_id, 1_000_000, 500_000_000, 42, None, None).unwrap();
let open_channel = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, node_b_id);
- nodes[1].node.handle_open_channel(node_a_id, &open_channel);
+ handle_and_accept_open_channel(&nodes[1], node_a_id, &open_channel);
let accept_channel = get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, node_a_id);
nodes[0].node.handle_accept_channel(node_b_id, &accept_channel);
@@ -6365,11 +6364,11 @@ pub fn test_bump_penalty_txn_on_revoked_htlcs() {
assert_eq!(
node_txn[1].input[0].previous_output,
- revoked_htlc_txn[1].input[0].previous_output
+ revoked_htlc_txn[0].input[0].previous_output
);
assert_eq!(
node_txn[1].input[1].previous_output,
- revoked_htlc_txn[0].input[0].previous_output
+ revoked_htlc_txn[1].input[0].previous_output
);
// node_txn[3] spends the revoked outputs from the revoked_htlc_txn (which only have one
@@ -6787,7 +6786,7 @@ pub fn test_override_0msat_htlc_minimum() {
let res = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, node_b_id);
assert_eq!(res.common_fields.htlc_minimum_msat, 1);
- nodes[1].node.handle_open_channel(node_a_id, &res);
+ handle_and_accept_open_channel(&nodes[1], node_a_id, &res);
let res = get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, node_a_id);
assert_eq!(res.common_fields.htlc_minimum_msat, 1);
}
@@ -7566,7 +7565,7 @@ pub fn test_pre_lockin_no_chan_closed_update() {
// Create an initial channel
nodes[0].node.create_channel(node_b_id, 100000, 10001, 42, None, None).unwrap();
let mut open_chan_msg = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, node_b_id);
- nodes[1].node.handle_open_channel(node_a_id, &open_chan_msg);
+ handle_and_accept_open_channel(&nodes[1], node_a_id, &open_chan_msg);
let accept_chan_msg = get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, node_a_id);
nodes[0].node.handle_accept_channel(node_b_id, &accept_chan_msg);
@@ -7885,9 +7884,8 @@ pub fn test_peer_funding_sidechannel() {
let node_b_id = nodes[1].node.get_our_node_id();
let temp_chan_id_ab = exchange_open_accept_chan(&nodes[0], &nodes[1], 1_000_000, 0);
- let temp_chan_id_ca = exchange_open_accept_chan(&nodes[1], &nodes[0], 1_000_000, 0);
-
let (_, tx, funding_output) = create_funding_transaction(&nodes[0], &node_b_id, 1_000_000, 42);
+ let temp_chan_id_ba = exchange_open_accept_chan(&nodes[1], &nodes[0], 1_000_000, 0);
let cs_funding_events = nodes[1].node.get_and_clear_pending_events();
assert_eq!(cs_funding_events.len(), 1);
@@ -7899,7 +7897,7 @@ pub fn test_peer_funding_sidechannel() {
let output_idx = funding_output.index;
nodes[1]
.node
- .funding_transaction_generated_unchecked(temp_chan_id_ca, node_a_id, tx.clone(), output_idx)
+ .funding_transaction_generated_unchecked(temp_chan_id_ba, node_a_id, tx.clone(), output_idx)
.unwrap();
let funding_created_msg =
get_event_msg!(nodes[1], MessageSendEvent::SendFundingCreated, node_a_id);
@@ -8603,7 +8601,7 @@ fn do_test_max_dust_htlc_exposure(
if on_holder_tx {
open_channel.common_fields.dust_limit_satoshis = 546;
}
- nodes[1].node.handle_open_channel(node_a_id, &open_channel);
+ handle_and_accept_open_channel(&nodes[1], node_a_id, &open_channel);
let mut accept_channel =
get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, node_a_id);
nodes[0].node.handle_accept_channel(node_b_id, &accept_channel);
@@ -9158,7 +9156,6 @@ fn do_test_nondust_htlc_fees_dust_exposure_delta(features: ChannelTypeFeatures)
if features == ChannelTypeFeatures::anchors_zero_htlc_fee_and_dependencies() {
default_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
// in addition to the one above, this setting is also needed to create an anchor channel
- default_config.manually_accept_inbound_channels = true;
}
// Set node 1's max dust htlc exposure to 1msat below `expected_dust_exposure_msat`
@@ -9566,7 +9563,7 @@ pub fn test_remove_expired_outbound_unfunded_channels() {
nodes[0].node.create_channel(node_b_id, 100_000, 0, 42, None, None).unwrap();
let open_channel_message =
get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, node_b_id);
- nodes[1].node.handle_open_channel(node_a_id, &open_channel_message);
+ handle_and_accept_open_channel(&nodes[1], node_a_id, &open_channel_message);
let accept_channel_message =
get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, node_a_id);
nodes[0].node.handle_accept_channel(node_b_id, &accept_channel_message);
@@ -9630,7 +9627,7 @@ pub fn test_remove_expired_inbound_unfunded_channels() {
nodes[0].node.create_channel(node_b_id, 100_000, 0, 42, None, None).unwrap();
let open_channel_message =
get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, node_b_id);
- nodes[1].node.handle_open_channel(node_a_id, &open_channel_message);
+ handle_and_accept_open_channel(&nodes[1], node_a_id, &open_channel_message);
let accept_channel_message =
get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, node_a_id);
nodes[0].node.handle_accept_channel(node_b_id, &accept_channel_message);
@@ -9689,9 +9686,6 @@ fn do_test_manual_broadcast_skips_commitment_until_funding(
let chanmon_cfgs = create_chanmon_cfgs(2);
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
let mut chan_config = test_default_channel_config();
- if zero_conf_open {
- chan_config.manually_accept_inbound_channels = true;
- }
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, Some(chan_config)]);
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
diff --git a/lightning/src/ln/htlc_reserve_unit_tests.rs b/lightning/src/ln/htlc_reserve_unit_tests.rs
index 4c4fbad..e719f5e 100644
--- a/lightning/src/ln/htlc_reserve_unit_tests.rs
+++ b/lightning/src/ln/htlc_reserve_unit_tests.rs
@@ -59,7 +59,7 @@ fn do_test_counterparty_no_reserve(send_from_initiator: bool) {
open_channel_message.channel_reserve_satoshis = 0;
open_channel_message.common_fields.max_htlc_value_in_flight_msat = 100_000_000;
}
- nodes[1].node.handle_open_channel(node_a_id, &open_channel_message);
+ handle_and_accept_open_channel(&nodes[1], node_a_id, &open_channel_message);
// Extract the channel accept message from node1 to node0
let mut accept_channel_message =
@@ -785,7 +785,6 @@ fn test_fee_spike_violation_fails_htlc() {
fn test_zero_fee_commitments_no_fee_spike_buffer() {
let mut cfg = test_default_channel_config();
cfg.channel_handshake_config.negotiate_anchor_zero_fee_commitments = true;
- cfg.manually_accept_inbound_channels = true;
do_test_fee_spike_buffer(Some(cfg), false)
}
@@ -2144,7 +2143,6 @@ pub fn do_test_dust_limit_fee_accounting(can_afford: bool) {
let mut default_config = test_default_channel_config();
default_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
- default_config.manually_accept_inbound_channels = true;
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
let node_chanmgrs =
diff --git a/lightning/src/ln/invoice_utils.rs b/lightning/src/ln/invoice_utils.rs
index 195eb73..3eaa369 100644
--- a/lightning/src/ln/invoice_utils.rs
+++ b/lightning/src/ln/invoice_utils.rs
@@ -1052,7 +1052,7 @@ mod test {
.create_channel(node_a_id, 1_000_000, 500_000_000, 42, None, Some(private_chan_cfg))
.unwrap();
let open_channel = get_event_msg!(nodes[2], MessageSendEvent::SendOpenChannel, node_a_id);
- nodes[0].node.handle_open_channel(node_c_id, &open_channel);
+ handle_and_accept_open_channel(&nodes[0], node_c_id, &open_channel);
let accept_channel =
get_event_msg!(nodes[0], MessageSendEvent::SendAcceptChannel, node_c_id);
nodes[2].node.handle_accept_channel(node_a_id, &accept_channel);
@@ -1583,7 +1583,7 @@ mod test {
.create_channel(node_d_id, 1_000_000, 500_000_000, 42, None, Some(private_chan_cfg))
.unwrap();
let open_channel = get_event_msg!(nodes[1], MessageSendEvent::SendOpenChannel, node_d_id);
- nodes[3].node.handle_open_channel(nodes[1].node.get_our_node_id(), &open_channel);
+ handle_and_accept_open_channel(&nodes[3], node_b_id, &open_channel);
let accept_channel =
get_event_msg!(nodes[3], MessageSendEvent::SendAcceptChannel, node_b_id);
nodes[1].node.handle_accept_channel(nodes[3].node.get_our_node_id(), &accept_channel);
diff --git a/lightning/src/ln/monitor_tests.rs b/lightning/src/ln/monitor_tests.rs
index c3266ae..8074f71 100644
--- a/lightning/src/ln/monitor_tests.rs
+++ b/lightning/src/ln/monitor_tests.rs
@@ -319,10 +319,8 @@ fn do_chanmon_claim_value_coop_close(keyed_anchors: bool, p2a_anchor: bool) {
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
let mut user_config = test_default_channel_config();
user_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
- user_config.manually_accept_inbound_channels = true;
user_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = keyed_anchors;
user_config.channel_handshake_config.negotiate_anchor_zero_fee_commitments = p2a_anchor;
- user_config.manually_accept_inbound_channels = keyed_anchors || p2a_anchor;
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[Some(user_config.clone()), Some(user_config)]);
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
@@ -473,7 +471,6 @@ fn do_test_claim_value_force_close(keyed_anchors: bool, p2a_anchor: bool, prev_c
let mut user_config = test_default_channel_config();
user_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = keyed_anchors;
user_config.channel_handshake_config.negotiate_anchor_zero_fee_commitments = p2a_anchor;
- user_config.manually_accept_inbound_channels = keyed_anchors || p2a_anchor;
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[Some(user_config.clone()), Some(user_config)]);
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
@@ -872,7 +869,6 @@ fn do_test_balances_on_local_commitment_htlcs(keyed_anchors: bool, p2a_anchor: b
let mut user_config = test_default_channel_config();
user_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = keyed_anchors;
user_config.channel_handshake_config.negotiate_anchor_zero_fee_commitments = p2a_anchor;
- user_config.manually_accept_inbound_channels = keyed_anchors || p2a_anchor;
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[Some(user_config.clone()), Some(user_config)]);
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
@@ -1383,7 +1379,6 @@ fn do_test_revoked_counterparty_commitment_balances(keyed_anchors: bool, p2a_anc
let mut user_config = test_default_channel_config();
user_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = keyed_anchors;
user_config.channel_handshake_config.negotiate_anchor_zero_fee_commitments = p2a_anchor;
- user_config.manually_accept_inbound_channels = keyed_anchors || p2a_anchor;
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[Some(user_config.clone()), Some(user_config)]);
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
@@ -1687,7 +1682,6 @@ fn do_test_revoked_counterparty_htlc_tx_balances(keyed_anchors: bool, p2a_anchor
let mut user_config = test_default_channel_config();
user_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = keyed_anchors;
user_config.channel_handshake_config.negotiate_anchor_zero_fee_commitments = p2a_anchor;
- user_config.manually_accept_inbound_channels = keyed_anchors || p2a_anchor;
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[Some(user_config.clone()), Some(user_config)]);
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
@@ -1977,7 +1971,6 @@ fn do_test_revoked_counterparty_aggregated_claims(keyed_anchors: bool, p2a_ancho
let mut user_config = test_default_channel_config();
user_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = keyed_anchors;
user_config.channel_handshake_config.negotiate_anchor_zero_fee_commitments = p2a_anchor;
- user_config.manually_accept_inbound_channels = keyed_anchors || p2a_anchor;
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[Some(user_config.clone()), Some(user_config)]);
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
@@ -2254,7 +2247,6 @@ fn do_test_claimable_balance_correct_while_payment_pending(outbound_payment: boo
let mut user_config = test_default_channel_config();
user_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = keyed_anchors;
user_config.channel_handshake_config.negotiate_anchor_zero_fee_commitments = p2a_anchor;
- user_config.manually_accept_inbound_channels = keyed_anchors || p2a_anchor;
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[Some(user_config.clone()), Some(user_config.clone()), Some(user_config)]);
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
@@ -2402,7 +2394,6 @@ fn do_test_monitor_rebroadcast_pending_claims(keyed_anchors: bool, p2a_anchor: b
let mut config = test_default_channel_config();
config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = keyed_anchors;
config.channel_handshake_config.negotiate_anchor_zero_fee_commitments = p2a_anchor;
- config.manually_accept_inbound_channels = keyed_anchors || p2a_anchor;
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[Some(config.clone()), Some(config)]);
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
@@ -2528,7 +2519,6 @@ fn do_test_yield_anchors_events(have_htlcs: bool, p2a_anchor: bool) {
anchors_config.channel_handshake_config.announce_for_forwarding = true;
anchors_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
anchors_config.channel_handshake_config.negotiate_anchor_zero_fee_commitments = p2a_anchor;
- anchors_config.manually_accept_inbound_channels = true;
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[Some(anchors_config.clone()), Some(anchors_config)]);
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
@@ -2730,7 +2720,6 @@ fn do_test_anchors_aggregated_revoked_htlc_tx(p2a_anchor: bool) {
let mut anchors_config = test_default_channel_config();
anchors_config.channel_handshake_config.announce_for_forwarding = true;
- anchors_config.manually_accept_inbound_channels = true;
anchors_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
anchors_config.channel_handshake_config.negotiate_anchor_zero_fee_commitments = p2a_anchor;
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[Some(anchors_config.clone()), Some(anchors_config.clone())]);
@@ -3037,7 +3026,6 @@ fn do_test_anchors_monitor_fixes_counterparty_payment_script_on_reload(confirm_c
let chain_monitor;
let mut user_config = test_default_channel_config();
user_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
- user_config.manually_accept_inbound_channels = true;
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[Some(user_config.clone()), Some(user_config.clone())]);
let node_deserialized;
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
@@ -3128,7 +3116,6 @@ fn do_test_monitor_claims_with_random_signatures(keyed_anchors: bool, p2a_anchor
let mut user_config = test_default_channel_config();
user_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = keyed_anchors;
user_config.channel_handshake_config.negotiate_anchor_zero_fee_commitments = p2a_anchor;
- user_config.manually_accept_inbound_channels = keyed_anchors || p2a_anchor;
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[Some(user_config.clone()), Some(user_config)]);
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
@@ -3419,7 +3406,6 @@ fn do_test_lost_preimage_monitor_events(on_counterparty_tx: bool, p2a_anchor: bo
// Here we test that losing `MonitorEvent`s that contain HTLC resolution preimages does not
// cause us to lose funds or miss a `PaymentSent` event.
let mut cfg = test_default_channel_config();
- cfg.manually_accept_inbound_channels = true;
cfg.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
cfg.channel_handshake_config.negotiate_anchor_zero_fee_commitments = p2a_anchor;
let cfgs = [Some(cfg.clone()), Some(cfg.clone()), Some(cfg.clone())];
@@ -3601,7 +3587,6 @@ fn do_test_lost_timeout_monitor_events(confirm_tx: CommitmentType, dust_htlcs: b
// Here we test that losing `MonitorEvent`s that contain HTLC resolution via timeouts does not
// cause us to lose a `PaymentFailed` event.
let mut cfg = test_default_channel_config();
- cfg.manually_accept_inbound_channels = true;
cfg.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
cfg.channel_handshake_config.negotiate_anchor_zero_fee_commitments = p2a_anchor;
let cfgs = [Some(cfg.clone()), Some(cfg.clone()), Some(cfg.clone())];
diff --git a/lightning/src/ln/payment_tests.rs b/lightning/src/ln/payment_tests.rs
index f73c55f..e24ad48 100644
--- a/lightning/src/ln/payment_tests.rs
+++ b/lightning/src/ln/payment_tests.rs
@@ -1020,7 +1020,6 @@ fn do_test_completed_payment_not_retryable_on_reload(use_dust: bool) {
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
let mut manually_accept_config = test_default_channel_config();
- manually_accept_config.manually_accept_inbound_channels = true;
let persist_1;
let chain_monitor_1;
@@ -2210,7 +2209,6 @@ fn do_test_intercepted_payment(test: InterceptTest) {
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
let mut zero_conf_chan_config = test_default_channel_config();
- zero_conf_chan_config.manually_accept_inbound_channels = true;
let mut intercept_forwards_config = test_default_channel_config();
intercept_forwards_config.htlc_interception_flags =
HTLCInterceptionFlags::ToInterceptSCIDs as u8;
@@ -4959,7 +4957,6 @@ fn test_htlc_forward_considers_anchor_outputs_value() {
// balance to dip below the reserve when considering the value of anchor outputs.
let mut config = test_default_channel_config();
config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
- config.manually_accept_inbound_channels = true;
config.channel_config.forwarding_fee_base_msat = 0;
config.channel_config.forwarding_fee_proportional_millionths = 0;
diff --git a/lightning/src/ln/priv_short_conf_tests.rs b/lightning/src/ln/priv_short_conf_tests.rs
index 2035af1..9d30d74 100644
--- a/lightning/src/ln/priv_short_conf_tests.rs
+++ b/lightning/src/ln/priv_short_conf_tests.rs
@@ -448,7 +448,7 @@ fn test_scid_privacy_negotiation() {
.as_ref()
.unwrap()
.supports_scid_privacy());
- nodes[1].node.handle_open_channel(node_a_id, &second_open_channel);
+ handle_and_accept_open_channel(&nodes[1], node_a_id, &second_open_channel);
nodes[0].node.handle_accept_channel(
node_b_id,
&get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, node_a_id),
@@ -501,7 +501,7 @@ fn test_inbound_scid_privacy() {
assert!(open_channel.common_fields.channel_type.as_ref().unwrap().requires_scid_privacy());
- nodes[2].node.handle_open_channel(node_b_id, &open_channel);
+ handle_and_accept_open_channel(&nodes[2], node_b_id, &open_channel);
let accept_channel = get_event_msg!(nodes[2], MessageSendEvent::SendAcceptChannel, node_b_id);
nodes[1].node.handle_accept_channel(node_c_id, &accept_channel);
@@ -781,7 +781,6 @@ fn test_simple_0conf_channel() {
let chanmon_cfgs = create_chanmon_cfgs(2);
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
let mut chan_config = test_default_channel_config();
- chan_config.manually_accept_inbound_channels = true;
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, Some(chan_config)]);
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
@@ -800,7 +799,6 @@ fn test_0conf_channel_with_async_monitor() {
let chanmon_cfgs = create_chanmon_cfgs(3);
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
let mut chan_config = test_default_channel_config();
- chan_config.manually_accept_inbound_channels = true;
let node_chanmgrs =
create_node_chanmgrs(3, &node_cfgs, &[None, Some(chan_config.clone()), None]);
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
@@ -997,7 +995,6 @@ fn test_0conf_close_no_early_chan_update() {
let chanmon_cfgs = create_chanmon_cfgs(2);
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
let mut chan_config = test_default_channel_config();
- chan_config.manually_accept_inbound_channels = true;
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, Some(chan_config.clone())]);
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
@@ -1024,7 +1021,6 @@ fn test_public_0conf_channel() {
let chanmon_cfgs = create_chanmon_cfgs(2);
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
let mut chan_config = test_default_channel_config();
- chan_config.manually_accept_inbound_channels = true;
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, Some(chan_config.clone())]);
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
@@ -1086,7 +1082,6 @@ fn test_0conf_channel_reorg() {
let chanmon_cfgs = create_chanmon_cfgs(3);
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
let mut chan_config = test_default_channel_config();
- chan_config.manually_accept_inbound_channels = true;
let node_chanmgrs =
create_node_chanmgrs(3, &node_cfgs, &[None, None, Some(chan_config.clone())]);
@@ -1314,7 +1309,7 @@ fn test_zero_conf_accept_reject() {
let mut channel_type_features = ChannelTypeFeatures::only_static_remote_key();
channel_type_features.set_zero_conf_required();
- // 1. Check we reject zero conf channels by default
+ // Check we can accept zero conf channels via the right method
let chanmon_cfgs = create_chanmon_cfgs(2);
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
@@ -1322,6 +1317,7 @@ fn test_zero_conf_accept_reject() {
let node_a_id = nodes[0].node.get_our_node_id();
let node_b_id = nodes[1].node.get_our_node_id();
+ // 1. First try the non-0conf method to manually accept
nodes[0].node.create_channel(node_b_id, 100000, 10001, 42, None, None).unwrap();
let mut open_channel_msg =
get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, node_b_id);
@@ -1330,41 +1326,6 @@ fn test_zero_conf_accept_reject() {
nodes[1].node.handle_open_channel(node_a_id, &open_channel_msg);
- let msg_events = nodes[1].node.get_and_clear_pending_msg_events();
- match msg_events[0] {
- MessageSendEvent::HandleError {
- action: ErrorAction::SendErrorMessage { ref msg, .. },
- ..
- } => {
- assert_eq!(msg.data, "No zero confirmation channels accepted".to_owned());
- },
- _ => panic!(),
- }
-
- // 2. Check we can manually accept zero conf channels via the right method
- let mut manually_accept_conf = UserConfig::default();
- manually_accept_conf.manually_accept_inbound_channels = true;
-
- let chanmon_cfgs = create_chanmon_cfgs(2);
- let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
- let node_chanmgrs =
- create_node_chanmgrs(2, &node_cfgs, &[None, Some(manually_accept_conf.clone())]);
- let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
- let node_a_id = nodes[0].node.get_our_node_id();
- let node_b_id = nodes[1].node.get_our_node_id();
-
- // 2.1 First try the non-0conf method to manually accept
- nodes[0]
- .node
- .create_channel(node_b_id, 100000, 10001, 42, None, Some(manually_accept_conf.clone()))
- .unwrap();
- let mut open_channel_msg =
- get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, node_b_id);
-
- open_channel_msg.common_fields.channel_type = Some(channel_type_features.clone());
-
- nodes[1].node.handle_open_channel(node_a_id, &open_channel_msg);
-
// Assert that `nodes[1]` has no `MessageSendEvent::SendAcceptChannel` in the `msg_events`.
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
@@ -1392,11 +1353,8 @@ fn test_zero_conf_accept_reject() {
_ => panic!(),
}
- // 2.2 Try again with the 0conf method to manually accept
- nodes[0]
- .node
- .create_channel(node_b_id, 100000, 10001, 42, None, Some(manually_accept_conf))
- .unwrap();
+ // 2. Try again with the 0conf method to manually accept
+ nodes[0].node.create_channel(node_b_id, 100000, 10001, 42, None, None).unwrap();
let mut open_channel_msg =
get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, node_b_id);
@@ -1439,7 +1397,6 @@ fn test_connect_before_funding() {
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
let mut manually_accept_conf = test_default_channel_config();
- manually_accept_conf.manually_accept_inbound_channels = true;
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, Some(manually_accept_conf)]);
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
@@ -1492,7 +1449,6 @@ fn test_0conf_ann_sigs_racing_conf() {
let chanmon_cfgs = create_chanmon_cfgs(2);
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
let mut chan_config = test_default_channel_config();
- chan_config.manually_accept_inbound_channels = true;
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, Some(chan_config.clone())]);
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
diff --git a/lightning/src/ln/reload_tests.rs b/lightning/src/ln/reload_tests.rs
index a8206df..7c66d75 100644
--- a/lightning/src/ln/reload_tests.rs
+++ b/lightning/src/ln/reload_tests.rs
@@ -254,7 +254,7 @@ fn test_manager_serialize_deserialize_events() {
let node_a = nodes.remove(0);
let node_b = nodes.remove(0);
node_a.node.create_channel(node_b.node.get_our_node_id(), channel_value, push_msat, 42, None, None).unwrap();
- node_b.node.handle_open_channel(node_a.node.get_our_node_id(), &get_event_msg!(node_a, MessageSendEvent::SendOpenChannel, node_b.node.get_our_node_id()));
+ handle_and_accept_open_channel(&node_b, node_a.node.get_our_node_id(), &get_event_msg!(node_a, MessageSendEvent::SendOpenChannel, node_b.node.get_our_node_id()));
node_a.node.handle_accept_channel(node_b.node.get_our_node_id(), &get_event_msg!(node_b, MessageSendEvent::SendAcceptChannel, node_a.node.get_our_node_id()));
let (temporary_channel_id, tx, funding_output) = create_funding_transaction(&node_a, &node_b.node.get_our_node_id(), channel_value, 42);
diff --git a/lightning/src/ln/reorg_tests.rs b/lightning/src/ln/reorg_tests.rs
index b56caf9..4c1bdd7 100644
--- a/lightning/src/ln/reorg_tests.rs
+++ b/lightning/src/ln/reorg_tests.rs
@@ -316,6 +316,14 @@ fn do_test_unconf_chan(reload_node: bool, reorg_after_reload: bool, use_funding_
check_added_monitors(&nodes[0], 1);
}
+ let expected_err = "Funding transaction was un-confirmed, originally locked at 6 confs.";
+ if reload_node && !reorg_after_reload {
+ handle_announce_close_broadcast_events(&nodes, 0, 1, true, "Channel closed because of an exception: Funding transaction was un-confirmed, originally locked at 6 confs.");
+ check_added_monitors(&nodes[1], 1);
+ let reason = ClosureReason::CounterpartyForceClosed { peer_msg: UntrustedString(format!("Channel closed because of an exception: {}", expected_err)) };
+ check_closed_event(&nodes[1], 1, reason, &[nodes[0].node.get_our_node_id()], 100000);
+ }
+
if reload_node {
// Since we currently have a background event pending, it's good to test that we survive a
// serialization roundtrip. Further, this tests the somewhat awkward edge-case of dropping
@@ -386,7 +394,6 @@ fn do_test_unconf_chan(reload_node: bool, reorg_after_reload: bool, use_funding_
assert_eq!(txn.len(), 1);
}
- let expected_err = "Funding transaction was un-confirmed, originally locked at 6 confs.";
if reorg_after_reload || !reload_node {
handle_announce_close_broadcast_events(&nodes, 0, 1, true, "Channel closed because of an exception: Funding transaction was un-confirmed, originally locked at 6 confs.");
check_added_monitors(&nodes[1], 1);
@@ -404,7 +411,11 @@ fn do_test_unconf_chan(reload_node: bool, reorg_after_reload: bool, use_funding_
nodes[0].node.peer_connected(nodes[1].node.get_our_node_id(), &Init {
features: nodes[1].node.init_features(), networks: None, remote_network_address: None
}, true).unwrap();
+ nodes[1].node.peer_connected(nodes[0].node.get_our_node_id(), &Init {
+ features: nodes[0].node.init_features(), networks: None, remote_network_address: None
+ }, true).unwrap();
}
+
create_announced_chan_between_nodes(&nodes, 0, 1);
send_payment(&nodes[0], &[&nodes[1]], 8000000);
}
@@ -828,7 +839,6 @@ fn do_test_retries_own_commitment_broadcast_after_reorg(keyed_anchors: bool, p2a
let mut config = test_default_channel_config();
config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = keyed_anchors;
config.channel_handshake_config.negotiate_anchor_zero_fee_commitments = p2a_anchor;
- config.manually_accept_inbound_channels = keyed_anchors || p2a_anchor;
let persister;
let new_chain_monitor;
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[Some(config.clone()), Some(config.clone())]);
@@ -985,7 +995,6 @@ fn do_test_split_htlc_expiry_tracking(use_third_htlc: bool, reorg_out: bool, p2a
// This test relies on being able to consolidate HTLC claims into a single transaction, which
// requires anchors:
let mut config = test_default_channel_config();
- config.manually_accept_inbound_channels = true;
config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
config.channel_handshake_config.negotiate_anchor_zero_fee_commitments = p2a_anchor;
diff --git a/lightning/src/ln/shutdown_tests.rs b/lightning/src/ln/shutdown_tests.rs
index 982dc78..74ffe3c 100644
--- a/lightning/src/ln/shutdown_tests.rs
+++ b/lightning/src/ln/shutdown_tests.rs
@@ -992,6 +992,17 @@ fn test_unsupported_anysegwit_upfront_shutdown_script() {
let mut open_channel = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, node_b_id);
open_channel.common_fields.shutdown_scriptpubkey = Some(anysegwit_shutdown_script.clone());
nodes[1].node.handle_open_channel(node_a_id, &open_channel);
+ let events = nodes[1].node.get_and_clear_pending_events();
+ assert_eq!(events.len(), 1);
+ match &events[0] {
+ Event::OpenChannelRequest { temporary_channel_id, counterparty_node_id, .. } => {
+ assert!(nodes[1]
+ .node
+ .accept_inbound_channel(temporary_channel_id, counterparty_node_id, 42, None,)
+ .is_err());
+ },
+ _ => panic!("Unexpected event"),
+ };
let events = nodes[1].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 1);
@@ -1020,7 +1031,8 @@ fn test_unsupported_anysegwit_upfront_shutdown_script() {
// Check script when handling an accept_channel message
nodes[0].node.create_channel(node_b_id, 100000, 10001, 42, None, None).unwrap();
let open_channel = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, node_b_id);
- nodes[1].node.handle_open_channel(node_a_id, &open_channel);
+ handle_and_accept_open_channel(&nodes[1], node_a_id, &open_channel);
+
let mut accept_channel =
get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, node_a_id);
accept_channel.common_fields.shutdown_scriptpubkey = Some(anysegwit_shutdown_script.clone());
@@ -1058,6 +1070,17 @@ fn test_invalid_upfront_shutdown_script() {
open_channel.common_fields.shutdown_scriptpubkey =
Some(Builder::new().push_int(0).push_slice(&[0, 0]).into_script());
nodes[1].node.handle_open_channel(node_a_id, &open_channel);
+ let events = nodes[1].node.get_and_clear_pending_events();
+ assert_eq!(events.len(), 1);
+ match &events[0] {
+ Event::OpenChannelRequest { temporary_channel_id, counterparty_node_id, .. } => {
+ assert!(nodes[1]
+ .node
+ .accept_inbound_channel(temporary_channel_id, counterparty_node_id, 42, None,)
+ .is_err());
+ },
+ _ => panic!("Unexpected event"),
+ };
let events = nodes[1].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 1);
diff --git a/lightning/src/ln/splicing_tests.rs b/lightning/src/ln/splicing_tests.rs
index cf93c62..618271d 100644
--- a/lightning/src/ln/splicing_tests.rs
+++ b/lightning/src/ln/splicing_tests.rs
@@ -1530,7 +1530,6 @@ fn do_test_propose_splice_while_disconnected(reload: bool, use_0conf: bool) {
let (chain_monitor_0a, chain_monitor_0b, chain_monitor_1a, chain_monitor_1b);
let mut config = test_default_channel_config();
if use_0conf {
- config.manually_accept_inbound_channels = true;
config.channel_handshake_limits.trust_own_funding_0conf = true;
}
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[Some(config.clone()), Some(config)]);
diff --git a/lightning/src/ln/update_fee_tests.rs b/lightning/src/ln/update_fee_tests.rs
index 67a0732..69890fb 100644
--- a/lightning/src/ln/update_fee_tests.rs
+++ b/lightning/src/ln/update_fee_tests.rs
@@ -388,8 +388,6 @@ pub fn do_test_update_fee_that_funder_cannot_afford(channel_type_features: Chann
let mut default_config = test_default_channel_config();
if channel_type_features == ChannelTypeFeatures::anchors_zero_htlc_fee_and_dependencies() {
default_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
- // this setting is also needed to create an anchor channel
- default_config.manually_accept_inbound_channels = true;
}
let node_chanmgrs = create_node_chanmgrs(
@@ -898,6 +896,17 @@ pub fn test_chan_init_feerate_unaffordability() {
get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, node_b_id);
open_channel_msg.push_msat += 1;
nodes[1].node.handle_open_channel(node_a_id, &open_channel_msg);
+ let events = nodes[1].node.get_and_clear_pending_events();
+ assert_eq!(events.len(), 1);
+ match &events[0] {
+ Event::OpenChannelRequest { temporary_channel_id, counterparty_node_id, .. } => {
+ assert!(nodes[1]
+ .node
+ .accept_inbound_channel(temporary_channel_id, counterparty_node_id, 42, None,)
+ .is_err());
+ },
+ _ => panic!("Unexpected event"),
+ }
let msg_events = nodes[1].node.get_and_clear_pending_msg_events();
assert_eq!(msg_events.len(), 1);
@@ -1029,7 +1038,6 @@ pub fn do_cannot_afford_on_holding_cell_release(
100;
if channel_type_features.supports_anchors_zero_fee_htlc_tx() {
default_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
- default_config.manually_accept_inbound_channels = true;
}
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
@@ -1372,7 +1380,6 @@ pub fn test_zero_fee_commitments_no_update_fee() {
// they'll disconnect and warn if they receive them.
let mut cfg = test_default_channel_config();
cfg.channel_handshake_config.negotiate_anchor_zero_fee_commitments = true;
- cfg.manually_accept_inbound_channels = true;
let chanmon_cfgs = create_chanmon_cfgs(2);
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
diff --git a/lightning/src/ln/zero_fee_commitment_tests.rs b/lightning/src/ln/zero_fee_commitment_tests.rs
index 2503ad8..d287b6e 100644
--- a/lightning/src/ln/zero_fee_commitment_tests.rs
+++ b/lightning/src/ln/zero_fee_commitment_tests.rs
@@ -18,7 +18,6 @@ fn test_p2a_anchor_values_under_trims_and_rounds() {
let mut user_cfg = test_default_channel_config();
user_cfg.channel_handshake_config.our_htlc_minimum_msat = 1;
user_cfg.channel_handshake_config.negotiate_anchor_zero_fee_commitments = true;
- user_cfg.manually_accept_inbound_channels = true;
let configs = [Some(user_cfg.clone()), Some(user_cfg)];
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &configs);
@@ -125,7 +124,6 @@ fn test_htlc_claim_chunking() {
user_cfg.channel_handshake_config.our_htlc_minimum_msat = 1;
user_cfg.channel_handshake_config.negotiate_anchor_zero_fee_commitments = true;
user_cfg.channel_handshake_config.our_max_accepted_htlcs = 114;
- user_cfg.manually_accept_inbound_channels = true;
let configs = [Some(user_cfg.clone()), Some(user_cfg)];
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &configs);
@@ -314,7 +312,6 @@ fn test_anchor_tx_too_big() {
user_cfg.channel_handshake_config.our_htlc_minimum_msat = 1;
user_cfg.channel_handshake_config.negotiate_anchor_zero_fee_commitments = true;
user_cfg.channel_handshake_config.our_max_accepted_htlcs = 114;
- user_cfg.manually_accept_inbound_channels = true;
let configs = [Some(user_cfg.clone()), Some(user_cfg)];
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &configs);
diff --git a/lightning/src/util/config.rs b/lightning/src/util/config.rs
index feb326c..1dec7bd 100644
--- a/lightning/src/util/config.rs
+++ b/lightning/src/util/config.rs
@@ -30,14 +30,14 @@ pub struct ChannelHandshakeConfig {
/// both parties have exchanged `splice_locked`.
///
/// A lower-bound of `1` is applied, requiring all channels to have a confirmed commitment
- /// transaction before operation. If you wish to accept channels with zero confirmations, see
- /// [`UserConfig::manually_accept_inbound_channels`] and
+ /// transaction before operation. If you wish to accept channels with zero confirmations,
+ /// manually accept them via [`Event::OpenChannelRequest`] using
/// [`ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`].
///
/// Default value: `6`
///
- /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
/// [`ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel_from_trusted_peer_0conf
+ /// [`Event::OpenChannelRequest`]: crate::events::Event::OpenChannelRequest
pub minimum_depth: u32,
/// Set to the number of blocks we require our counterparty to wait to claim their money (ie
/// the number of blocks we have to punish our counterparty if they broadcast a revoked
@@ -162,15 +162,13 @@ pub struct ChannelHandshakeConfig {
/// will be treated as one million instead, although channel negotiations will
/// fail in that case.)
pub their_channel_reserve_proportional_millionths: u32,
- /// If set, we attempt to negotiate the `anchors_zero_fee_htlc_tx`option for all future
+ /// If set, we attempt to negotiate the `anchors_zero_fee_htlc_tx` option for all future
/// channels. This feature requires having a reserve of onchain funds readily available to bump
/// transactions in the event of a channel force close to avoid the possibility of losing funds.
///
- /// Note that if you wish accept inbound channels with anchor outputs, you must enable
- /// [`UserConfig::manually_accept_inbound_channels`] and manually accept them with
- /// [`ChannelManager::accept_inbound_channel`]. This is done to give you the chance to check
- /// whether your reserve of onchain funds is enough to cover the fees for all existing and new
- /// channels featuring anchor outputs in the event of a force close.
+ /// Upon receiving an [`Event::OpenChannelRequest`] for a channel of this type, you must
+ /// check whether your reserve of onchain funds is enough to cover the fees for all existing
+ /// and new channels featuring anchor outputs in the event of a force close.
///
/// If this option is set, channels may be created that will not be readable by LDK versions
/// prior to 0.0.116, causing [`ChannelManager`]'s read method to return a
@@ -185,6 +183,7 @@ pub struct ChannelHandshakeConfig {
/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
/// [`DecodeError::InvalidValue`]: crate::ln::msgs::DecodeError::InvalidValue
+ /// [`Event::OpenChannelRequest`]: crate::events::Event::OpenChannelRequest
pub negotiate_anchors_zero_fee_htlc_tx: bool,
/// If set, we attempt to negotiate the `zero_fee_commitments` option for all future channels.
@@ -198,11 +197,9 @@ pub struct ChannelHandshakeConfig {
/// funds readily available to bump transactions in the event of a channel force close to avoid
/// the possibility of losing funds.
///
- /// Note that if you wish accept inbound channels with anchor outputs, you must enable
- /// [`UserConfig::manually_accept_inbound_channels`] and manually accept them with
- /// [`ChannelManager::accept_inbound_channel`]. This is done to give you the chance to check
- /// whether your reserve of onchain funds is enough to cover the fees for all existing and new
- /// channels featuring anchor outputs in the event of a force close.
+ /// Upon receiving an [`Event::OpenChannelRequest`] for a channel of this type, you must
+ /// check whether your reserve of onchain funds is enough to cover the fees for all existing
+ /// and new channels featuring anchor outputs in the event of a force close.
///
/// If this option is set, channels may be created that will not be readable by LDK versions
/// prior to 0.2, causing [`ChannelManager`]'s read method to return a
@@ -224,6 +221,7 @@ pub struct ChannelHandshakeConfig {
/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
/// [`DecodeError::InvalidValue`]: crate::ln::msgs::DecodeError::InvalidValue
+ /// [`Event::OpenChannelRequest`]: crate::events::Event::OpenChannelRequest
pub negotiate_anchor_zero_fee_commitments: bool,
/// The maximum number of HTLCs in-flight from our counterparty towards us at the same time.
@@ -998,20 +996,6 @@ pub struct UserConfig {
///
/// Default value: `true`
pub accept_inbound_channels: bool,
- /// If this is set to `true`, the user needs to manually accept inbound requests to open a new
- /// channel.
- ///
- /// When set to `true`, [`Event::OpenChannelRequest`] will be triggered once a request to open a
- /// new inbound channel is received through a [`msgs::OpenChannel`] message. In that case, a
- /// [`msgs::AcceptChannel`] message will not be sent back to the counterparty node unless the
- /// user explicitly chooses to accept the request.
- ///
- /// Default value: `false`
- ///
- /// [`Event::OpenChannelRequest`]: crate::events::Event::OpenChannelRequest
- /// [`msgs::OpenChannel`]: crate::ln::msgs::OpenChannel
- /// [`msgs::AcceptChannel`]: crate::ln::msgs::AcceptChannel
- pub manually_accept_inbound_channels: bool,
/// Flags consisting of OR'd values from [`HTLCInterceptionFlags`] which describe HTLCs
/// forwarded over this node to intercept. Any HTLCs which are intercepted will generate an
/// [`Event::HTLCIntercepted`] event which must be handled to forward or fail the HTLC.
@@ -1092,7 +1076,6 @@ impl Default for UserConfig {
channel_config: ChannelConfig::default(),
accept_forwards_to_priv_channels: false,
accept_inbound_channels: true,
- manually_accept_inbound_channels: false,
htlc_interception_flags: 0,
manually_handle_bolt12_invoices: false,
enable_dual_funded_channels: false,
@@ -1115,7 +1098,6 @@ impl Readable for UserConfig {
channel_config: Readable::read(reader)?,
accept_forwards_to_priv_channels: Readable::read(reader)?,
accept_inbound_channels: Readable::read(reader)?,
- manually_accept_inbound_channels: Readable::read(reader)?,
htlc_interception_flags: Readable::read(reader)?,
manually_handle_bolt12_invoices: Readable::read(reader)?,
enable_dual_funded_channels: Readable::read(reader)?,
Why this scored 36/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.