Skip to content

Commit 2e61d92

Browse files
committed
Expose channel_type in Event::ChannelPending
It is useful to immediately know what kind of channel is being opened, and not having to wait until `ChannelReady`.
1 parent 7c94636 commit 2e61d92

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

lightning/src/events/mod.rs

+13-2
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,10 @@ pub enum Event {
845845
counterparty_node_id: PublicKey,
846846
/// The outpoint of the channel's funding transaction.
847847
funding_txo: OutPoint,
848+
/// The features that this channel will operate with.
849+
///
850+
/// Will be `None` for channels created prior to LDK version 0.0.122.
851+
channel_type: Option<ChannelTypeFeatures>,
848852
},
849853
/// Used to indicate that a channel with the given `channel_id` is ready to
850854
/// be used. This event is emitted either when the funding transaction has been confirmed
@@ -1214,10 +1218,14 @@ impl Writeable for Event {
12141218
(6, channel_type, required),
12151219
});
12161220
},
1217-
&Event::ChannelPending { ref channel_id, ref user_channel_id, ref former_temporary_channel_id, ref counterparty_node_id, ref funding_txo } => {
1221+
&Event::ChannelPending { ref channel_id, ref user_channel_id,
1222+
ref former_temporary_channel_id, ref counterparty_node_id, ref funding_txo,
1223+
ref channel_type
1224+
} => {
12181225
31u8.write(writer)?;
12191226
write_tlv_fields!(writer, {
12201227
(0, channel_id, required),
1228+
(1, channel_type, option),
12211229
(2, user_channel_id, required),
12221230
(4, former_temporary_channel_id, required),
12231231
(6, counterparty_node_id, required),
@@ -1606,8 +1614,10 @@ impl MaybeReadable for Event {
16061614
let mut former_temporary_channel_id = None;
16071615
let mut counterparty_node_id = RequiredWrapper(None);
16081616
let mut funding_txo = RequiredWrapper(None);
1617+
let mut channel_type = None;
16091618
read_tlv_fields!(reader, {
16101619
(0, channel_id, required),
1620+
(1, channel_type, option),
16111621
(2, user_channel_id, required),
16121622
(4, former_temporary_channel_id, required),
16131623
(6, counterparty_node_id, required),
@@ -1619,7 +1629,8 @@ impl MaybeReadable for Event {
16191629
user_channel_id,
16201630
former_temporary_channel_id,
16211631
counterparty_node_id: counterparty_node_id.0.unwrap(),
1622-
funding_txo: funding_txo.0.unwrap()
1632+
funding_txo: funding_txo.0.unwrap(),
1633+
channel_type,
16231634
}))
16241635
};
16251636
f()

lightning/src/ln/channelmanager.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2152,6 +2152,7 @@ macro_rules! emit_channel_pending_event {
21522152
counterparty_node_id: $channel.context.get_counterparty_node_id(),
21532153
user_channel_id: $channel.context.get_user_id(),
21542154
funding_txo: $channel.context.get_funding_txo().unwrap().into_bitcoin_outpoint(),
2155+
channel_type: Some($channel.context.get_channel_type().clone()),
21552156
}, None));
21562157
$channel.context.set_channel_pending_event_emitted();
21572158
}

0 commit comments

Comments
 (0)