Skip to content

Commit 7afe27d

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 1a134b4 commit 7afe27d

File tree

1 file changed

+37
-7
lines changed

1 file changed

+37
-7
lines changed

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),
@@ -1363,14 +1376,28 @@ where
13631376
}
13641377
},
13651378
LdkEvent::ChannelReady {
1366-
channel_id, user_channel_id, counterparty_node_id, ..
1379+
channel_id,
1380+
user_channel_id,
1381+
counterparty_node_id,
1382+
funding_txo,
1383+
..
13671384
} => {
1368-
log_info!(
1369-
self.logger,
1370-
"Channel {} with counterparty {} ready to be used.",
1371-
channel_id,
1372-
counterparty_node_id,
1373-
);
1385+
if let Some(funding_txo) = funding_txo {
1386+
log_info!(
1387+
self.logger,
1388+
"Channel {} with counterparty {} ready to be used with funding_txo {}",
1389+
channel_id,
1390+
counterparty_node_id,
1391+
funding_txo,
1392+
);
1393+
} else {
1394+
log_info!(
1395+
self.logger,
1396+
"Channel {} with counterparty {} ready to be used",
1397+
channel_id,
1398+
counterparty_node_id,
1399+
);
1400+
}
13741401

13751402
if let Some(liquidity_source) = self.liquidity_source.as_ref() {
13761403
liquidity_source
@@ -1382,6 +1409,7 @@ where
13821409
channel_id,
13831410
user_channel_id: UserChannelId(user_channel_id),
13841411
counterparty_node_id: Some(counterparty_node_id),
1412+
funding_txo,
13851413
};
13861414
match self.event_queue.add_event(event) {
13871415
Ok(_) => {},
@@ -1620,6 +1648,7 @@ mod tests {
16201648
channel_id: ChannelId([23u8; 32]),
16211649
user_channel_id: UserChannelId(2323),
16221650
counterparty_node_id: None,
1651+
funding_txo: None,
16231652
};
16241653
event_queue.add_event(expected_event.clone()).unwrap();
16251654

@@ -1656,6 +1685,7 @@ mod tests {
16561685
channel_id: ChannelId([23u8; 32]),
16571686
user_channel_id: UserChannelId(2323),
16581687
counterparty_node_id: None,
1688+
funding_txo: None,
16591689
};
16601690

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

0 commit comments

Comments
 (0)