@@ -311,9 +311,12 @@ where
311
311
& temporary_channel_id,
312
312
& counterparty_node_id,
313
313
)
314
- . expect (
315
- "Failed to force close channel after funding generation failed" ,
316
- ) ;
314
+ . unwrap_or_else ( |e| {
315
+ log_error ! ( self . logger, "Failed to force close channel after funding generation failed: {:?}" , e) ;
316
+ panic ! (
317
+ "Failed to force close channel after funding generation failed"
318
+ ) ;
319
+ } ) ;
317
320
}
318
321
}
319
322
}
@@ -341,7 +344,10 @@ where
341
344
status : Some ( PaymentStatus :: Failed ) ,
342
345
..PaymentDetailsUpdate :: new ( payment_hash)
343
346
} ;
344
- self . payment_store . update ( & update) . expect ( "Failed to access payment store" ) ;
347
+ self . payment_store . update ( & update) . unwrap_or_else ( |e| {
348
+ log_error ! ( self . logger, "Failed to access payment store: {}" , e) ;
349
+ panic ! ( "Failed to access payment store" ) ;
350
+ } ) ;
345
351
return ;
346
352
}
347
353
}
@@ -379,7 +385,10 @@ where
379
385
status : Some ( PaymentStatus :: Failed ) ,
380
386
..PaymentDetailsUpdate :: new ( payment_hash)
381
387
} ;
382
- self . payment_store . update ( & update) . expect ( "Failed to access payment store" ) ;
388
+ self . payment_store . update ( & update) . unwrap_or_else ( |e| {
389
+ log_error ! ( self . logger, "Failed to access payment store: {}" , e) ;
390
+ panic ! ( "Failed to access payment store" ) ;
391
+ } ) ;
383
392
}
384
393
}
385
394
LdkEvent :: PaymentClaimed {
@@ -459,15 +468,19 @@ where
459
468
460
469
self . event_queue
461
470
. add_event ( Event :: PaymentReceived { payment_hash, amount_msat } )
462
- . expect ( "Failed to push to event queue" ) ;
471
+ . unwrap_or_else ( |e| {
472
+ log_error ! ( self . logger, "Failed to push to event queue: {}" , e) ;
473
+ panic ! ( "Failed to push to event queue" ) ;
474
+ } ) ;
463
475
}
464
476
LdkEvent :: PaymentSent { payment_preimage, payment_hash, fee_paid_msat, .. } => {
465
477
if let Some ( mut payment) = self . payment_store . get ( & payment_hash) {
466
478
payment. preimage = Some ( payment_preimage) ;
467
479
payment. status = PaymentStatus :: Succeeded ;
468
- self . payment_store
469
- . insert ( payment. clone ( ) )
470
- . expect ( "Failed to access payment store" ) ;
480
+ self . payment_store . insert ( payment. clone ( ) ) . unwrap_or_else ( |e| {
481
+ log_error ! ( self . logger, "Failed to access payment store: {}" , e) ;
482
+ panic ! ( "Failed to access payment store" ) ;
483
+ } ) ;
471
484
log_info ! (
472
485
self . logger,
473
486
"Successfully sent payment of {}msat{} from \
@@ -484,7 +497,10 @@ where
484
497
}
485
498
self . event_queue
486
499
. add_event ( Event :: PaymentSuccessful { payment_hash } )
487
- . expect ( "Failed to push to event queue" ) ;
500
+ . unwrap_or_else ( |e| {
501
+ log_error ! ( self . logger, "Failed to push to event queue: {}" , e) ;
502
+ panic ! ( "Failed to push to event queue" ) ;
503
+ } ) ;
488
504
}
489
505
LdkEvent :: PaymentFailed { payment_hash, .. } => {
490
506
log_info ! (
@@ -497,10 +513,16 @@ where
497
513
status : Some ( PaymentStatus :: Failed ) ,
498
514
..PaymentDetailsUpdate :: new ( payment_hash)
499
515
} ;
500
- self . payment_store . update ( & update) . expect ( "Failed to access payment store" ) ;
501
- self . event_queue
502
- . add_event ( Event :: PaymentFailed { payment_hash } )
503
- . expect ( "Failed to push to event queue" ) ;
516
+ self . payment_store . update ( & update) . unwrap_or_else ( |e| {
517
+ log_error ! ( self . logger, "Failed to access payment store: {}" , e) ;
518
+ panic ! ( "Failed to access payment store" ) ;
519
+ } ) ;
520
+ self . event_queue . add_event ( Event :: PaymentFailed { payment_hash } ) . unwrap_or_else (
521
+ |e| {
522
+ log_error ! ( self . logger, "Failed to push to event queue: {}" , e) ;
523
+ panic ! ( "Failed to push to event queue" ) ;
524
+ } ,
525
+ ) ;
504
526
}
505
527
506
528
LdkEvent :: PaymentPathSuccessful { .. } => { }
@@ -526,8 +548,11 @@ where
526
548
}
527
549
LdkEvent :: SpendableOutputs { outputs } => {
528
550
// TODO: We should eventually remember the outputs and supply them to the wallet's coin selection, once BDK allows us to do so.
529
- let destination_address =
530
- self . wallet . get_new_address ( ) . expect ( "Failed to get destination address" ) ;
551
+ let destination_address = self . wallet . get_new_address ( ) . unwrap_or_else ( |e| {
552
+ log_error ! ( self . logger, "Failed to get destination address: {}" , e) ;
553
+ panic ! ( "Failed to get destination address" ) ;
554
+ } ) ;
555
+
531
556
let output_descriptors = & outputs. iter ( ) . collect :: < Vec < _ > > ( ) ;
532
557
let tx_feerate =
533
558
self . wallet . get_est_sat_per_1000_weight ( ConfirmationTarget :: Normal ) ;
@@ -676,7 +701,10 @@ where
676
701
counterparty_node_id,
677
702
funding_txo,
678
703
} )
679
- . expect ( "Failed to push to event queue" ) ;
704
+ . unwrap_or_else ( |e| {
705
+ log_error ! ( self . logger, "Failed to push to event queue: {}" , e) ;
706
+ panic ! ( "Failed to push to event queue" ) ;
707
+ } ) ;
680
708
}
681
709
LdkEvent :: ChannelReady {
682
710
channel_id, user_channel_id, counterparty_node_id, ..
@@ -692,7 +720,10 @@ where
692
720
channel_id : ChannelId ( channel_id) ,
693
721
user_channel_id : UserChannelId ( user_channel_id) ,
694
722
} )
695
- . expect ( "Failed to push to event queue" ) ;
723
+ . unwrap_or_else ( |e| {
724
+ log_error ! ( self . logger, "Failed to push to event queue: {}" , e) ;
725
+ panic ! ( "Failed to push to event queue" ) ;
726
+ } ) ;
696
727
}
697
728
LdkEvent :: ChannelClosed { channel_id, reason, user_channel_id } => {
698
729
log_info ! (
@@ -706,7 +737,10 @@ where
706
737
channel_id : ChannelId ( channel_id) ,
707
738
user_channel_id : UserChannelId ( user_channel_id) ,
708
739
} )
709
- . expect ( "Failed to push to event queue" ) ;
740
+ . unwrap_or_else ( |e| {
741
+ log_error ! ( self . logger, "Failed to push to event queue: {}" , e) ;
742
+ panic ! ( "Failed to push to event queue" ) ;
743
+ } ) ;
710
744
}
711
745
LdkEvent :: DiscardFunding { .. } => { }
712
746
LdkEvent :: HTLCIntercepted { .. } => { }
0 commit comments