Skip to content

Commit a57c034

Browse files
committed
Add funding_txo to ChannelReady event
A ChannelReady event is used for both channel establishment and splicing to indicate that the funding transaction is confirmed to an acceptable depth and thus the channel can be used with the funding. An upcoming SplicePending event will be emitted for each pending splice (i.e., both the initial splice attempt and any RBF attempts). Thus, when a ChannelReady event is emitted, the funding_txo must be included to differentiate between which ChannelPending -- which also contains the funding_txo -- that the event corresponds to.
1 parent 341dcb4 commit a57c034

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lightning/src/events/mod.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -1318,6 +1318,11 @@ pub enum Event {
13181318
user_channel_id: u128,
13191319
/// The `node_id` of the channel counterparty.
13201320
counterparty_node_id: PublicKey,
1321+
/// The outpoint of the channel's funding transaction.
1322+
///
1323+
/// Will be `None` if the channel's funding transaction reached an acceptable depth prior to
1324+
/// version 0.2.
1325+
funding_txo: Option<OutPoint>,
13211326
/// The features that this channel will operate with.
13221327
channel_type: ChannelTypeFeatures,
13231328
},
@@ -1786,10 +1791,14 @@ impl Writeable for Event {
17861791
}
17871792
write_tlv_fields!(writer, {}); // Write a length field for forwards compat
17881793
}
1789-
&Event::ChannelReady { ref channel_id, ref user_channel_id, ref counterparty_node_id, ref channel_type } => {
1794+
&Event::ChannelReady {
1795+
ref channel_id, ref user_channel_id, ref counterparty_node_id, ref funding_txo,
1796+
ref channel_type,
1797+
} => {
17901798
29u8.write(writer)?;
17911799
write_tlv_fields!(writer, {
17921800
(0, channel_id, required),
1801+
(1, funding_txo, required),
17931802
(2, user_channel_id, required),
17941803
(4, counterparty_node_id, required),
17951804
(6, channel_type, required),
@@ -2239,9 +2248,11 @@ impl MaybeReadable for Event {
22392248
let mut channel_id = ChannelId::new_zero();
22402249
let mut user_channel_id: u128 = 0;
22412250
let mut counterparty_node_id = RequiredWrapper(None);
2251+
let mut funding_txo = None;
22422252
let mut channel_type = RequiredWrapper(None);
22432253
read_tlv_fields!(reader, {
22442254
(0, channel_id, required),
2255+
(1, funding_txo, option),
22452256
(2, user_channel_id, required),
22462257
(4, counterparty_node_id, required),
22472258
(6, channel_type, required),
@@ -2251,6 +2262,7 @@ impl MaybeReadable for Event {
22512262
channel_id,
22522263
user_channel_id,
22532264
counterparty_node_id: counterparty_node_id.0.unwrap(),
2265+
funding_txo,
22542266
channel_type: channel_type.0.unwrap()
22552267
}))
22562268
};

lightning/src/ln/channelmanager.rs

+3
Original file line numberDiff line numberDiff line change
@@ -3201,6 +3201,7 @@ macro_rules! emit_initial_channel_ready_event {
32013201
channel_id: $channel.context.channel_id(),
32023202
user_channel_id: $channel.context.get_user_id(),
32033203
counterparty_node_id: $channel.context.get_counterparty_node_id(),
3204+
funding_txo: $channel.funding.get_funding_txo().map(|outpoint| outpoint.into_bitcoin_outpoint()),
32043205
channel_type: $channel.funding.get_channel_type().clone(),
32053206
}, None));
32063207
$channel.context.set_initial_channel_ready_event_emitted();
@@ -9645,6 +9646,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
96459646
channel_id: chan.context.channel_id(),
96469647
user_channel_id: chan.context.get_user_id(),
96479648
counterparty_node_id: chan.context.get_counterparty_node_id(),
9649+
funding_txo: chan.funding.get_funding_txo().map(|outpoint| outpoint.into_bitcoin_outpoint()),
96489650
channel_type: chan.funding.get_channel_type().clone(),
96499651
}, None));
96509652

@@ -11798,6 +11800,7 @@ where
1179811800
channel_id: funded_channel.context.channel_id(),
1179911801
user_channel_id: funded_channel.context.get_user_id(),
1180011802
counterparty_node_id: funded_channel.context.get_counterparty_node_id(),
11803+
funding_txo: funded_channel.funding.get_funding_txo().map(|outpoint| outpoint.into_bitcoin_outpoint()),
1180111804
channel_type: funded_channel.funding.get_channel_type().clone(),
1180211805
}, None));
1180311806
}

0 commit comments

Comments
 (0)