@@ -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 ;
@@ -608,12 +610,39 @@ pub enum Event {
608
610
/// The caveat described above the `fee_earned_msat` field applies here as well.
609
611
outbound_amount_forwarded_msat : Option < u64 > ,
610
612
} ,
613
+ /// Used to indicate that a channel with the given `channel_id` is being opened and pending
614
+ /// confirmation on-chain.
615
+ ///
616
+ /// This event is emitted when the funding transaction has been signed and is broadcast to the
617
+ /// network. For 0conf channels it will be immediately followed by the corresponding
618
+ /// [`Event::ChannelReady`] event.
619
+ ChannelPending {
620
+ /// The `channel_id` of the channel that is pending confirmation.
621
+ channel_id : [ u8 ; 32 ] ,
622
+ /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
623
+ /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
624
+ /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
625
+ /// `user_channel_id` will be randomized for an inbound channel.
626
+ ///
627
+ /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
628
+ /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
629
+ /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
630
+ user_channel_id : u128 ,
631
+ /// The `temporary_channel_id` this channel used to be known by during channel establishment.
632
+ ///
633
+ /// Will be `None` for channels created prior to LDK version 0.0.115.
634
+ former_temporary_channel_id : Option < [ u8 ; 32 ] > ,
635
+ /// The `node_id` of the channel counterparty.
636
+ counterparty_node_id : PublicKey ,
637
+ /// The outpoint of the channel's funding transaction.
638
+ funding_txo : OutPoint ,
639
+ } ,
611
640
/// Used to indicate that a channel with the given `channel_id` is ready to
612
641
/// be used. This event is emitted either when the funding transaction has been confirmed
613
642
/// on-chain, or, in case of a 0conf channel, when both parties have confirmed the channel
614
643
/// establishment.
615
644
ChannelReady {
616
- /// The channel_id of the channel that is ready.
645
+ /// The ` channel_id` of the channel that is ready.
617
646
channel_id : [ u8 ; 32 ] ,
618
647
/// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
619
648
/// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
@@ -624,15 +653,15 @@ pub enum Event {
624
653
/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
625
654
/// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
626
655
user_channel_id : u128 ,
627
- /// The node_id of the channel counterparty.
656
+ /// The ` node_id` of the channel counterparty.
628
657
counterparty_node_id : PublicKey ,
629
658
/// The features that this channel will operate with.
630
659
channel_type : ChannelTypeFeatures ,
631
660
} ,
632
661
/// Used to indicate that a previously opened channel with the given `channel_id` is in the
633
662
/// process of closure.
634
663
ChannelClosed {
635
- /// The channel_id of the channel which has been closed. Note that on-chain transactions
664
+ /// The ` channel_id` of the channel which has been closed. Note that on-chain transactions
636
665
/// resolving the channel are likely still awaiting confirmation.
637
666
channel_id : [ u8 ; 32 ] ,
638
667
/// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
@@ -931,6 +960,16 @@ impl Writeable for Event {
931
960
( 6 , channel_type, required) ,
932
961
} ) ;
933
962
} ,
963
+ & Event :: ChannelPending { ref channel_id, ref user_channel_id, ref former_temporary_channel_id, ref counterparty_node_id, ref funding_txo } => {
964
+ 31u8 . write ( writer) ?;
965
+ write_tlv_fields ! ( writer, {
966
+ ( 0 , channel_id, required) ,
967
+ ( 2 , user_channel_id, required) ,
968
+ ( 4 , former_temporary_channel_id, required) ,
969
+ ( 6 , counterparty_node_id, required) ,
970
+ ( 8 , funding_txo, required) ,
971
+ } ) ;
972
+ } ,
934
973
// Note that, going forward, all new events must only write data inside of
935
974
// `write_tlv_fields`. Versions 0.0.101+ will ignore odd-numbered events that write
936
975
// data via `write_tlv_fields`.
@@ -1271,6 +1310,31 @@ impl MaybeReadable for Event {
1271
1310
} ;
1272
1311
f ( )
1273
1312
} ,
1313
+ 31u8 => {
1314
+ let f = || {
1315
+ let mut channel_id = [ 0 ; 32 ] ;
1316
+ let mut user_channel_id: u128 = 0 ;
1317
+ let mut former_temporary_channel_id = None ;
1318
+ let mut counterparty_node_id = RequiredWrapper ( None ) ;
1319
+ let mut funding_txo = RequiredWrapper ( None ) ;
1320
+ read_tlv_fields ! ( reader, {
1321
+ ( 0 , channel_id, required) ,
1322
+ ( 2 , user_channel_id, required) ,
1323
+ ( 4 , former_temporary_channel_id, required) ,
1324
+ ( 6 , counterparty_node_id, required) ,
1325
+ ( 8 , funding_txo, required) ,
1326
+ } ) ;
1327
+
1328
+ Ok ( Some ( Event :: ChannelPending {
1329
+ channel_id,
1330
+ user_channel_id,
1331
+ former_temporary_channel_id,
1332
+ counterparty_node_id : counterparty_node_id. 0 . unwrap ( ) ,
1333
+ funding_txo : funding_txo. 0 . unwrap ( )
1334
+ } ) )
1335
+ } ;
1336
+ f ( )
1337
+ } ,
1274
1338
// Versions prior to 0.0.100 did not ignore odd types, instead returning InvalidValue.
1275
1339
// Version 0.0.100 failed to properly ignore odd types, possibly resulting in corrupt
1276
1340
// reads.
0 commit comments