@@ -593,6 +593,8 @@ 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
+ InvalidInvoice ,
596
598
/// The invoice was valid for the corresponding [`PaymentId`], but sending the payment failed.
597
599
SendingFailed ( RetryableSendFailure ) ,
598
600
}
@@ -604,6 +606,8 @@ pub enum Bolt12PaymentError {
604
606
UnexpectedInvoice ,
605
607
/// Payment for an invoice with the corresponding [`PaymentId`] was already initiated.
606
608
DuplicateInvoice ,
609
+ /// An invalid or incompatible invoice was provided to [`ChannelManager::pay_for_bolt12_invoice`].
610
+ InvalidInvoice ,
607
611
/// The invoice was valid for the corresponding [`PaymentId`], but required unknown features.
608
612
UnknownRequiredFeatures ,
609
613
/// The invoice was valid for the corresponding [`PaymentId`], but sending the payment failed.
@@ -902,6 +906,7 @@ impl OutboundPayments {
902
906
recipient_onion. payment_metadata = invoice. payment_metadata ( ) . map ( |v| v. clone ( ) ) ;
903
907
904
908
let payment_params = PaymentParameters :: from_bolt11_invoice ( invoice)
909
+ . map_err ( |_| Bolt11PaymentError :: InvalidInvoice ) ?
905
910
. with_user_config_ignoring_fee_limit ( route_params_config) ;
906
911
907
912
let mut route_params = RouteParameters :: from_payment_params_and_value ( payment_params, amount) ;
@@ -949,6 +954,7 @@ impl OutboundPayments {
949
954
950
955
let mut route_params = RouteParameters :: from_payment_params_and_value (
951
956
PaymentParameters :: from_bolt12_invoice ( & invoice)
957
+ . map_err ( |_| Bolt12PaymentError :: InvalidInvoice ) ?
952
958
. with_user_config_ignoring_fee_limit ( params_config) , invoice. amount_msats ( )
953
959
) ;
954
960
if let Some ( max_fee_msat) = params_config. max_total_routing_fee_msat {
@@ -1127,6 +1133,7 @@ impl OutboundPayments {
1127
1133
let keysend_preimage = PaymentPreimage ( entropy_source. get_secure_random_bytes ( ) ) ;
1128
1134
let payment_hash = PaymentHash ( Sha256 :: hash ( & keysend_preimage. 0 ) . to_byte_array ( ) ) ;
1129
1135
let pay_params = PaymentParameters :: from_static_invoice ( invoice)
1136
+ . map_err ( |_| Bolt12PaymentError :: InvalidInvoice ) ?
1130
1137
. with_user_config_ignoring_fee_limit ( * route_params_config) ;
1131
1138
let mut route_params = RouteParameters :: from_payment_params_and_value ( pay_params, amount_msat) ;
1132
1139
route_params. max_total_routing_fee_msat = route_params_config. max_total_routing_fee_msat ;
@@ -3034,7 +3041,7 @@ mod tests {
3034
3041
assert ! ( outbound_payments. has_pending_payments( ) ) ;
3035
3042
3036
3043
let route_params = RouteParameters :: from_payment_params_and_value (
3037
- PaymentParameters :: from_bolt12_invoice ( & invoice) ,
3044
+ PaymentParameters :: from_bolt12_invoice ( & invoice) . unwrap ( ) ,
3038
3045
invoice. amount_msats ( ) ,
3039
3046
) ;
3040
3047
router. expect_find_route ( route_params, Err ( "" ) ) ;
@@ -3086,7 +3093,7 @@ mod tests {
3086
3093
. sign ( recipient_sign) . unwrap ( ) ;
3087
3094
3088
3095
let route_params = RouteParameters {
3089
- payment_params : PaymentParameters :: from_bolt12_invoice ( & invoice) ,
3096
+ payment_params : PaymentParameters :: from_bolt12_invoice ( & invoice) . unwrap ( ) ,
3090
3097
final_value_msat : invoice. amount_msats ( ) ,
3091
3098
max_total_routing_fee_msat : Some ( 1234 ) ,
3092
3099
} ;
0 commit comments