@@ -27,7 +27,7 @@ use crate::util::errors::APIError;
27
27
use crate :: util:: ser:: { BigSize , FixedLengthReader , Writeable , Writer , MaybeReadable , Readable , RequiredWrapper , UpgradableRequired , WithoutLength } ;
28
28
use crate :: routing:: router:: { RouteHop , RouteParameters } ;
29
29
30
- use bitcoin:: { PackedLockTime , Transaction } ;
30
+ use bitcoin:: { PackedLockTime , Transaction , Txid } ;
31
31
#[ cfg( anchors) ]
32
32
use bitcoin:: { OutPoint , Txid , TxIn , TxOut , Witness } ;
33
33
use bitcoin:: blockdata:: script:: Script ;
@@ -817,6 +817,50 @@ pub enum Event {
817
817
/// transaction.
818
818
claim_from_onchain_tx : bool ,
819
819
} ,
820
+ /// Indicates a channel has received sufficient confirmations and LDK is ready to send [`msgs::ChannelReady`].
821
+ ///
822
+ /// To signal readiness, call [`ChannelManager::signal_channel_readiness`]. To reject the
823
+ /// request, call [`ChannelManager::force_close_without_broadcasting_txn`].
824
+ ///
825
+ /// The event is only triggered when the [`UserConfig::manually_signal_channel_ready`]
826
+ /// config flag is set to true.
827
+ ///
828
+ /// [`ChannelManager::signal_channel_readiness`]: crate::ln::channelmanager::ChannelManager::signal_channel_readiness
829
+ /// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
830
+ /// [`UserConfig::manually_signal_channel_ready`]: crate::util::config::UserConfig::manually_signal_channel_ready
831
+ /// [`msgs::ChannelReady`]: crate::ln::msgs::ChannelReady
832
+ PendingChannelReady {
833
+ /// The channel ID of the channel.
834
+ ///
835
+ /// When responding to the request, the `channel_id` should be passed
836
+ /// back to the ChannelManager through [`ChannelManager::signal_channel_readiness`] to signal,
837
+ /// or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject.
838
+ ///
839
+ /// [`ChannelManager::signal_channel_readiness`]: crate::ln::channelmanager::ChannelManager::signal_channel_readiness
840
+ /// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
841
+ channel_id : [ u8 ; 32 ] ,
842
+ /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
843
+ /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
844
+ /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
845
+ /// `user_channel_id` will be randomized for an inbound channel.
846
+ ///
847
+ /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
848
+ /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
849
+ /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
850
+ user_channel_id : u128 ,
851
+ /// The node_id of the counterparty requesting to open the channel.
852
+ ///
853
+ /// When responding to the request, the `counterparty_node_id` should be passed
854
+ /// back to the `ChannelManager` through [`ChannelManager::signal_channel_readiness`] to
855
+ /// signal readiness, or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject the
856
+ /// request.
857
+ ///
858
+ /// [`ChannelManager::signal_channel_readiness`]: crate::ln::channelmanager::ChannelManager::signal_channel_readiness
859
+ /// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
860
+ counterparty_node_id : PublicKey ,
861
+ /// The txid of the funding transaction.
862
+ funding_txid : Txid ,
863
+ } ,
820
864
/// Used to indicate that a channel with the given `channel_id` is ready to
821
865
/// be used. This event is emitted either when the funding transaction has been confirmed
822
866
/// on-chain, or, in case of a 0conf channel, when both parties have confirmed the channel
@@ -1136,6 +1180,15 @@ impl Writeable for Event {
1136
1180
( 6 , channel_type, required) ,
1137
1181
} ) ;
1138
1182
} ,
1183
+ & Event :: PendingChannelReady { ref channel_id, ref user_channel_id, ref counterparty_node_id, ref funding_txid } => {
1184
+ 31u8 . write ( writer) ?;
1185
+ write_tlv_fields ! ( writer, {
1186
+ ( 0 , channel_id, required) ,
1187
+ ( 2 , user_channel_id, required) ,
1188
+ ( 4 , counterparty_node_id, required) ,
1189
+ ( 6 , funding_txid, required)
1190
+ } ) ;
1191
+ } ,
1139
1192
// Note that, going forward, all new events must only write data inside of
1140
1193
// `write_tlv_fields`. Versions 0.0.101+ will ignore odd-numbered events that write
1141
1194
// data via `write_tlv_fields`.
@@ -1471,6 +1524,28 @@ impl MaybeReadable for Event {
1471
1524
} ;
1472
1525
f ( )
1473
1526
} ,
1527
+ 31u8 => {
1528
+ let f = || {
1529
+ let mut channel_id = [ 0 ; 32 ] ;
1530
+ let mut user_channel_id: u128 = 0 ;
1531
+ let mut counterparty_node_id = RequiredWrapper ( None ) ;
1532
+ let mut funding_txid = RequiredWrapper ( None ) ;
1533
+ read_tlv_fields ! ( reader, {
1534
+ ( 0 , channel_id, required) ,
1535
+ ( 2 , user_channel_id, required) ,
1536
+ ( 4 , counterparty_node_id, required) ,
1537
+ ( 6 , funding_txid, required) ,
1538
+ } ) ;
1539
+
1540
+ Ok ( Some ( Event :: PendingChannelReady {
1541
+ channel_id,
1542
+ user_channel_id,
1543
+ counterparty_node_id : counterparty_node_id. 0 . unwrap ( ) ,
1544
+ funding_txid : funding_txid. 0 . unwrap ( )
1545
+ } ) )
1546
+ } ;
1547
+ f ( )
1548
+ } ,
1474
1549
// Versions prior to 0.0.100 did not ignore odd types, instead returning InvalidValue.
1475
1550
// Version 0.0.100 failed to properly ignore odd types, possibly resulting in corrupt
1476
1551
// reads.
0 commit comments