Skip to content

Commit e583ae8

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 8b0ac01 commit e583ae8

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lightning/src/events/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,6 +1378,11 @@ pub enum Event {
13781378
user_channel_id: u128,
13791379
/// The `node_id` of the channel counterparty.
13801380
counterparty_node_id: PublicKey,
1381+
/// The outpoint of the channel's funding transaction.
1382+
///
1383+
/// Will be `None` if the channel's funding transaction reached an acceptable depth prior to
1384+
/// version 0.2.
1385+
funding_txo: Option<OutPoint>,
13811386
/// The features that this channel will operate with.
13821387
channel_type: ChannelTypeFeatures,
13831388
},
@@ -1929,11 +1934,13 @@ impl Writeable for Event {
19291934
ref channel_id,
19301935
ref user_channel_id,
19311936
ref counterparty_node_id,
1937+
ref funding_txo,
19321938
ref channel_type,
19331939
} => {
19341940
29u8.write(writer)?;
19351941
write_tlv_fields!(writer, {
19361942
(0, channel_id, required),
1943+
(1, funding_txo, option),
19371944
(2, user_channel_id, required),
19381945
(4, counterparty_node_id, required),
19391946
(6, channel_type, required),
@@ -2440,9 +2447,11 @@ impl MaybeReadable for Event {
24402447
let mut channel_id = ChannelId::new_zero();
24412448
let mut user_channel_id: u128 = 0;
24422449
let mut counterparty_node_id = RequiredWrapper(None);
2450+
let mut funding_txo = None;
24432451
let mut channel_type = RequiredWrapper(None);
24442452
read_tlv_fields!(reader, {
24452453
(0, channel_id, required),
2454+
(1, funding_txo, option),
24462455
(2, user_channel_id, required),
24472456
(4, counterparty_node_id, required),
24482457
(6, channel_type, required),
@@ -2452,6 +2461,7 @@ impl MaybeReadable for Event {
24522461
channel_id,
24532462
user_channel_id,
24542463
counterparty_node_id: counterparty_node_id.0.unwrap(),
2464+
funding_txo,
24552465
channel_type: channel_type.0.unwrap(),
24562466
}))
24572467
};

lightning/src/ln/channelmanager.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3364,6 +3364,10 @@ macro_rules! emit_initial_channel_ready_event {
33643364
channel_id: $channel.context.channel_id(),
33653365
user_channel_id: $channel.context.get_user_id(),
33663366
counterparty_node_id: $channel.context.get_counterparty_node_id(),
3367+
funding_txo: $channel
3368+
.funding
3369+
.get_funding_txo()
3370+
.map(|outpoint| outpoint.into_bitcoin_outpoint()),
33673371
channel_type: $channel.funding.get_channel_type().clone(),
33683372
},
33693373
None,
@@ -10167,6 +10171,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1016710171
channel_id: chan.context.channel_id(),
1016810172
user_channel_id: chan.context.get_user_id(),
1016910173
counterparty_node_id: chan.context.get_counterparty_node_id(),
10174+
funding_txo: chan.funding.get_funding_txo().map(|outpoint| outpoint.into_bitcoin_outpoint()),
1017010175
channel_type: chan.funding.get_channel_type().clone(),
1017110176
}, None));
1017210177
}
@@ -12281,6 +12286,7 @@ where
1228112286
channel_id: funded_channel.context.channel_id(),
1228212287
user_channel_id: funded_channel.context.get_user_id(),
1228312288
counterparty_node_id: funded_channel.context.get_counterparty_node_id(),
12289+
funding_txo: funded_channel.funding.get_funding_txo().map(|outpoint| outpoint.into_bitcoin_outpoint()),
1228412290
channel_type: funded_channel.funding.get_channel_type().clone(),
1228512291
}, None));
1228612292
}

0 commit comments

Comments
 (0)