Skip to content

Commit 17a548a

Browse files
committed
Add funding_txo to ChannelReady event
When a channel is spliced, the existing funding transaction's output is spent and a new funding transaction output is formed. Once the splice is considered locked by both parties, LDK will emit a ChannelReady event which will include the new funding_txo. Additionally, the initial ChannelReady event now includes the original funding_txo. Include this data in LDK Node's ChannelReady event.
1 parent 121dadb commit 17a548a

1 file changed

Lines changed: 37 additions & 7 deletions

File tree

src/event.rs

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,10 @@ pub enum Event {
199199
funding_txo: OutPoint,
200200
},
201201
/// A channel is ready to be used.
202+
///
203+
/// This event is emitted when:
204+
/// - A new channel has been established and is ready for use
205+
/// - An existing channel has been spliced and is ready with the new funding output
202206
ChannelReady {
203207
/// The `channel_id` of the channel.
204208
channel_id: ChannelId,
@@ -208,6 +212,14 @@ pub enum Event {
208212
///
209213
/// This will be `None` for events serialized by LDK Node v0.1.0 and prior.
210214
counterparty_node_id: Option<PublicKey>,
215+
/// The outpoint of the channel's funding transaction.
216+
///
217+
/// This represents the channel's current funding output, which may change when the
218+
/// channel is spliced. For spliced channels, this will contain the new funding output
219+
/// from the confirmed splice transaction.
220+
///
221+
/// This will be `None` for events serialized by LDK Node v0.6.0 and prior.
222+
funding_txo: Option<OutPoint>,
211223
},
212224
/// A channel has been closed.
213225
ChannelClosed {
@@ -246,6 +258,7 @@ impl_writeable_tlv_based_enum!(Event,
246258
(0, channel_id, required),
247259
(1, counterparty_node_id, option),
248260
(2, user_channel_id, required),
261+
(3, funding_txo, option),
249262
},
250263
(4, ChannelPending) => {
251264
(0, channel_id, required),
@@ -1381,14 +1394,28 @@ where
13811394
}
13821395
},
13831396
LdkEvent::ChannelReady {
1384-
channel_id, user_channel_id, counterparty_node_id, ..
1397+
channel_id,
1398+
user_channel_id,
1399+
counterparty_node_id,
1400+
funding_txo,
1401+
..
13851402
} => {
1386-
log_info!(
1387-
self.logger,
1388-
"Channel {} with counterparty {} ready to be used.",
1389-
channel_id,
1390-
counterparty_node_id,
1391-
);
1403+
if let Some(funding_txo) = funding_txo {
1404+
log_info!(
1405+
self.logger,
1406+
"Channel {} with counterparty {} ready to be used with funding_txo {}",
1407+
channel_id,
1408+
counterparty_node_id,
1409+
funding_txo,
1410+
);
1411+
} else {
1412+
log_info!(
1413+
self.logger,
1414+
"Channel {} with counterparty {} ready to be used",
1415+
channel_id,
1416+
counterparty_node_id,
1417+
);
1418+
}
13921419

13931420
if let Some(liquidity_source) = self.liquidity_source.as_ref() {
13941421
liquidity_source
@@ -1400,6 +1427,7 @@ where
14001427
channel_id,
14011428
user_channel_id: UserChannelId(user_channel_id),
14021429
counterparty_node_id: Some(counterparty_node_id),
1430+
funding_txo,
14031431
};
14041432
match self.event_queue.add_event(event) {
14051433
Ok(_) => {},
@@ -1638,6 +1666,7 @@ mod tests {
16381666
channel_id: ChannelId([23u8; 32]),
16391667
user_channel_id: UserChannelId(2323),
16401668
counterparty_node_id: None,
1669+
funding_txo: None,
16411670
};
16421671
event_queue.add_event(expected_event.clone()).unwrap();
16431672

@@ -1675,6 +1704,7 @@ mod tests {
16751704
channel_id: ChannelId([23u8; 32]),
16761705
user_channel_id: UserChannelId(2323),
16771706
counterparty_node_id: None,
1707+
funding_txo: None,
16781708
};
16791709

16801710
// Check `next_event_async` won't return if the queue is empty and always rather timeout.

0 commit comments

Comments
 (0)