@@ -27,9 +27,9 @@ 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 , OutPoint } ;
31
31
#[ cfg( anchors) ]
32
- use bitcoin:: { OutPoint , Txid , TxIn , TxOut , Witness } ;
32
+ use bitcoin:: { Txid , TxIn , TxOut , Witness } ;
33
33
use bitcoin:: blockdata:: script:: Script ;
34
34
use bitcoin:: hashes:: Hash ;
35
35
use bitcoin:: hashes:: sha256:: Hash as Sha256 ;
@@ -821,12 +821,33 @@ pub enum Event {
821
821
/// transaction.
822
822
claim_from_onchain_tx : bool ,
823
823
} ,
824
+ /// Used to indicate that a channel with the given `channel_id` is being opened and pending
825
+ /// confirmation on-chain.
826
+ ///
827
+ /// This event is emitted when the funding transaction has been signed.
828
+ ChannelPending {
829
+ /// The `channel_id` of the channel that is pending confirmation.
830
+ channel_id : [ u8 ; 32 ] ,
831
+ /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
832
+ /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
833
+ /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
834
+ /// `user_channel_id` will be randomized for an inbound channel.
835
+ ///
836
+ /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
837
+ /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
838
+ /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
839
+ user_channel_id : u128 ,
840
+ /// The `node_id` of the channel counterparty.
841
+ counterparty_node_id : PublicKey ,
842
+ /// The outpoint of the channel's funding transaction.
843
+ funding_txo : OutPoint ,
844
+ } ,
824
845
/// Used to indicate that a channel with the given `channel_id` is ready to
825
846
/// be used. This event is emitted either when the funding transaction has been confirmed
826
847
/// on-chain, or, in case of a 0conf channel, when both parties have confirmed the channel
827
848
/// establishment.
828
849
ChannelReady {
829
- /// The channel_id of the channel that is ready.
850
+ /// The ` channel_id` of the channel that is ready.
830
851
channel_id : [ u8 ; 32 ] ,
831
852
/// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
832
853
/// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
@@ -837,15 +858,15 @@ pub enum Event {
837
858
/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
838
859
/// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
839
860
user_channel_id : u128 ,
840
- /// The node_id of the channel counterparty.
861
+ /// The ` node_id` of the channel counterparty.
841
862
counterparty_node_id : PublicKey ,
842
863
/// The features that this channel will operate with.
843
864
channel_type : ChannelTypeFeatures ,
844
865
} ,
845
866
/// Used to indicate that a previously opened channel with the given `channel_id` is in the
846
867
/// process of closure.
847
868
ChannelClosed {
848
- /// The channel_id of the channel which has been closed. Note that on-chain transactions
869
+ /// The ` channel_id` of the channel which has been closed. Note that on-chain transactions
849
870
/// resolving the channel are likely still awaiting confirmation.
850
871
channel_id : [ u8 ; 32 ] ,
851
872
/// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
@@ -1140,6 +1161,15 @@ impl Writeable for Event {
1140
1161
( 6 , channel_type, required) ,
1141
1162
} ) ;
1142
1163
} ,
1164
+ & Event :: ChannelPending { ref channel_id, ref user_channel_id, ref counterparty_node_id, ref funding_txo } => {
1165
+ 31u8 . write ( writer) ?;
1166
+ write_tlv_fields ! ( writer, {
1167
+ ( 0 , channel_id, required) ,
1168
+ ( 2 , user_channel_id, required) ,
1169
+ ( 4 , counterparty_node_id, required) ,
1170
+ ( 6 , funding_txo, required) ,
1171
+ } ) ;
1172
+ } ,
1143
1173
// Note that, going forward, all new events must only write data inside of
1144
1174
// `write_tlv_fields`. Versions 0.0.101+ will ignore odd-numbered events that write
1145
1175
// data via `write_tlv_fields`.
@@ -1478,6 +1508,28 @@ impl MaybeReadable for Event {
1478
1508
} ;
1479
1509
f ( )
1480
1510
} ,
1511
+ 31u8 => {
1512
+ let f = || {
1513
+ let mut channel_id = [ 0 ; 32 ] ;
1514
+ let mut user_channel_id: u128 = 0 ;
1515
+ let mut counterparty_node_id = RequiredWrapper ( None ) ;
1516
+ let mut funding_txo = RequiredWrapper ( None ) ;
1517
+ read_tlv_fields ! ( reader, {
1518
+ ( 0 , channel_id, required) ,
1519
+ ( 2 , user_channel_id, required) ,
1520
+ ( 4 , counterparty_node_id, required) ,
1521
+ ( 6 , funding_txo, required) ,
1522
+ } ) ;
1523
+
1524
+ Ok ( Some ( Event :: ChannelReady {
1525
+ channel_id,
1526
+ user_channel_id,
1527
+ counterparty_node_id : counterparty_node_id. 0 . unwrap ( ) ,
1528
+ channel_type : funding_txo. 0 . unwrap ( )
1529
+ } ) )
1530
+ } ;
1531
+ f ( )
1532
+ } ,
1481
1533
// Versions prior to 0.0.100 did not ignore odd types, instead returning InvalidValue.
1482
1534
// Version 0.0.100 failed to properly ignore odd types, possibly resulting in corrupt
1483
1535
// reads.
0 commit comments