Skip to content

Commit a8093ee

Browse files
committed
Send channel_update messages to direct peers on private channels
If we are a public node and have a private channel, our counterparty needs to know the fees which we will charge to forward payments to them. Without sending them a channel_update, they have no way to learn that information, resulting in the channel being effectively useless for outbound-from-us payments. This commit fixes our lack of channel_update messages to private channel counterparties, ensuring we always send them a channel_update after the channel funding is confirmed.
1 parent 4808790 commit a8093ee

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,11 @@ macro_rules! handle_chan_restoration_locked {
946946
node_id: counterparty_node_id,
947947
msg: announcement_sigs,
948948
});
949+
} else if $channel_entry.get().is_usable() {
950+
$channel_state.pending_msg_events.push(events::MessageSendEvent::SendChannelUpdate {
951+
node_id: counterparty_node_id,
952+
msg: $self.get_channel_update_for_unicast($channel_entry.get()).unwrap(),
953+
});
949954
}
950955
$channel_state.short_to_id.insert($channel_entry.get().get_short_channel_id().unwrap(), $channel_entry.get().channel_id());
951956
}
@@ -2960,6 +2965,11 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
29602965
node_id: counterparty_node_id.clone(),
29612966
msg: announcement_sigs,
29622967
});
2968+
} else if chan.get().is_usable() {
2969+
channel_state.pending_msg_events.push(events::MessageSendEvent::SendChannelUpdate {
2970+
node_id: counterparty_node_id.clone(),
2971+
msg: self.get_channel_update_for_unicast(chan.get()).unwrap(),
2972+
});
29632973
}
29642974
Ok(())
29652975
},
@@ -3953,6 +3963,12 @@ where
39533963
node_id: channel.get_counterparty_node_id(),
39543964
msg: announcement_sigs,
39553965
});
3966+
} else if channel.is_usable() {
3967+
log_trace!(self.logger, "Sending funding_locked WITHOUT announcement_signatures but with channel_update for {}", log_bytes!(channel.channel_id()));
3968+
pending_msg_events.push(events::MessageSendEvent::SendChannelUpdate {
3969+
node_id: channel.get_counterparty_node_id(),
3970+
msg: self.get_channel_update_for_unicast(channel).unwrap(),
3971+
});
39563972
} else {
39573973
log_trace!(self.logger, "Sending funding_locked WITHOUT announcement_signatures for {}", log_bytes!(channel.channel_id()));
39583974
}
@@ -4187,6 +4203,7 @@ impl<Signer: Sign, M: Deref , T: Deref , K: Deref , F: Deref , L: Deref >
41874203
&events::MessageSendEvent::BroadcastChannelAnnouncement { .. } => true,
41884204
&events::MessageSendEvent::BroadcastNodeAnnouncement { .. } => true,
41894205
&events::MessageSendEvent::BroadcastChannelUpdate { .. } => true,
4206+
&events::MessageSendEvent::SendChannelUpdate { ref node_id, .. } => node_id != counterparty_node_id,
41904207
&events::MessageSendEvent::HandleError { ref node_id, .. } => node_id != counterparty_node_id,
41914208
&events::MessageSendEvent::PaymentFailureNetworkUpdate { .. } => true,
41924209
&events::MessageSendEvent::SendChannelRangeQuery { .. } => false,

lightning/src/ln/peer_handler.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,12 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, L: Deref> PeerManager<D
12711271
self.forward_broadcast_msg(peers, &wire::Message::ChannelUpdate(msg), None);
12721272
}
12731273
},
1274+
MessageSendEvent::SendChannelUpdate { ref node_id, ref msg } => {
1275+
log_trace!(self.logger, "Handling SendChannelUpdate event in peer_handler for node {} for channel {}",
1276+
log_pubkey!(node_id), msg.contents.short_channel_id);
1277+
let (_, peer) = get_peer_for_forwarding!(node_id);
1278+
peer.pending_outbound_buffer.push_back(peer.channel_encryptor.encrypt_message(&encode_msg!(msg)));
1279+
},
12741280
MessageSendEvent::PaymentFailureNetworkUpdate { ref update } => {
12751281
self.message_handler.route_handler.handle_htlc_fail_channel_update(update);
12761282
},

lightning/src/util/events.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,15 @@ pub enum MessageSendEvent {
392392
/// The channel_update which should be sent.
393393
msg: msgs::ChannelUpdate,
394394
},
395+
/// Used to indicate that a channel_update should be sent to a single peer.
396+
/// This is used, in contrast to [`Self::BroadcastChannelUpdate`], when the channel is a
397+
/// private channel and we shouldn't be informing all of our peers of channel parameters.
398+
SendChannelUpdate {
399+
/// The node_id of the node which should receive this message
400+
node_id: PublicKey,
401+
/// The channel_update which should be sent.
402+
msg: msgs::ChannelUpdate,
403+
},
395404
/// Broadcast an error downstream to be handled
396405
HandleError {
397406
/// The node_id of the node which should receive this message

0 commit comments

Comments
 (0)