@@ -19,7 +19,8 @@ use lightning::routing::gossip::NodeId;
1919use lightning:: util:: errors:: APIError ;
2020use lightning:: util:: ser:: { Readable , ReadableArgs , Writeable , Writer } ;
2121
22- use bitcoin:: secp256k1:: Secp256k1 ;
22+ use bitcoin:: secp256k1:: { PublicKey , Secp256k1 } ;
23+ use bitcoin:: OutPoint ;
2324use rand:: { thread_rng, Rng } ;
2425use std:: collections:: VecDeque ;
2526use std:: ops:: Deref ;
@@ -48,6 +49,19 @@ pub enum Event {
4849 /// The value, in thousandths of a satoshi, that has been received.
4950 amount_msat : u64 ,
5051 } ,
52+ /// A channel has been created and is pending confirmation on-chain.
53+ ChannelPending {
54+ /// The `channel_id` of the channel.
55+ channel_id : [ u8 ; 32 ] ,
56+ /// The `user_channel_id` of the channel.
57+ user_channel_id : u128 ,
58+ /// The `temporary_channel_id` this channel used to be known by during channel establishment.
59+ former_temporary_channel_id : [ u8 ; 32 ] ,
60+ /// The `node_id` of the channel counterparty.
61+ counterparty_node_id : PublicKey ,
62+ /// The outpoint of the channel's funding transaction.
63+ funding_txo : OutPoint ,
64+ } ,
5165 /// A channel is ready to be used.
5266 ChannelReady {
5367 /// The `channel_id` of the channel.
@@ -79,7 +93,14 @@ impl_writeable_tlv_based_enum!(Event,
7993 ( 0 , channel_id, required) ,
8094 ( 1 , user_channel_id, required) ,
8195 } ,
82- ( 4 , ChannelClosed ) => {
96+ ( 4 , ChannelPending ) => {
97+ ( 0 , channel_id, required) ,
98+ ( 1 , user_channel_id, required) ,
99+ ( 2 , former_temporary_channel_id, required) ,
100+ ( 3 , counterparty_node_id, required) ,
101+ ( 4 , funding_txo, required) ,
102+ } ,
103+ ( 5 , ChannelClosed ) => {
83104 ( 0 , channel_id, required) ,
84105 ( 1 , user_channel_id, required) ,
85106 } ;
@@ -607,20 +628,34 @@ where
607628 }
608629 }
609630 LdkEvent :: ChannelPending {
610- channel_id : _ ,
611- user_channel_id : _ ,
612- former_temporary_channel_id : _ ,
613- counterparty_node_id : _ ,
614- funding_txo : _ ,
631+ channel_id,
632+ user_channel_id,
633+ former_temporary_channel_id,
634+ counterparty_node_id,
635+ funding_txo,
615636 } => {
616- // TODO!
637+ log_info ! (
638+ self . logger,
639+ "New channel {} with counterparty {} has been created and is pending confirmation on chain." ,
640+ hex_utils:: to_string( & channel_id) ,
641+ counterparty_node_id,
642+ ) ;
643+ self . event_queue
644+ . add_event ( Event :: ChannelPending {
645+ channel_id,
646+ user_channel_id,
647+ former_temporary_channel_id : former_temporary_channel_id. unwrap ( ) ,
648+ counterparty_node_id,
649+ funding_txo,
650+ } )
651+ . expect ( "Failed to push to event queue" ) ;
617652 }
618653 LdkEvent :: ChannelReady {
619654 channel_id, user_channel_id, counterparty_node_id, ..
620655 } => {
621656 log_info ! (
622657 self . logger,
623- "Channel {} with {} ready to be used." ,
658+ "Channel {} with counterparty {} ready to be used." ,
624659 hex_utils:: to_string( & channel_id) ,
625660 counterparty_node_id,
626661 ) ;
0 commit comments