Skip to content

Commit ba335eb

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 3034614 commit ba335eb

File tree

2 files changed

+38
-8
lines changed

2 files changed

+38
-8
lines changed

bindings/ldk_node.udl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ interface Event {
393393
PaymentForwarded(ChannelId prev_channel_id, ChannelId next_channel_id, UserChannelId?
394394
prev_user_channel_id, UserChannelId? next_user_channel_id, PublicKey? prev_node_id, PublicKey? next_node_id, u64? total_fee_earned_msat, u64? skimmed_fee_msat, boolean claim_from_onchain_tx, u64? outbound_amount_forwarded_msat);
395395
ChannelPending(ChannelId channel_id, UserChannelId user_channel_id, ChannelId former_temporary_channel_id, PublicKey counterparty_node_id, OutPoint funding_txo);
396-
ChannelReady(ChannelId channel_id, UserChannelId user_channel_id, PublicKey? counterparty_node_id);
396+
ChannelReady(ChannelId channel_id, UserChannelId user_channel_id, PublicKey? counterparty_node_id, OutPoint? funding_txo);
397397
ChannelClosed(ChannelId channel_id, UserChannelId user_channel_id, PublicKey? counterparty_node_id, ClosureReason? reason);
398398
};
399399

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),
@@ -1397,14 +1410,28 @@ where
13971410
}
13981411
},
13991412
LdkEvent::ChannelReady {
1400-
channel_id, user_channel_id, counterparty_node_id, ..
1413+
channel_id,
1414+
user_channel_id,
1415+
counterparty_node_id,
1416+
funding_txo,
1417+
..
14011418
} => {
1402-
log_info!(
1403-
self.logger,
1404-
"Channel {} with counterparty {} ready to be used.",
1405-
channel_id,
1406-
counterparty_node_id,
1407-
);
1419+
if let Some(funding_txo) = funding_txo {
1420+
log_info!(
1421+
self.logger,
1422+
"Channel {} with counterparty {} ready to be used with funding_txo {}",
1423+
channel_id,
1424+
counterparty_node_id,
1425+
funding_txo,
1426+
);
1427+
} else {
1428+
log_info!(
1429+
self.logger,
1430+
"Channel {} with counterparty {} ready to be used",
1431+
channel_id,
1432+
counterparty_node_id,
1433+
);
1434+
}
14081435

14091436
if let Some(liquidity_source) = self.liquidity_source.as_ref() {
14101437
liquidity_source
@@ -1416,6 +1443,7 @@ where
14161443
channel_id,
14171444
user_channel_id: UserChannelId(user_channel_id),
14181445
counterparty_node_id: Some(counterparty_node_id),
1446+
funding_txo,
14191447
};
14201448
match self.event_queue.add_event(event).await {
14211449
Ok(_) => {},
@@ -1655,6 +1683,7 @@ mod tests {
16551683
channel_id: ChannelId([23u8; 32]),
16561684
user_channel_id: UserChannelId(2323),
16571685
counterparty_node_id: None,
1686+
funding_txo: None,
16581687
};
16591688
event_queue.add_event(expected_event.clone()).await.unwrap();
16601689

@@ -1692,6 +1721,7 @@ mod tests {
16921721
channel_id: ChannelId([23u8; 32]),
16931722
user_channel_id: UserChannelId(2323),
16941723
counterparty_node_id: None,
1724+
funding_txo: None,
16951725
};
16961726

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

0 commit comments

Comments
 (0)