@@ -593,6 +593,10 @@ pub enum Bolt11PaymentError {
593
593
/// [`Bolt11Invoice`]: lightning_invoice::Bolt11Invoice
594
594
/// [`ChannelManager::pay_for_bolt11_invoice`]: crate::ln::channelmanager::ChannelManager::pay_for_bolt11_invoice
595
595
InvalidAmount ,
596
+ /// An invalid or incompatible invoice was provided to [`ChannelManager::pay_for_bolt11_invoice`].
597
+ ///
598
+ /// [`ChannelManager::pay_for_bolt11_invoice`]: crate::ln::channelmanager::ChannelManager::pay_for_bolt11_invoice
599
+ InvalidInvoice ,
596
600
/// The invoice was valid for the corresponding [`PaymentId`], but sending the payment failed.
597
601
SendingFailed ( RetryableSendFailure ) ,
598
602
}
@@ -604,7 +608,13 @@ pub enum Bolt12PaymentError {
604
608
UnexpectedInvoice ,
605
609
/// Payment for an invoice with the corresponding [`PaymentId`] was already initiated.
606
610
DuplicateInvoice ,
611
+ /// An invalid or incompatible invoice was provided to [`ChannelManager`].
612
+ ///
613
+ /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
614
+ InvalidInvoice ,
607
615
/// The invoice was valid for the corresponding [`PaymentId`], but required unknown features.
616
+ ///
617
+ /// [`ChannelManager::pay_for_bolt12_invoice`]: crate::ln::channelmanager::ChannelManager::pay_for_bolt12_invoice
608
618
UnknownRequiredFeatures ,
609
619
/// The invoice was valid for the corresponding [`PaymentId`], but sending the payment failed.
610
620
SendingFailed ( RetryableSendFailure ) ,
@@ -902,6 +912,7 @@ impl OutboundPayments {
902
912
recipient_onion. payment_metadata = invoice. payment_metadata ( ) . map ( |v| v. clone ( ) ) ;
903
913
904
914
let payment_params = PaymentParameters :: from_bolt11_invoice ( invoice)
915
+ . map_err ( |_| Bolt11PaymentError :: InvalidInvoice ) ?
905
916
. with_user_config_ignoring_fee_limit ( route_params_config) ;
906
917
907
918
let mut route_params = RouteParameters :: from_payment_params_and_value ( payment_params, amount) ;
@@ -949,6 +960,7 @@ impl OutboundPayments {
949
960
950
961
let mut route_params = RouteParameters :: from_payment_params_and_value (
951
962
PaymentParameters :: from_bolt12_invoice ( & invoice)
963
+ . map_err ( |_| Bolt12PaymentError :: InvalidInvoice ) ?
952
964
. with_user_config_ignoring_fee_limit ( params_config) , invoice. amount_msats ( )
953
965
) ;
954
966
if let Some ( max_fee_msat) = params_config. max_total_routing_fee_msat {
@@ -1127,6 +1139,7 @@ impl OutboundPayments {
1127
1139
let keysend_preimage = PaymentPreimage ( entropy_source. get_secure_random_bytes ( ) ) ;
1128
1140
let payment_hash = PaymentHash ( Sha256 :: hash ( & keysend_preimage. 0 ) . to_byte_array ( ) ) ;
1129
1141
let pay_params = PaymentParameters :: from_static_invoice ( invoice)
1142
+ . map_err ( |_| Bolt12PaymentError :: InvalidInvoice ) ?
1130
1143
. with_user_config_ignoring_fee_limit ( * route_params_config) ;
1131
1144
let mut route_params = RouteParameters :: from_payment_params_and_value ( pay_params, amount_msat) ;
1132
1145
route_params. max_total_routing_fee_msat = route_params_config. max_total_routing_fee_msat ;
@@ -3034,7 +3047,7 @@ mod tests {
3034
3047
assert ! ( outbound_payments. has_pending_payments( ) ) ;
3035
3048
3036
3049
let route_params = RouteParameters :: from_payment_params_and_value (
3037
- PaymentParameters :: from_bolt12_invoice ( & invoice) ,
3050
+ PaymentParameters :: from_bolt12_invoice ( & invoice) . unwrap ( ) ,
3038
3051
invoice. amount_msats ( ) ,
3039
3052
) ;
3040
3053
router. expect_find_route ( route_params, Err ( "" ) ) ;
@@ -3086,7 +3099,7 @@ mod tests {
3086
3099
. sign ( recipient_sign) . unwrap ( ) ;
3087
3100
3088
3101
let route_params = RouteParameters {
3089
- payment_params : PaymentParameters :: from_bolt12_invoice ( & invoice) ,
3102
+ payment_params : PaymentParameters :: from_bolt12_invoice ( & invoice) . unwrap ( ) ,
3090
3103
final_value_msat : invoice. amount_msats ( ) ,
3091
3104
max_total_routing_fee_msat : Some ( 1234 ) ,
3092
3105
} ;
0 commit comments