Merge PR 'Tie inbound channel requests to their OpenChannelRequest events' (#5742)
What changed, and why it matters
This change fixes a design weakness in how Lightning Dev Kit handles incoming channel requests. Previously, a malicious peer could cancel a channel request and reuse the same temporary ID for a new request. If a user (or automated bot) still had the old request open, they might accidentally approve the new, different channel while thinking they were approving the original one. The fix adds a unique counter to each request so that approvals can only match the exact request they were meant for.
Treat this as a security-hardening fix with API breakage. Downstream users must update all handlers of `Event::OpenChannelRequest` to capture `inbound_channel_request_counter` and pass it verbatim to the corresponding accept call. Review any automated channel-acceptance logic for stale-event race conditions. No emergency deployment is indicated unless the application automatically accepts inbound channels without user confirmation.
Security signals we found
TOCTOU-like stale-event acceptance prevented by binding event to request via unique counter
Peer can withdraw and re-use temporary_channel_id while old OpenChannelRequest event is still pending
New regression test `test_inbound_channel_request_counter_ties_accept_to_event` demonstrates the fix
Existing test `test_stale_inbound_request_does_not_replace_funded_channel` updated to use counter
API breaking change: accept_inbound_channel signatures gain an extra u64 parameter
Evidence from the diff
The commit introduces an inbound_channel_request_counter field to Event::OpenChannelRequest and requires callers to pass it back unchanged to accept_inbound_channel and accept_inbound_channel_from_trusted_peer. The counter is generated from a per-ChannelManager AtomicCounter, stored in InboundChannelRequest, and validated during acceptance. If the counter does not match the currently pending request for that temporary_channel_id, acceptance fails with APIMisuseError or ChannelUnavailable, preventing a stale event from approving a different, later request. Serialization is backward-compatible: old events without the counter deserialize to 0, which can never match a live request because counters start at 1.
Changed components
lightning/src/ln/channelmanager.rslightning/src/events/mod.rsPublic API: ChannelManager::accept_inbound_channelPublic API: ChannelManager::accept_inbound_channel_from_trusted_peerPublic API: Event::OpenChannelRequestInspect captured patch +496 / −80
### fuzz/src/chanmon_consistency.rs
@@ -2783,6 +2783,7 @@ fn make_channel(
if let events::Event::OpenChannelRequest {
ref temporary_channel_id,
ref counterparty_node_id,
+ ref inbound_channel_request_counter,
..
} = events[0]
{
@@ -2793,6 +2794,7 @@ fn make_channel(
dest.accept_inbound_channel_from_trusted_peer(
temporary_channel_id,
counterparty_node_id,
+ *inbound_channel_request_counter,
user_channel_id,
TrustedChannelFeatures::ZeroReserve,
None,
@@ -2802,6 +2804,7 @@ fn make_channel(
dest.accept_inbound_channel(
temporary_channel_id,
counterparty_node_id,
+ *inbound_channel_request_counter,
user_channel_id,
None,
)
### fuzz/src/full_stack.rs
@@ -1157,11 +1157,15 @@ pub fn do_test(mut data: &[u8], logger: &Arc<dyn Logger + MaybeSend + MaybeSync>
// Splice failed, inputs can be re-spent
},
Event::OpenChannelRequest {
- temporary_channel_id, counterparty_node_id, ..
+ temporary_channel_id,
+ counterparty_node_id,
+ ref inbound_channel_request_counter,
+ ..
} => {
let _ = loss_detector.manager.accept_inbound_channel(
&temporary_channel_id,
&counterparty_node_id,
+ *inbound_channel_request_counter,
0,
None,
);
### lightning-background-processor/src/lib.rs
@@ -2780,13 +2780,17 @@ mod tests {
assert_eq!(events.len(), 1);
match &events[0] {
Event::OpenChannelRequest {
- temporary_channel_id, counterparty_node_id, ..
+ temporary_channel_id,
+ counterparty_node_id,
+ ref inbound_channel_request_counter,
+ ..
} => {
$node_b
.node
.accept_inbound_channel(
temporary_channel_id,
counterparty_node_id,
+ *inbound_channel_request_counter,
42,
None,
)
### lightning-liquidity/tests/lsps2_integration_tests.rs
@@ -3720,13 +3720,21 @@ fn assert_negotiated_delay_limit_enforced(
let events = client_node.node.get_and_clear_pending_events();
assert_eq!(events.len(), 1);
- let temporary_channel_id = match &events[0] {
- Event::OpenChannelRequest { temporary_channel_id, .. } => *temporary_channel_id,
+ let (temporary_channel_id, inbound_channel_request_counter) = match &events[0] {
+ Event::OpenChannelRequest {
+ temporary_channel_id, inbound_channel_request_counter, ..
+ } => (*temporary_channel_id, *inbound_channel_request_counter),
other => panic!("Unexpected event: {:?}", other),
};
client_node
.node
- .accept_inbound_channel(&temporary_channel_id, &service_node_id, user_channel_id, None)
+ .accept_inbound_channel(
+ &temporary_channel_id,
+ &service_node_id,
+ inbound_channel_request_counter,
+ user_channel_id,
+ None,
+ )
.unwrap_or_else(|e| panic!("accept_inbound_channel failed: {:?}", e));
let accept_channel =
@@ -3930,12 +3938,17 @@ fn create_channel_with_manual_broadcast(
let events = client_node.node.get_and_clear_pending_events();
assert_eq!(events.len(), 1);
match events[0] {
- Event::OpenChannelRequest { temporary_channel_id, .. } => {
+ Event::OpenChannelRequest {
+ temporary_channel_id,
+ ref inbound_channel_request_counter,
+ ..
+ } => {
client_node
.node
.accept_inbound_channel_from_trusted_peer(
&temporary_channel_id,
&service_node_id,
+ *inbound_channel_request_counter,
user_channel_id,
TrustedChannelFeatures::ZeroConf,
None,
### lightning/src/events/mod.rs
@@ -1922,6 +1922,18 @@ pub enum Event {
/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
/// [`ChannelManager::force_close_broadcasting_latest_txn`]: crate::ln::channelmanager::ChannelManager::force_close_broadcasting_latest_txn
counterparty_node_id: PublicKey,
+ /// A counter that identifies this specific inbound channel request.
+ ///
+ /// A counterparty may withdraw a channel request (e.g. by sending an `error` message for
+ /// it) and re-use its `temporary_channel_id` for a different request while the
+ /// [`Event::OpenChannelRequest`] for the withdrawn request is still pending. The counter
+ /// ties a response to the exact request this event was generated for: when responding to
+ /// the request, the `inbound_channel_request_counter` must be passed back to the
+ /// `ChannelManager` through [`ChannelManager::accept_inbound_channel`] verbatim,
+ /// unmodified. Accepting with any other value will fail.
+ ///
+ /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
+ inbound_channel_request_counter: u64,
/// The channel value of the requested channel.
funding_satoshis: u64,
/// If `channel_negotiation_type` is `InboundChannelFunds::DualFunded`, this indicates that the peer wishes to
@@ -2588,13 +2600,15 @@ impl Writeable for Event {
&Event::OpenChannelRequest {
ref temporary_channel_id,
ref counterparty_node_id,
+ ref inbound_channel_request_counter,
ref funding_satoshis,
ref channel_negotiation_type,
ref channel_type,
ref is_announced,
ref params,
} => {
55u8.write(writer)?;
+ let inbound_channel_request_counter = Some(*inbound_channel_request_counter);
write_tlv_fields!(writer, {
(1, temporary_channel_id, required),
(3, counterparty_node_id, required),
@@ -2603,6 +2617,7 @@ impl Writeable for Event {
(9, channel_type, required),
(11, is_announced, required),
(13, params, required),
+ (15, inbound_channel_request_counter, option),
});
},
&Event::PaymentClaimed {
@@ -3607,10 +3622,16 @@ impl MaybeReadable for Event {
(9, channel_type, required),
(11, is_announced, required),
(13, params, required),
+ (15, inbound_channel_request_counter, option),
});
Ok(Some(Event::OpenChannelRequest {
temporary_channel_id: temporary_channel_id.0.unwrap(),
counterparty_node_id: counterparty_node_id.0.unwrap(),
+ // Events written before the counter existed never carried one. Such an
+ // event cannot be answered correctly anymore, which `0` ensures by
+ // never matching a live request.
+ inbound_channel_request_counter: inbound_channel_request_counter
+ .unwrap_or(0),
funding_satoshis: funding_satoshis.0.unwrap(),
channel_negotiation_type: channel_negotiation_type.0.unwrap(),
channel_type: channel_type.0.unwrap(),
### lightning/src/ln/async_signer_tests.rs
@@ -75,12 +75,17 @@ fn do_test_open_channel(zero_conf: bool) {
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, .. } => {
+ Event::OpenChannelRequest {
+ temporary_channel_id,
+ ref inbound_channel_request_counter,
+ ..
+ } => {
nodes[1]
.node
.accept_inbound_channel_from_trusted_peer(
temporary_channel_id,
&node_a_id,
+ *inbound_channel_request_counter,
0,
TrustedChannelFeatures::ZeroConf,
None,
@@ -531,12 +536,17 @@ fn do_test_funding_signed_0conf(signer_ops: Vec<SignerOp>) {
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, .. } => {
+ Event::OpenChannelRequest {
+ temporary_channel_id,
+ ref inbound_channel_request_counter,
+ ..
+ } => {
nodes[1]
.node
.accept_inbound_channel_from_trusted_peer(
temporary_channel_id,
&node_a_id,
+ *inbound_channel_request_counter,
0,
TrustedChannelFeatures::ZeroConf,
None,
### lightning/src/ln/chanmon_update_fail_tests.rs
@@ -3221,20 +3221,34 @@ fn do_test_outbound_reload_without_init_mon(use_0conf: bool) {
let events = nodes[1].node.get_and_clear_pending_events();
assert_eq!(events.len(), 1);
match events[0] {
- Event::OpenChannelRequest { temporary_channel_id: chan_id, .. } => {
+ Event::OpenChannelRequest {
+ temporary_channel_id: chan_id,
+ ref inbound_channel_request_counter,
+ ..
+ } => {
if use_0conf {
nodes[1]
.node
.accept_inbound_channel_from_trusted_peer(
&chan_id,
&node_a_id,
+ *inbound_channel_request_counter,
0,
TrustedChannelFeatures::ZeroConf,
None,
)
.unwrap();
} else {
- nodes[1].node.accept_inbound_channel(&chan_id, &node_a_id, 0, None).unwrap();
+ nodes[1]
+ .node
+ .accept_inbound_channel(
+ &chan_id,
+ &node_a_id,
+ *inbound_channel_request_counter,
+ 0,
+ None,
+ )
+ .unwrap();
}
},
_ => panic!("Unexpected event"),
@@ -3337,20 +3351,34 @@ fn do_test_outbound_reload_with_completed_init_mon(use_0conf: bool) {
let events = nodes[1].node.get_and_clear_pending_events();
assert_eq!(events.len(), 1);
match events[0] {
- Event::OpenChannelRequest { temporary_channel_id: chan_id, .. } => {
+ Event::OpenChannelRequest {
+ temporary_channel_id: chan_id,
+ ref inbound_channel_request_counter,
+ ..
+ } => {
if use_0conf {
nodes[1]
.node
.accept_inbound_channel_from_trusted_peer(
&chan_id,
&node_a_id,
+ *inbound_channel_request_counter,
0,
TrustedChannelFeatures::ZeroConf,
None,
)
.unwrap();
} else {
- nodes[1].node.accept_inbound_channel(&chan_id, &node_a_id, 0, None).unwrap();
+ nodes[1]
+ .node
+ .accept_inbound_channel(
+ &chan_id,
+ &node_a_id,
+ *inbound_channel_request_counter,
+ 0,
+ None,
+ )
+ .unwrap();
}
},
_ => panic!("Unexpected event"),
@@ -3469,8 +3497,21 @@ fn test_outbound_reload_funding_confirmed_during_downtime() {
let events = nodes[1].node.get_and_clear_pending_events();
assert_eq!(events.len(), 1);
match events[0] {
- Event::OpenChannelRequest { temporary_channel_id: chan_id, .. } => {
- nodes[1].node.accept_inbound_channel(&chan_id, &node_a_id, 0, None).unwrap();
+ Event::OpenChannelRequest {
+ temporary_channel_id: chan_id,
+ ref inbound_channel_request_counter,
+ ..
+ } => {
+ nodes[1]
+ .node
+ .accept_inbound_channel(
+ &chan_id,
+ &node_a_id,
+ *inbound_channel_request_counter,
+ 0,
+ None,
+ )
+ .unwrap();
},
_ => panic!("Unexpected event"),
};
@@ -3630,20 +3671,34 @@ fn do_test_inbound_reload_without_init_mon(use_0conf: bool, lock_commitment: boo
let events = nodes[1].node.get_and_clear_pending_events();
assert_eq!(events.len(), 1);
match events[0] {
- Event::OpenChannelRequest { temporary_channel_id: chan_id, .. } => {
+ Event::OpenChannelRequest {
+ temporary_channel_id: chan_id,
+ ref inbound_channel_request_counter,
+ ..
+ } => {
if use_0conf {
nodes[1]
.node
.accept_inbound_channel_from_trusted_peer(
&chan_id,
&node_a_id,
+ *inbound_channel_request_counter,
0,
TrustedChannelFeatures::ZeroConf,
None,
)
.unwrap();
} else {
- nodes[1].node.accept_inbound_channel(&chan_id, &node_a_id, 0, None).unwrap();
+ nodes[1]
+ .node
+ .accept_inbound_channel(
+ &chan_id,
+ &node_a_id,
+ *inbound_channel_request_counter,
+ 0,
+ None,
+ )
+ .unwrap();
}
},
_ => panic!("Unexpected event"),
### lightning/src/ln/channel_open_tests.rs
@@ -133,10 +133,15 @@ fn test_0conf_limiting() {
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, .. } => {
+ Event::OpenChannelRequest {
+ temporary_channel_id,
+ ref inbound_channel_request_counter,
+ ..
+ } => {
match nodes[1].node.accept_inbound_channel(
&temporary_channel_id,
&last_random_pk,
+ *inbound_channel_request_counter,
23,
None,
) {
@@ -158,12 +163,17 @@ fn test_0conf_limiting() {
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, .. } => {
+ Event::OpenChannelRequest {
+ temporary_channel_id,
+ ref inbound_channel_request_counter,
+ ..
+ } => {
nodes[1]
.node
.accept_inbound_channel_from_trusted_peer(
&temporary_channel_id,
&last_random_pk,
+ *inbound_channel_request_counter,
23,
TrustedChannelFeatures::ZeroConf,
None,
@@ -228,10 +238,15 @@ fn test_unfunded_channel_peer_limit_multiple_requests() {
// we're already at the limit of peers with unfunded channels.
for event in events {
match event {
- Event::OpenChannelRequest { temporary_channel_id, .. } => {
+ Event::OpenChannelRequest {
+ temporary_channel_id,
+ ref inbound_channel_request_counter,
+ ..
+ } => {
match nodes[1].node.accept_inbound_channel(
&temporary_channel_id,
&last_random_pk,
+ *inbound_channel_request_counter,
23,
None,
) {
@@ -309,9 +324,19 @@ fn do_test_manual_inbound_accept_with_override(
nodes[2].node.handle_open_channel(node_a, &open_channel_msg);
let events = nodes[2].node.get_and_clear_pending_events();
match events[0] {
- Event::OpenChannelRequest { temporary_channel_id, .. } => nodes[2]
+ Event::OpenChannelRequest {
+ temporary_channel_id,
+ ref inbound_channel_request_counter,
+ ..
+ } => nodes[2]
.node
- .accept_inbound_channel(&temporary_channel_id, &node_a, 23, config_overrides)
+ .accept_inbound_channel(
+ &temporary_channel_id,
+ &node_a,
+ *inbound_channel_request_counter,
+ 23,
+ config_overrides,
+ )
.unwrap(),
_ => panic!("Unexpected event"),
}
@@ -570,10 +595,14 @@ pub fn test_insane_channel_opens() {
let events = nodes[1].node.get_and_clear_pending_events();
match events[0] {
Event::OpenChannelRequest {
- temporary_channel_id, counterparty_node_id, ..
+ temporary_channel_id,
+ counterparty_node_id,
+ ref inbound_channel_request_counter,
+ ..
} => match nodes[1].node.accept_inbound_channel(
&temporary_channel_id,
&counterparty_node_id,
+ *inbound_channel_request_counter,
42,
None,
) {
@@ -695,10 +724,15 @@ fn test_insane_zero_fee_channel_open() {
let events = nodes[1].node.get_and_clear_pending_events();
match events[0] {
- Event::OpenChannelRequest { temporary_channel_id, .. } => {
+ Event::OpenChannelRequest {
+ temporary_channel_id,
+ ref inbound_channel_request_counter,
+ ..
+ } => {
match nodes[1].node.accept_inbound_channel(
&temporary_channel_id,
&nodes[0].node.get_our_node_id(),
+ *inbound_channel_request_counter,
23,
None,
) {
@@ -972,11 +1006,18 @@ pub fn bolt2_open_channel_sane_dust_limit() {
nodes[1].node.handle_open_channel(node_a_id, &node0_to_1_send_open_channel);
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)
- {
+ Event::OpenChannelRequest {
+ temporary_channel_id,
+ counterparty_node_id,
+ ref inbound_channel_request_counter,
+ ..
+ } => match nodes[1].node.accept_inbound_channel(
+ &temporary_channel_id,
+ &counterparty_node_id,
+ *inbound_channel_request_counter,
+ 42,
+ None,
+ ) {
Err(APIError::ChannelUnavailable { err }) => assert_eq!(
err,
"dust_limit_satoshis (10001) is greater than the implementation limit (10000)"
@@ -1176,11 +1217,21 @@ pub fn test_accept_inbound_channel_config_override() {
};
let events = nodes[1].node.get_and_clear_pending_events();
match events[0] {
- Event::OpenChannelRequest { temporary_channel_id, .. } => {
+ Event::OpenChannelRequest {
+ temporary_channel_id,
+ ref inbound_channel_request_counter,
+ ..
+ } => {
let config = Some(config_overrides);
nodes[1]
.node
- .accept_inbound_channel(&temporary_channel_id, &node_a_id, 23, config)
+ .accept_inbound_channel(
+ &temporary_channel_id,
+ &node_a_id,
+ *inbound_channel_request_counter,
+ 23,
+ config,
+ )
.unwrap();
},
_ => panic!("Unexpected event"),
@@ -1295,6 +1346,72 @@ pub fn test_reject_inbound_channel_request() {
assert!(nodes[1].node.get_and_clear_pending_events().is_empty());
}
+#[xtest(feature = "_externalize_tests")]
+pub fn test_inbound_channel_request_counter_ties_accept_to_event() {
+ // A peer may withdraw an inbound channel request (e.g. with an `error` message) and re-use
+ // its `temporary_channel_id` for a different request while the event for the withdrawn
+ // request is still pending. Test that the counter handed out in `OpenChannelRequest` ties an
+ // accept to the exact request the event was generated for, so the new request cannot be
+ // accepted in response to the stale event.
+ 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]);
+ 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, 100_000, 0, 42, None, None).unwrap();
+ let mut open_channel_msg =
+ get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, node_b_id);
+ let temporary_channel_id = open_channel_msg.common_fields.temporary_channel_id;
+
+ nodes[1].node.handle_open_channel(node_a_id, &open_channel_msg);
+ let first_counter = match nodes[1].node.get_and_clear_pending_events().pop().unwrap() {
+ Event::OpenChannelRequest { inbound_channel_request_counter, .. } => {
+ inbound_channel_request_counter
+ },
+ _ => panic!("Unexpected event"),
+ };
+
+ // The peer withdraws its request, then re-uses the `temporary_channel_id` for a request
+ // describing a different channel.
+ let error_msg = ErrorMessage { channel_id: temporary_channel_id, data: String::new() };
+ nodes[1].node.handle_error(node_a_id, &error_msg);
+ open_channel_msg.common_fields.funding_satoshis *= 2;
+ nodes[1].node.handle_open_channel(node_a_id, &open_channel_msg);
+ let second_counter = match nodes[1].node.get_and_clear_pending_events().pop().unwrap() {
+ Event::OpenChannelRequest { inbound_channel_request_counter, .. } => {
+ inbound_channel_request_counter
+ },
+ _ => panic!("Unexpected event"),
+ };
+ assert_ne!(first_counter, second_counter);
+
+ // Responding to the withdrawn request's event must fail, without dropping the new request
+ // that now occupies the `temporary_channel_id`.
+ match nodes[1].node.accept_inbound_channel(
+ &temporary_channel_id,
+ &node_a_id,
+ first_counter,
+ 42,
+ None,
+ ) {
+ Err(APIError::APIMisuseError { err }) => {
+ assert_eq!(err, "No such channel awaiting to be accepted.");
+ },
+ Ok(_) => panic!("The withdrawn request's event must not accept the new request"),
+ Err(e) => panic!("Unexpected Error: {:?}", e),
+ }
+
+ // The new request is accepted under the counter its own event was generated with.
+ nodes[1]
+ .node
+ .accept_inbound_channel(&temporary_channel_id, &node_a_id, second_counter, 42, None)
+ .unwrap();
+ get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, node_a_id);
+}
+
#[xtest(feature = "_externalize_tests")]
pub fn test_can_not_accept_inbound_channel_twice() {
let chanmon_cfgs = create_chanmon_cfgs(2);
@@ -1312,13 +1429,28 @@ pub fn test_can_not_accept_inbound_channel_twice() {
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, .. } => {
+ Event::OpenChannelRequest {
+ temporary_channel_id,
+ ref inbound_channel_request_counter,
+ ..
+ } => {
nodes[1]
.node
- .accept_inbound_channel(&temporary_channel_id, &node_a_id, 0, None)
+ .accept_inbound_channel(
+ &temporary_channel_id,
+ &node_a_id,
+ *inbound_channel_request_counter,
+ 0,
+ None,
+ )
.unwrap();
- let api_res =
- nodes[1].node.accept_inbound_channel(&temporary_channel_id, &node_a_id, 0, None);
+ let api_res = nodes[1].node.accept_inbound_channel(
+ &temporary_channel_id,
+ &node_a_id,
+ *inbound_channel_request_counter,
+ 0,
+ None,
+ );
match api_res {
Err(APIError::APIMisuseError { err }) => {
assert_eq!(err, "No such channel awaiting to be accepted.");
@@ -1352,7 +1484,7 @@ pub fn test_can_not_accept_unknown_inbound_channel() {
let node_b_id = nodes[1].node.get_our_node_id();
let unknown_channel_id = ChannelId::new_zero();
- let api_res = nodes[0].node.accept_inbound_channel(&unknown_channel_id, &node_b_id, 0, None);
+ let api_res = nodes[0].node.accept_inbound_channel(&unknown_channel_id, &node_b_id, 0, 0, None);
match api_res {
Err(APIError::APIMisuseError { err }) => {
assert_eq!(err, "No such channel awaiting to be accepted.");
@@ -1507,12 +1639,15 @@ pub fn test_stale_inbound_request_does_not_replace_funded_channel() {
let mut open_b = open_a.clone();
open_b.common_fields.temporary_channel_id = funded_id;
nodes[1].node.handle_open_channel(attacker_id, &open_b);
- match nodes[1].node.get_and_clear_pending_events().pop().unwrap() {
- Event::OpenChannelRequest { temporary_channel_id, .. } => {
+ let stale_request_counter = match nodes[1].node.get_and_clear_pending_events().pop().unwrap() {
+ Event::OpenChannelRequest {
+ temporary_channel_id, inbound_channel_request_counter, ..
+ } => {
assert_eq!(temporary_channel_id, funded_id);
+ inbound_channel_request_counter
},
_ => panic!("Unexpected event"),
- }
+ };
// Fund channel A, taking over the ID the still-pending request was queued under.
nodes[1].node.handle_funding_created(attacker_id, &funding_created);
@@ -1534,7 +1669,13 @@ pub fn test_stale_inbound_request_does_not_replace_funded_channel() {
assert!(original.funding_txo.is_some());
// Accepting the stale request must fail without discarding A's state.
- match nodes[1].node.accept_inbound_channel(&funded_id, &attacker_id, 43, None) {
+ match nodes[1].node.accept_inbound_channel(
+ &funded_id,
+ &attacker_id,
+ stale_request_counter,
+ 43,
+ None,
+ ) {
Err(APIError::ChannelUnavailable { .. }) => {},
Ok(_) => panic!("Accepting a colliding inbound request must fail"),
Err(e) => panic!("Unexpected Error: {:?}", e),
@@ -2486,9 +2627,18 @@ pub fn test_accept_inbound_channel_errors_queued() {
nodes[1].node.handle_open_channel(node_a_id, &open_channel_msg);
let events = nodes[1].node.get_and_clear_pending_events();
match events[0] {
- Event::OpenChannelRequest { temporary_channel_id, .. } => {
- match nodes[1].node.accept_inbound_channel(&temporary_channel_id, &node_a_id, 23, None)
- {
+ Event::OpenChannelRequest {
+ temporary_channel_id,
+ ref inbound_channel_request_counter,
+ ..
+ } => {
+ match nodes[1].node.accept_inbound_channel(
+ &temporary_channel_id,
+ &node_a_id,
+ *inbound_channel_request_counter,
+ 23,
+ None,
+ ) {
Err(APIError::ChannelUnavailable { err: _ }) => (),
_ => panic!(),
}
@@ -2786,12 +2936,17 @@ fn test_holder_selected_0reserve_on_legacy_channel_is_not_allowed() {
nodes[1].node.handle_open_channel(node_a_id, &open_channel_msg_0reserve);
let events = nodes[1].node.get_and_clear_pending_events();
match events[0] {
- Event::OpenChannelRequest { temporary_channel_id, .. } => {
+ Event::OpenChannelRequest {
+ temporary_channel_id,
+ ref inbound_channel_request_counter,
+ ..
+ } => {
let error = nodes[1]
.node
.accept_inbound_channel_from_trusted_peer(
&temporary_channel_id,
&node_a_id,
+ *inbound_channel_request_counter,
42,
TrustedChannelFeatures::ZeroReserve,
None,
### lightning/src/ln/channelmanager.rs
@@ -128,6 +128,7 @@ use crate::types::features::{
};
use crate::types::payment::{PaymentHash, PaymentPreimage, PaymentSecret};
use crate::types::string::UntrustedString;
+use crate::util::atomic_counter::AtomicCounter;
use crate::util::config::{
ChannelConfig, ChannelConfigOverrides, ChannelConfigUpdate, HTLCInterceptionFlags, UserConfig,
};
@@ -2119,6 +2120,7 @@ pub(super) enum OpenChannelMessageRef<'a> {
pub(super) struct InboundChannelRequest {
/// The original OpenChannel message.
pub open_channel_msg: OpenChannelMessage,
+ pub counter: u64,
/// The number of ticks remaining before the request expires.
pub ticks_remaining: i32,
}
@@ -2529,7 +2531,9 @@ impl<
/// # let error_message = "Channel force-closed";
/// channel_manager.process_pending_events(&|event| {
/// match event {
-/// Event::OpenChannelRequest { temporary_channel_id, counterparty_node_id, .. } => {
+/// Event::OpenChannelRequest {
+/// temporary_channel_id, counterparty_node_id, inbound_channel_request_counter, ..
+/// } => {
/// if !is_trusted(counterparty_node_id) {
/// match channel_manager.force_close_broadcasting_latest_txn(
/// &temporary_channel_id, &counterparty_node_id, error_message.to_string()
@@ -2542,7 +2546,8 @@ impl<
///
/// let user_channel_id = 43;
/// match channel_manager.accept_inbound_channel(
-/// &temporary_channel_id, &counterparty_node_id, user_channel_id, None
+/// &temporary_channel_id, &counterparty_node_id, inbound_channel_request_counter,
+/// user_channel_id, None
/// ) {
/// Ok(()) => println!("Accepting channel {}", temporary_channel_id),
/// Err(e) => println!("Error accepting channel {}: {:?}", temporary_channel_id, e),
@@ -3193,6 +3198,10 @@ pub struct ChannelManager<
#[cfg(any(test, feature = "_test_utils"))]
pub(super) pending_events_processor: AtomicU32,
+ /// Source of the counters handed out in [`events::Event::OpenChannelRequest`] to tie an
+ /// inbound channel request to the event it was announced in and the response to that event.
+ inbound_channel_request_counter: AtomicCounter,
+
/// A simple atomic flag to ensure only one task at a time can be processing HTLC forwards via
/// [`Self::process_pending_htlc_forwards`].
pending_htlc_forwards_processor: AtomicBool,
@@ -4132,6 +4141,7 @@ impl<
pending_events: Mutex::new(VecDeque::new()),
pending_events_processor: AtomicU32::new(0),
+ inbound_channel_request_counter: AtomicCounter::new(),
pending_htlc_forwards_processor: AtomicBool::new(false),
pending_background_events: Mutex::new(Vec::new()),
total_consistency_lock: RwLock::new(()),
@@ -12123,6 +12133,13 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
/// and the `counterparty_node_id` parameter is the id of the peer which has requested to open
/// the channel.
///
+ /// The `inbound_channel_request_counter` parameter identifies the specific request being
+ /// accepted, and must be the value the handled [`Event::OpenChannelRequest`] was generated
+ /// with, passed back unmodified. A counterparty may withdraw a channel request and re-use its
+ /// `temporary_channel_id` for a different request while the event is still pending; accepting
+ /// with any other counter than the event's will fail, ensuring only the request the user was
+ /// actually shown can be accepted.
+ ///
/// The `user_channel_id` parameter will be provided back in
/// [`Event::ChannelClosed::user_channel_id`] to allow tracking of which events correspond
/// with which `accept_inbound_channel`/`accept_inbound_channel_from_trusted_peer` call.
@@ -12139,11 +12156,13 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
/// [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id
pub fn accept_inbound_channel(
&self, temporary_channel_id: &ChannelId, counterparty_node_id: &PublicKey,
- user_channel_id: u128, config_overrides: Option<ChannelConfigOverrides>,
+ inbound_channel_request_counter: u64, user_channel_id: u128,
+ config_overrides: Option<ChannelConfigOverrides>,
) -> Result<(), APIError> {
self.do_accept_inbound_channel(
temporary_channel_id,
counterparty_node_id,
+ inbound_channel_request_counter,
None,
user_channel_id,
config_overrides,
@@ -12155,6 +12174,10 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
/// zero-conf and zero-reserve features to be set for the channel, see a description of these
/// features in [`TrustedChannelFeatures`].
///
+ /// The `inbound_channel_request_counter` parameter must be the value the handled
+ /// [`Event::OpenChannelRequest`] was generated with, passed back unmodified. See
+ /// [`ChannelManager::accept_inbound_channel`] for details.
+ ///
/// The `user_channel_id` parameter will be provided back in
/// [`Event::ChannelClosed::user_channel_id`] to allow tracking of which events correspond
/// with which `accept_inbound_channel`/`accept_inbound_channel_from_trusted_peer` call.
@@ -12163,12 +12186,14 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
/// [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id
pub fn accept_inbound_channel_from_trusted_peer(
&self, temporary_channel_id: &ChannelId, counterparty_node_id: &PublicKey,
- user_channel_id: u128, trusted_channel_features: TrustedChannelFeatures,
+ inbound_channel_request_counter: u64, user_channel_id: u128,
+ trusted_channel_features: TrustedChannelFeatures,
config_overrides: Option<ChannelConfigOverrides>,
) -> Result<(), APIError> {
self.do_accept_inbound_channel(
temporary_channel_id,
counterparty_node_id,
+ inbound_channel_request_counter,
Some(trusted_channel_features),
user_channel_id,
config_overrides,
@@ -12178,6 +12203,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
/// TODO(dual_funding): Allow contributions, pass intended amount and inputs
fn do_accept_inbound_channel(
&self, temporary_channel_id: &ChannelId, counterparty_node_id: &PublicKey,
+ inbound_channel_request_counter: u64,
trusted_channel_features: Option<TrustedChannelFeatures>, user_channel_id: u128,
config_overrides: Option<ChannelConfigOverrides>,
) -> Result<(), APIError> {
@@ -12209,12 +12235,16 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
Self::unfunded_channel_count(peer_state, self.best_block.read().unwrap().height)
== peer_state.total_channel_count();
- // Find (and remove) the channel in the unaccepted table. If it's not there, something weird is
- // happening and return an error. N.B. that we create channel with an outbound SCID of zero so
- // that we can delay allocating the SCID until after we're sure that the checks below will
+ // Find (and remove) the channel in the unaccepted table. If it's not there, or if it
+ // doesn't match the counter the user responded with, something weird is happening and we
+ // return an error. N.B. that we create channel with an outbound SCID of zero so that we
+ // can delay allocating the SCID until after we're sure that the checks below will
// succeed.
- let res = match peer_state.inbound_channel_request_by_id.remove(temporary_channel_id) {
- Some(unaccepted_channel) => {
+ let res = match peer_state.inbound_channel_request_by_id.entry(*temporary_channel_id) {
+ hash_map::Entry::Occupied(entry)
+ if entry.get().counter == inbound_channel_request_counter =>
+ {
+ let unaccepted_channel = entry.remove();
let best_block_height = self.best_block.read().unwrap().height;
match unaccepted_channel.open_channel_msg {
OpenChannelMessage::V1(open_channel_msg) => InboundV1Channel::new(
@@ -12277,7 +12307,11 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
}),
}
},
- None => {
+ // Either no request is pending under this `temporary_channel_id`, or the one that is
+ // belongs to a different event than the one the user responded to (e.g. because the
+ // peer withdrew its request and re-used the ID). In the latter case the pending
+ // request must be left alone - it has an event of its own the user has yet to see.
+ _ => {
let err_str = "No such channel awaiting to be accepted.".to_owned();
log_error!(logger, "{}", err_str);
@@ -12496,10 +12530,14 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
let mut pending_events = self.pending_events.lock().unwrap();
let is_announced = (common_fields.channel_flags & 1) == 1;
+ // Counters start at 1 so that an `OpenChannelRequest` event which was serialized without
+ // one (reading back as 0) can never match a live request.
+ let inbound_channel_request_counter = self.inbound_channel_request_counter.next() + 1;
pending_events.push_back((
events::Event::OpenChannelRequest {
temporary_channel_id: common_fields.temporary_channel_id,
counterparty_node_id: *counterparty_node_id,
+ inbound_channel_request_counter,
funding_satoshis: common_fields.funding_satoshis,
channel_negotiation_type: match msg {
OpenChannelMessageRef::V1(msg) => InboundChannelFunds::PushMsat(msg.push_msat),
@@ -12518,6 +12556,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
OpenChannelMessageRef::V1(msg) => OpenChannelMessage::V1(msg.clone()),
OpenChannelMessageRef::V2(msg) => OpenChannelMessage::V2(msg.clone()),
},
+ counter: inbound_channel_request_counter,
ticks_remaining: UNACCEPTED_INBOUND_CHANNEL_AGE_LIMIT_TICKS,
},
);
@@ -21607,6 +21646,7 @@ impl<
pending_events: Mutex::new(pending_events_read),
pending_events_processor: AtomicU32::new(0),
+ inbound_channel_request_counter: AtomicCounter::new(),
pending_htlc_forwards_processor: AtomicBool::new(false),
pending_background_events: Mutex::new(pending_background_events),
total_consistency_lock: RwLock::new(()),
@@ -22813,7 +22853,7 @@ mod tests {
// Test the API functions.
check_not_connected_to_peer_error(nodes[0].node.create_channel(unkown_public_key, 1_000_000, 500_000_000, 42, None, None), unkown_public_key);
- check_unkown_peer_error(nodes[0].node.accept_inbound_channel(&channel_id, &unkown_public_key, 42, None), unkown_public_key);
+ check_unkown_peer_error(nodes[0].node.accept_inbound_channel(&channel_id, &unkown_public_key, 0, 42, None), unkown_public_key);
check_unkown_peer_error(nodes[0].node.close_channel(&channel_id, &unkown_public_key), unkown_public_key);
@@ -22843,7 +22883,7 @@ mod tests {
let error_message = "Channel force-closed";
// Test the API functions.
- check_api_misuse_error(nodes[0].node.accept_inbound_channel(&channel_id, &counterparty_node_id, 42, None));
+ check_api_misuse_error(nodes[0].node.accept_inbound_channel(&channel_id, &counterparty_node_id, 0, 42, None));
check_channel_unavailable_error(nodes[0].node.close_channel(&channel_id, &counterparty_node_id), channel_id, counterparty_node_id);
@@ -22951,10 +22991,10 @@ mod tests {
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, .. } => {
+ Event::OpenChannelRequest { temporary_channel_id, ref inbound_channel_request_counter, .. } => {
assert!(nodes[1]
.node
- .accept_inbound_channel(&temporary_channel_id, &last_random_pk, 23, None,)
+ .accept_inbound_channel(&temporary_channel_id, &last_random_pk, *inbound_channel_request_counter, 23, None,)
.is_err())
},
_ => panic!("Unexpected event"),
@@ -23350,9 +23390,9 @@ pub mod bench {
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, .. } => {
+ Event::OpenChannelRequest { temporary_channel_id, counterparty_node_id, ref inbound_channel_request_counter, .. } => {
node_b
- .accept_inbound_channel(temporary_channel_id, counterparty_node_id, 42, None)
+ .accept_inbound_channel(temporary_channel_id, counterparty_node_id, *inbound_channel_request_counter, 42, None)
.unwrap();
},
_ => panic!("Unexpected event"),
### lightning/src/ln/functional_test_utils.rs
@@ -1706,12 +1706,17 @@ pub fn exchange_open_accept_zero_conf_chan<'a, 'b, 'c, 'd>(
let events = receiver.node.get_and_clear_pending_events();
assert_eq!(events.len(), 1);
match events[0] {
- Event::OpenChannelRequest { temporary_channel_id, .. } => {
+ Event::OpenChannelRequest {
+ temporary_channel_id,
+ ref inbound_channel_request_counter,
+ ..
+ } => {
receiver
.node
.accept_inbound_channel_from_trusted_peer(
&temporary_channel_id,
&initiator_node_id,
+ *inbound_channel_request_counter,
0,
TrustedChannelFeatures::ZeroConf,
None,
@@ -2225,9 +2230,20 @@ pub fn handle_and_accept_open_channel(node: &Node, counterparty_id: PublicKey, m
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, .. } => {
+ Event::OpenChannelRequest {
+ temporary_channel_id,
+ counterparty_node_id,
+ ref inbound_channel_request_counter,
+ ..
+ } => {
node.node
- .accept_inbound_channel(temporary_channel_id, counterparty_node_id, 42, None)
+ .accept_inbound_channel(
+ temporary_channel_id,
+ counterparty_node_id,
+ *inbound_channel_request_counter,
+ 42,
+ None,
+ )
.unwrap();
},
_ => panic!("Unexpected event"),
### lightning/src/ln/functional_tests.rs
@@ -10598,11 +10598,17 @@ pub fn test_cancelled_async_event_processing_can_resume() {
let accepted = Cell::new(0);
let node = nodes[1].node;
let retry_handler = |event: Event| match event {
- Event::OpenChannelRequest { temporary_channel_id, counterparty_node_id, .. } => {
+ Event::OpenChannelRequest {
+ temporary_channel_id,
+ counterparty_node_id,
+ inbound_channel_request_counter,
+ ..
+ } => {
let user_channel_id = accepted.get() as u128 + 50;
node.accept_inbound_channel(
&temporary_channel_id,
&counterparty_node_id,
+ inbound_channel_request_counter,
user_channel_id,
None,
)
@@ -10639,9 +10645,20 @@ pub fn test_cancelled_async_event_processing_can_resume() {
let accepted = Cell::new(false);
let node = nodes[1].node;
let retry_handler = |event: Event| match event {
- Event::OpenChannelRequest { temporary_channel_id, counterparty_node_id, .. } => {
- node.accept_inbound_channel(&temporary_channel_id, &counterparty_node_id, 60, None)
- .unwrap();
+ Event::OpenChannelRequest {
+ temporary_channel_id,
+ counterparty_node_id,
+ ref inbound_channel_request_counter,
+ ..
+ } => {
+ node.accept_inbound_channel(
+ &temporary_channel_id,
+ &counterparty_node_id,
+ *inbound_channel_request_counter,
+ 60,
+ None,
+ )
+ .unwrap();
accepted.set(true);
Ok(())
},
### lightning/src/ln/htlc_reserve_unit_tests.rs
@@ -2625,12 +2625,17 @@ fn do_test_accept_inbound_channel_from_trusted_peer_0reserve(
let events = nodes[1].node.get_and_clear_pending_events();
assert_eq!(events.len(), 1);
match events[0] {
- Event::OpenChannelRequest { temporary_channel_id: chan_id, .. } => {
+ Event::OpenChannelRequest {
+ temporary_channel_id: chan_id,
+ ref inbound_channel_request_counter,
+ ..
+ } => {
nodes[1]
.node
.accept_inbound_channel_from_trusted_peer(
&chan_id,
&node_a_id,
+ *inbound_channel_request_counter,
0,
TrustedChannelFeatures::ZeroReserve,
None,
@@ -2724,12 +2729,17 @@ pub(crate) fn setup_0reserve_no_outputs_channels<'a, 'b, 'c, 'd>(
let events = nodes[1].node.get_and_clear_pending_events();
assert_eq!(events.len(), 1);
match events[0] {
- Event::OpenChannelRequest { temporary_channel_id: chan_id, .. } => {
+ Event::OpenChannelRequest {
+ temporary_channel_id: chan_id,
+ ref inbound_channel_request_counter,
+ ..
+ } => {
nodes[1]
.node
.accept_inbound_channel_from_trusted_peer(
&chan_id,
&node_a_id,
+ *inbound_channel_request_counter,
0,
TrustedChannelFeatures::ZeroReserve,
None,
@@ -3246,12 +3256,17 @@ fn test_0reserve_zero_conf_combined() {
let events = nodes[1].node.get_and_clear_pending_events();
assert_eq!(events.len(), 1);
match events[0] {
- Event::OpenChannelRequest { temporary_channel_id: chan_id, .. } => {
+ Event::OpenChannelRequest {
+ temporary_channel_id: chan_id,
+ ref inbound_channel_request_counter,
+ ..
+ } => {
nodes[1]
.node
.accept_inbound_channel_from_trusted_peer(
&chan_id,
&node_a_id,
+ *inbound_channel_request_counter,
0,
TrustedChannelFeatures::ZeroConfZeroReserve,
None,
### lightning/src/ln/priv_short_conf_tests.rs
@@ -886,12 +886,17 @@ fn test_0conf_channel_with_async_monitor() {
let events = nodes[1].node.get_and_clear_pending_events();
assert_eq!(events.len(), 1);
match events[0] {
- Event::OpenChannelRequest { temporary_channel_id, .. } => {
+ Event::OpenChannelRequest {
+ temporary_channel_id,
+ ref inbound_channel_request_counter,
+ ..
+ } => {
nodes[1]
.node
.accept_inbound_channel_from_trusted_peer(
&temporary_channel_id,
&node_a_id,
+ *inbound_channel_request_counter,
0,
TrustedChannelFeatures::ZeroConf,
None,
@@ -1414,11 +1419,21 @@ fn test_zero_conf_accept_reject() {
let events = nodes[1].node.get_and_clear_pending_events();
match events[0] {
- Event::OpenChannelRequest { temporary_channel_id, .. } => {
+ Event::OpenChannelRequest {
+ temporary_channel_id,
+ ref inbound_channel_request_counter,
+ ..
+ } => {
// Assert we fail to accept via the non-0conf method
assert!(nodes[1]
.node
- .accept_inbound_channel(&temporary_channel_id, &node_a_id, 0, None)
+ .accept_inbound_channel(
+ &temporary_channel_id,
+ &node_a_id,
+ *inbound_channel_request_counter,
+ 0,
+ None
+ )
.is_err());
},
_ => panic!(),
@@ -1447,13 +1462,18 @@ fn test_zero_conf_accept_reject() {
let events = nodes[1].node.get_and_clear_pending_events();
match events[0] {
- Event::OpenChannelRequest { temporary_channel_id, .. } => {
+ Event::OpenChannelRequest {
+ temporary_channel_id,
+ ref inbound_channel_request_counter,
+ ..
+ } => {
// Assert we can accept via the 0conf method
assert!(nodes[1]
.node
.accept_inbound_channel_from_trusted_peer(
&temporary_channel_id,
&node_a_id,
+ *inbound_channel_request_counter,
0,
TrustedChannelFeatures::ZeroConf,
None,
@@ -1491,12 +1511,17 @@ fn test_connect_before_funding() {
let events = nodes[1].node.get_and_clear_pending_events();
assert_eq!(events.len(), 1);
match events[0] {
- Event::OpenChannelRequest { temporary_channel_id, .. } => {
+ Event::OpenChannelRequest {
+ temporary_channel_id,
+ ref inbound_channel_request_counter,
+ ..
+ } => {
nodes[1]
.node
.accept_inbound_channel_from_trusted_peer(
&temporary_channel_id,
&node_a_id,
+ *inbound_channel_request_counter,
0,
TrustedChannelFeatures::ZeroConf,
None,
### lightning/src/ln/shutdown_tests.rs
@@ -1062,10 +1062,21 @@ fn test_unsupported_anysegwit_upfront_shutdown_script() {
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, .. } => {
+ Event::OpenChannelRequest {
+ temporary_channel_id,
+ counterparty_node_id,
+ ref inbound_channel_request_counter,
+ ..
+ } => {
assert!(nodes[1]
.node
- .accept_inbound_channel(temporary_channel_id, counterparty_node_id, 42, None,)
+ .accept_inbound_channel(
+ temporary_channel_id,
+ counterparty_node_id,
+ *inbound_channel_request_counter,
+ 42,
+ None,
+ )
.is_err());
},
_ => panic!("Unexpected event"),
@@ -1140,10 +1151,21 @@ fn test_invalid_upfront_shutdown_script() {
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, .. } => {
+ Event::OpenChannelRequest {
+ temporary_channel_id,
+ counterparty_node_id,
+ ref inbound_channel_request_counter,
+ ..
+ } => {
assert!(nodes[1]
.node
- .accept_inbound_channel(temporary_channel_id, counterparty_node_id, 42, None,)
+ .accept_inbound_channel(
+ temporary_channel_id,
+ counterparty_node_id,
+ *inbound_channel_request_counter,
+ 42,
+ None,
+ )
.is_err());
},
_ => panic!("Unexpected event"),
### lightning/src/ln/update_fee_tests.rs
@@ -897,10 +897,21 @@ pub fn test_chan_init_feerate_unaffordability() {
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, .. } => {
+ Event::OpenChannelRequest {
+ temporary_channel_id,
+ counterparty_node_id,
+ ref inbound_channel_request_counter,
+ ..
+ } => {
assert!(nodes[1]
.node
- .accept_inbound_channel(temporary_channel_id, counterparty_node_id, 42, None,)
+ .accept_inbound_channel(
+ temporary_channel_id,
+ counterparty_node_id,
+ *inbound_channel_request_counter,
+ 42,
+ None,
+ )
.is_err());
},
_ => panic!("Unexpected event"),
### pending_changelog/inbound-channel-request-counter.txt
@@ -0,0 +1,5 @@
+# API Updates
+
+ * `Event::OpenChannelRequest` has a new `inbound_channel_request_counter` field, which
+ `accept_inbound_channel` and `accept_inbound_channel_from_trusted_peer` now require
+ to be passed back verbatim, tying a response to the request the event described.Why this scored 60/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.