@@ -19,7 +19,8 @@ use lightning::routing::gossip::NodeId;
19
19
use lightning:: util:: errors:: APIError ;
20
20
use lightning:: util:: ser:: { Readable , ReadableArgs , Writeable , Writer } ;
21
21
22
- use bitcoin:: secp256k1:: Secp256k1 ;
22
+ use bitcoin:: secp256k1:: { PublicKey , Secp256k1 } ;
23
+ use bitcoin:: OutPoint ;
23
24
use rand:: { thread_rng, Rng } ;
24
25
use std:: collections:: VecDeque ;
25
26
use std:: ops:: Deref ;
@@ -48,6 +49,19 @@ pub enum Event {
48
49
/// The value, in thousandths of a satoshi, that has been received.
49
50
amount_msat : u64 ,
50
51
} ,
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
+ } ,
51
65
/// A channel is ready to be used.
52
66
ChannelReady {
53
67
/// The `channel_id` of the channel.
@@ -79,7 +93,14 @@ impl_writeable_tlv_based_enum!(Event,
79
93
( 0 , channel_id, required) ,
80
94
( 1 , user_channel_id, required) ,
81
95
} ,
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 ) => {
83
104
( 0 , channel_id, required) ,
84
105
( 1 , user_channel_id, required) ,
85
106
} ;
@@ -607,20 +628,34 @@ where
607
628
}
608
629
}
609
630
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,
615
636
} => {
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" ) ;
617
652
}
618
653
LdkEvent :: ChannelReady {
619
654
channel_id, user_channel_id, counterparty_node_id, ..
620
655
} => {
621
656
log_info ! (
622
657
self . logger,
623
- "Channel {} with {} ready to be used." ,
658
+ "Channel {} with counterparty {} ready to be used." ,
624
659
hex_utils:: to_string( & channel_id) ,
625
660
counterparty_node_id,
626
661
) ;
0 commit comments