@@ -278,8 +278,34 @@ async fn handle_ldk_events(
278
278
}
279
279
persister. persist ( OUTBOUND_PAYMENTS_FNAME , & * outbound) . unwrap ( ) ;
280
280
}
281
- Event :: OpenChannelRequest { .. } => {
282
- // Unreachable, we don't set manually_accept_inbound_channels
281
+ Event :: OpenChannelRequest {
282
+ ref temporary_channel_id, ref counterparty_node_id, ..
283
+ } => {
284
+ let mut random_bytes = [ 0u8 ; 16 ] ;
285
+ random_bytes. copy_from_slice ( & keys_manager. get_secure_random_bytes ( ) [ ..16 ] ) ;
286
+ let user_channel_id = u128:: from_be_bytes ( random_bytes) ;
287
+ let res = channel_manager. accept_inbound_channel (
288
+ temporary_channel_id,
289
+ counterparty_node_id,
290
+ user_channel_id,
291
+ ) ;
292
+
293
+ if let Err ( e) = res {
294
+ print ! (
295
+ "\n EVENT: Failed to accept inbound channel ({}) from {}: {:?}" ,
296
+ hex_utils:: hex_str( & temporary_channel_id[ ..] ) ,
297
+ hex_utils:: hex_str( & counterparty_node_id. serialize( ) ) ,
298
+ e,
299
+ ) ;
300
+ } else {
301
+ print ! (
302
+ "\n EVENT: Accepted inbound channel ({}) from {}" ,
303
+ hex_utils:: hex_str( & temporary_channel_id[ ..] ) ,
304
+ hex_utils:: hex_str( & counterparty_node_id. serialize( ) ) ,
305
+ ) ;
306
+ }
307
+ print ! ( "> " ) ;
308
+ io:: stdout ( ) . flush ( ) . unwrap ( ) ;
283
309
}
284
310
Event :: PaymentPathSuccessful { .. } => { }
285
311
Event :: PaymentPathFailed { .. } => { }
@@ -566,6 +592,7 @@ async fn start_ldk() {
566
592
// Step 11: Initialize the ChannelManager
567
593
let mut user_config = UserConfig :: default ( ) ;
568
594
user_config. channel_handshake_limits . force_announced_channel_preference = false ;
595
+ user_config. manually_accept_inbound_channels = true ;
569
596
let mut restarting_node = true ;
570
597
let ( channel_manager_blockhash, channel_manager) = {
571
598
if let Ok ( mut f) = fs:: File :: open ( format ! ( "{}/manager" , ldk_data_dir. clone( ) ) ) {
0 commit comments