@@ -79,15 +79,16 @@ pub use crate::swap::{FailedSwapInfo, ResolveFailedSwapInfo, SwapAddressInfo, Sw
79
79
use crate :: task_manager:: TaskManager ;
80
80
use crate :: util:: unix_timestamp_to_system_time;
81
81
use crate :: util:: LogIgnoreError ;
82
- use breez_sdk_core :: error :: LnUrlWithdrawError ;
82
+
83
83
pub use breez_sdk_core:: error:: ReceiveOnchainError as SwapError ;
84
- use breez_sdk_core:: error:: ReceiveOnchainError ;
84
+ use breez_sdk_core:: error:: { LnUrlWithdrawError , ReceiveOnchainError , SendPaymentError } ;
85
85
use breez_sdk_core:: {
86
86
parse, parse_invoice, BreezServices , GreenlightCredentials , GreenlightNodeConfig , InputType ,
87
87
ListPaymentsRequest , LnUrlPayRequest , LnUrlPayRequestData , LnUrlWithdrawRequest ,
88
88
LnUrlWithdrawRequestData , NodeConfig , OpenChannelFeeRequest , OpeningFeeParams , PaymentDetails ,
89
89
PaymentTypeFilter , PrepareRefundRequest , PrepareSweepRequest , ReceiveOnchainRequest ,
90
- RefundRequest , SendPaymentRequest , SweepRequest ,
90
+ RefundRequest , ReportIssueRequest , ReportPaymentFailureDetails , SendPaymentRequest ,
91
+ SweepRequest ,
91
92
} ;
92
93
use crow:: { CountryCode , LanguageCode , OfferManager , TopupError , TopupInfo } ;
93
94
pub use crow:: { PermanentFailureCode , TemporaryFailureCode } ;
@@ -650,13 +651,27 @@ impl LightningNode {
650
651
self . get_exchange_rate ( ) ,
651
652
) ;
652
653
653
- self . rt
654
+ let result = self
655
+ . rt
654
656
. handle ( )
655
657
. block_on ( self . sdk . send_payment ( SendPaymentRequest {
656
658
bolt11 : invoice_details. invoice ,
657
659
amount_msat,
658
- } ) )
659
- . map_err ( map_send_payment_error) ?;
660
+ } ) ) ;
661
+
662
+ if matches ! (
663
+ result,
664
+ Err ( SendPaymentError :: Generic { .. }
665
+ | SendPaymentError :: PaymentFailed { .. }
666
+ | SendPaymentError :: PaymentTimeout { .. }
667
+ | SendPaymentError :: RouteNotFound { .. }
668
+ | SendPaymentError :: RouteTooExpensive { .. }
669
+ | SendPaymentError :: ServiceConnectivity { .. } )
670
+ ) {
671
+ self . report_send_payment_issue ( invoice_details. payment_hash ) ;
672
+ }
673
+
674
+ result. map_err ( map_send_payment_error) ?;
660
675
Ok ( ( ) )
661
676
}
662
677
@@ -688,11 +703,14 @@ impl LightningNode {
688
703
"LNURL server returned error: {}" ,
689
704
data. reason
690
705
) ,
691
- breez_sdk_core:: LnUrlPayResult :: PayError { data } => runtime_error ! (
692
- LnUrlPayErrorCode :: PaymentFailed ,
693
- "Paying invoice for LNURL pay failed: {}" ,
694
- data. reason
695
- ) ,
706
+ breez_sdk_core:: LnUrlPayResult :: PayError { data } => {
707
+ self . report_send_payment_issue ( data. payment_hash ) ;
708
+ runtime_error ! (
709
+ LnUrlPayErrorCode :: PaymentFailed ,
710
+ "Paying invoice for LNURL pay failed: {}" ,
711
+ data. reason
712
+ )
713
+ }
696
714
} ?;
697
715
self . store_payment_info ( & payment_hash, None ) ;
698
716
Ok ( payment_hash)
@@ -1535,6 +1553,19 @@ impl LightningNode {
1535
1553
. lock_unwrap ( )
1536
1554
. retrieve_latest_fiat_topup_info ( )
1537
1555
}
1556
+
1557
+ fn report_send_payment_issue ( & self , payment_hash : String ) {
1558
+ debug ! ( "Reporting failure of payment: {payment_hash}" ) ;
1559
+ let data = ReportPaymentFailureDetails {
1560
+ payment_hash,
1561
+ comment : None ,
1562
+ } ;
1563
+ let request = ReportIssueRequest :: PaymentFailure { data } ;
1564
+ self . rt
1565
+ . handle ( )
1566
+ . block_on ( self . sdk . report_issue ( request) )
1567
+ . log_ignore_error ( Level :: Warn , "Failed to report issue" ) ;
1568
+ }
1538
1569
}
1539
1570
1540
1571
/// Accept lipa's terms and conditions. Should be called before instantiating a [`LightningNode`]
0 commit comments