Skip to content

Commit e9ffefc

Browse files
committed
Add FundingSigned event
If `manually_broadcast_outbound_channels` is set, LDK will emit this event after the counterparty node send the `FundingSigned` msg without broadcasting the funding transaction.
1 parent 7feebc5 commit e9ffefc

File tree

5 files changed

+290
-13
lines changed

5 files changed

+290
-13
lines changed

lightning/src/events/mod.rs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,27 @@ impl_writeable_tlv_based_enum!(PaymentFailureReason,
497497
/// written as it makes no sense to respond to it after reconnecting to peers).
498498
#[derive(Clone, Debug, PartialEq, Eq)]
499499
pub enum Event {
500+
/// Used to indicate that the counterparty node has sent `FundingSigned` msg but we are yet to
501+
/// broadcast the funding transaction.
502+
///
503+
/// After you receive this event, you should broadcast the funding transaction and then call
504+
//// [`ChannelManager::funding_transaction_broadcasted`]. <-- not implemtened yet
505+
/// // should we have some timeout for this?
506+
//// [`ChannelManager::funding_transaction_broadcasted`]: crate::ln::channelmanager::ChannelManager::funding_transaction_broadcasted
507+
FundingSigned {
508+
/// The `channel_id` indicating which channel has completed the `FundingSigned` stage.
509+
channel_id: ChannelId,
510+
/// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
511+
/// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
512+
/// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
513+
/// `user_channel_id` will be randomized for an inbound channel. This may be zero for objects
514+
/// serialized with LDK versions prior to 0.0.113.
515+
///
516+
/// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
517+
/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
518+
/// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
519+
user_channel_id: u128,
520+
},
500521
/// Used to indicate that the client should generate a funding transaction with the given
501522
/// parameters and then call [`ChannelManager::funding_transaction_generated`].
502523
/// Generated in [`ChannelManager`] message handling.
@@ -1404,6 +1425,13 @@ impl Writeable for Event {
14041425
35u8.write(writer)?;
14051426
// Never write ConnectionNeeded events as buffered onion messages aren't serialized.
14061427
},
1428+
&Event::FundingSigned { ref channel_id, ref user_channel_id } => {
1429+
37u8.write(writer)?;
1430+
write_tlv_fields!(writer, {
1431+
(0, channel_id, required),
1432+
(2, user_channel_id, required),
1433+
});
1434+
},
14071435
// Note that, going forward, all new events must only write data inside of
14081436
// `write_tlv_fields`. Versions 0.0.101+ will ignore odd-numbered events that write
14091437
// data via `write_tlv_fields`.
@@ -1814,6 +1842,22 @@ impl MaybeReadable for Event {
18141842
},
18151843
// Note that we do not write a length-prefixed TLV for ConnectionNeeded events.
18161844
35u8 => Ok(None),
1845+
37u8 => {
1846+
let mut f = || {
1847+
let mut channel_id = ChannelId::new_zero();
1848+
let mut user_channel_id: u128 = 0;
1849+
read_tlv_fields!(reader, {
1850+
(0, channel_id, required),
1851+
(2, user_channel_id, required),
1852+
});
1853+
1854+
Ok(Some(Event::FundingSigned {
1855+
channel_id,
1856+
user_channel_id,
1857+
}))
1858+
};
1859+
f()
1860+
},
18171861
// Versions prior to 0.0.100 did not ignore odd types, instead returning InvalidValue.
18181862
// Version 0.0.100 failed to properly ignore odd types, possibly resulting in corrupt
18191863
// reads.

0 commit comments

Comments
 (0)