@@ -32,7 +32,9 @@ use crate::util::ser::{BigSize, FixedLengthReader, Writeable, Writer, MaybeReada
32
32
use crate :: util:: string:: UntrustedString ;
33
33
use crate :: routing:: router:: { RouteHop , RouteParameters } ;
34
34
35
- use bitcoin:: { PackedLockTime , Transaction } ;
35
+ use bitcoin:: { PackedLockTime , Transaction , OutPoint } ;
36
+ #[ cfg( anchors) ]
37
+ use bitcoin:: { Txid , TxIn , TxOut , Witness } ;
36
38
use bitcoin:: blockdata:: script:: Script ;
37
39
use bitcoin:: hashes:: Hash ;
38
40
use bitcoin:: hashes:: sha256:: Hash as Sha256 ;
@@ -604,12 +606,39 @@ pub enum Event {
604
606
/// transaction.
605
607
claim_from_onchain_tx : bool ,
606
608
} ,
609
+ /// Used to indicate that a channel with the given `channel_id` is being opened and pending
610
+ /// confirmation on-chain.
611
+ ///
612
+ /// This event is emitted when the funding transaction has been signed and is broadcast to the
613
+ /// network. For 0conf channels it will be immediately followed by the corresponding
614
+ /// [`Event::ChannelReady`] event.
615
+ ChannelPending {
616
+ /// The `channel_id` of the channel that is pending confirmation.
617
+ channel_id : [ u8 ; 32 ] ,
618
+ /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
619
+ /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
620
+ /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
621
+ /// `user_channel_id` will be randomized for an inbound channel.
622
+ ///
623
+ /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
624
+ /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
625
+ /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
626
+ user_channel_id : u128 ,
627
+ /// The `temporary_channel_id` this channel used to be known by during channel establishment.
628
+ ///
629
+ /// Will be `None` for channels created prior to LDK version 0.0.115.
630
+ former_temporary_channel_id : Option < [ u8 ; 32 ] > ,
631
+ /// The `node_id` of the channel counterparty.
632
+ counterparty_node_id : PublicKey ,
633
+ /// The outpoint of the channel's funding transaction.
634
+ funding_txo : OutPoint ,
635
+ } ,
607
636
/// Used to indicate that a channel with the given `channel_id` is ready to
608
637
/// be used. This event is emitted either when the funding transaction has been confirmed
609
638
/// on-chain, or, in case of a 0conf channel, when both parties have confirmed the channel
610
639
/// establishment.
611
640
ChannelReady {
612
- /// The channel_id of the channel that is ready.
641
+ /// The ` channel_id` of the channel that is ready.
613
642
channel_id : [ u8 ; 32 ] ,
614
643
/// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
615
644
/// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
@@ -620,15 +649,15 @@ pub enum Event {
620
649
/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
621
650
/// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
622
651
user_channel_id : u128 ,
623
- /// The node_id of the channel counterparty.
652
+ /// The ` node_id` of the channel counterparty.
624
653
counterparty_node_id : PublicKey ,
625
654
/// The features that this channel will operate with.
626
655
channel_type : ChannelTypeFeatures ,
627
656
} ,
628
657
/// Used to indicate that a previously opened channel with the given `channel_id` is in the
629
658
/// process of closure.
630
659
ChannelClosed {
631
- /// The channel_id of the channel which has been closed. Note that on-chain transactions
660
+ /// The ` channel_id` of the channel which has been closed. Note that on-chain transactions
632
661
/// resolving the channel are likely still awaiting confirmation.
633
662
channel_id : [ u8 ; 32 ] ,
634
663
/// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
@@ -923,6 +952,16 @@ impl Writeable for Event {
923
952
( 6 , channel_type, required) ,
924
953
} ) ;
925
954
} ,
955
+ & Event :: ChannelPending { ref channel_id, ref user_channel_id, ref former_temporary_channel_id, ref counterparty_node_id, ref funding_txo } => {
956
+ 31u8 . write ( writer) ?;
957
+ write_tlv_fields ! ( writer, {
958
+ ( 0 , channel_id, required) ,
959
+ ( 2 , user_channel_id, required) ,
960
+ ( 4 , former_temporary_channel_id, required) ,
961
+ ( 6 , counterparty_node_id, required) ,
962
+ ( 8 , funding_txo, required) ,
963
+ } ) ;
964
+ } ,
926
965
// Note that, going forward, all new events must only write data inside of
927
966
// `write_tlv_fields`. Versions 0.0.101+ will ignore odd-numbered events that write
928
967
// data via `write_tlv_fields`.
@@ -1258,6 +1297,31 @@ impl MaybeReadable for Event {
1258
1297
} ;
1259
1298
f ( )
1260
1299
} ,
1300
+ 31u8 => {
1301
+ let f = || {
1302
+ let mut channel_id = [ 0 ; 32 ] ;
1303
+ let mut user_channel_id: u128 = 0 ;
1304
+ let mut former_temporary_channel_id = None ;
1305
+ let mut counterparty_node_id = RequiredWrapper ( None ) ;
1306
+ let mut funding_txo = RequiredWrapper ( None ) ;
1307
+ read_tlv_fields ! ( reader, {
1308
+ ( 0 , channel_id, required) ,
1309
+ ( 2 , user_channel_id, required) ,
1310
+ ( 4 , former_temporary_channel_id, required) ,
1311
+ ( 6 , counterparty_node_id, required) ,
1312
+ ( 8 , funding_txo, required) ,
1313
+ } ) ;
1314
+
1315
+ Ok ( Some ( Event :: ChannelPending {
1316
+ channel_id,
1317
+ user_channel_id,
1318
+ former_temporary_channel_id,
1319
+ counterparty_node_id : counterparty_node_id. 0 . unwrap ( ) ,
1320
+ funding_txo : funding_txo. 0 . unwrap ( )
1321
+ } ) )
1322
+ } ;
1323
+ f ( )
1324
+ } ,
1261
1325
// Versions prior to 0.0.100 did not ignore odd types, instead returning InvalidValue.
1262
1326
// Version 0.0.100 failed to properly ignore odd types, possibly resulting in corrupt
1263
1327
// reads.
0 commit comments