Skip to content

Commit 1e576b4

Browse files
add PendingChannelReady event
1 parent 986f3e3 commit 1e576b4

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

lightning/src/events/mod.rs

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub mod bump_transaction;
2121
pub use bump_transaction::BumpTransactionEvent;
2222

2323
use crate::chain::keysinterface::SpendableOutputDescriptor;
24+
use crate::chain::transaction::OutPoint;
2425
use crate::ln::channelmanager::{InterceptId, PaymentId};
2526
use crate::ln::channel::FUNDING_CONF_DEADLINE_BLOCKS;
2627
use crate::ln::features::ChannelTypeFeatures;
@@ -604,6 +605,50 @@ pub enum Event {
604605
/// transaction.
605606
claim_from_onchain_tx: bool,
606607
},
608+
/// Indicates a channel has received sufficient confirmations and LDK is ready to send [`msgs::ChannelReady`].
609+
///
610+
/// To signal readiness, call [`ChannelManager::signal_channel_readiness`]. To reject the
611+
/// request, call [`ChannelManager::force_close_without_broadcasting_txn`].
612+
///
613+
/// The event is only triggered when the [`UserConfig::manually_signal_channel_ready`]
614+
/// config flag is set to true.
615+
///
616+
/// [`ChannelManager::signal_channel_readiness`]: crate::ln::channelmanager::ChannelManager::signal_channel_readiness
617+
/// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
618+
/// [`UserConfig::manually_signal_channel_ready`]: crate::util::config::UserConfig::manually_signal_channel_ready
619+
/// [`msgs::ChannelReady`]: crate::ln::msgs::ChannelReady
620+
PendingChannelReady {
621+
/// The channel ID of the channel.
622+
///
623+
/// When responding to the request, the `channel_id` should be passed
624+
/// back to the ChannelManager through [`ChannelManager::signal_channel_readiness`] to signal,
625+
/// or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject.
626+
///
627+
/// [`ChannelManager::signal_channel_readiness`]: crate::ln::channelmanager::ChannelManager::signal_channel_readiness
628+
/// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
629+
channel_id: [u8; 32],
630+
/// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
631+
/// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
632+
/// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
633+
/// `user_channel_id` will be randomized for an inbound channel.
634+
///
635+
/// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
636+
/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
637+
/// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
638+
user_channel_id: u128,
639+
/// The node_id of the counterparty requesting to open the channel.
640+
///
641+
/// When responding to the request, the `counterparty_node_id` should be passed
642+
/// back to the `ChannelManager` through [`ChannelManager::signal_channel_readiness`] to
643+
/// signal readiness, or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject the
644+
/// request.
645+
///
646+
/// [`ChannelManager::signal_channel_readiness`]: crate::ln::channelmanager::ChannelManager::signal_channel_readiness
647+
/// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
648+
counterparty_node_id: PublicKey,
649+
/// The outpoint that holds the channel funds on-chain.
650+
funding_outpoint: OutPoint,
651+
},
607652
/// Used to indicate that a channel with the given `channel_id` is ready to
608653
/// be used. This event is emitted either when the funding transaction has been confirmed
609654
/// on-chain, or, in case of a 0conf channel, when both parties have confirmed the channel
@@ -923,6 +968,15 @@ impl Writeable for Event {
923968
(6, channel_type, required),
924969
});
925970
},
971+
&Event::PendingChannelReady { ref channel_id, ref user_channel_id, ref counterparty_node_id, ref funding_outpoint } => {
972+
31u8.write(writer)?;
973+
write_tlv_fields!(writer, {
974+
(0, channel_id, required),
975+
(2, user_channel_id, required),
976+
(4, counterparty_node_id, required),
977+
(6, funding_outpoint, required)
978+
});
979+
},
926980
// Note that, going forward, all new events must only write data inside of
927981
// `write_tlv_fields`. Versions 0.0.101+ will ignore odd-numbered events that write
928982
// data via `write_tlv_fields`.
@@ -1258,6 +1312,28 @@ impl MaybeReadable for Event {
12581312
};
12591313
f()
12601314
},
1315+
31u8 => {
1316+
let f = || {
1317+
let mut channel_id = [0; 32];
1318+
let mut user_channel_id: u128 = 0;
1319+
let mut counterparty_node_id = RequiredWrapper(None);
1320+
let mut funding_outpoint = RequiredWrapper(None);
1321+
read_tlv_fields!(reader, {
1322+
(0, channel_id, required),
1323+
(2, user_channel_id, required),
1324+
(4, counterparty_node_id, required),
1325+
(6, funding_outpoint, required),
1326+
});
1327+
1328+
Ok(Some(Event::PendingChannelReady {
1329+
channel_id,
1330+
user_channel_id,
1331+
counterparty_node_id: counterparty_node_id.0.unwrap(),
1332+
funding_outpoint: funding_outpoint.0.unwrap()
1333+
}))
1334+
};
1335+
f()
1336+
},
12611337
// Versions prior to 0.0.100 did not ignore odd types, instead returning InvalidValue.
12621338
// Version 0.0.100 failed to properly ignore odd types, possibly resulting in corrupt
12631339
// reads.

0 commit comments

Comments
 (0)