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