@@ -24,7 +24,7 @@ use crate::ln::onion_utils::{DecodedOnionFailure, HTLCFailReason};
24
24
use crate :: offers:: invoice:: Bolt12Invoice ;
25
25
use crate :: offers:: invoice_request:: InvoiceRequest ;
26
26
use crate :: offers:: nonce:: Nonce ;
27
- use crate :: routing:: router:: { BlindedTail , InFlightHtlcs , Path , PaymentParameters , Route , RouteParameters , Router } ;
27
+ use crate :: routing:: router:: { BlindedTail , InFlightHtlcs , ManualRoutingParameters , Path , PaymentParameters , Route , RouteParameters , Router } ;
28
28
use crate :: sign:: { EntropySource , NodeSigner , Recipient } ;
29
29
use crate :: util:: errors:: APIError ;
30
30
use crate :: util:: logger:: Logger ;
@@ -61,7 +61,7 @@ pub(crate) enum PendingOutboundPayment {
61
61
AwaitingInvoice {
62
62
expiration : StaleExpiration ,
63
63
retry_strategy : Retry ,
64
- max_total_routing_fee_msat : Option < u64 > ,
64
+ manual_routing_params : Option < ManualRoutingParameters > ,
65
65
retryable_invoice_request : Option < RetryableInvoiceRequest >
66
66
} ,
67
67
// This state will never be persisted to disk because we transition from `AwaitingInvoice` to
@@ -849,10 +849,12 @@ impl OutboundPayments {
849
849
match self . pending_outbound_payments . lock ( ) . unwrap ( ) . entry ( payment_id) {
850
850
hash_map:: Entry :: Occupied ( entry) => match entry. get ( ) {
851
851
PendingOutboundPayment :: AwaitingInvoice {
852
- retry_strategy : retry, max_total_routing_fee_msat : max_total_fee , ..
852
+ retry_strategy : retry, manual_routing_params , ..
853
853
} => {
854
854
retry_strategy = * retry;
855
- max_total_routing_fee_msat = * max_total_fee;
855
+ max_total_routing_fee_msat = manual_routing_params. map (
856
+ |params| params. max_total_routing_fee_msat
857
+ ) . flatten ( ) ;
856
858
* entry. into_mut ( ) = PendingOutboundPayment :: InvoiceReceived {
857
859
payment_hash,
858
860
retry_strategy : * retry,
@@ -1004,7 +1006,7 @@ impl OutboundPayments {
1004
1006
match self . pending_outbound_payments . lock ( ) . unwrap ( ) . entry ( payment_id) {
1005
1007
hash_map:: Entry :: Occupied ( mut entry) => match entry. get ( ) {
1006
1008
PendingOutboundPayment :: AwaitingInvoice {
1007
- retry_strategy, retryable_invoice_request, max_total_routing_fee_msat , ..
1009
+ retry_strategy, retryable_invoice_request, manual_routing_params , ..
1008
1010
} => {
1009
1011
let invreq = & retryable_invoice_request
1010
1012
. as_ref ( )
@@ -1031,7 +1033,7 @@ impl OutboundPayments {
1031
1033
let payment_hash = PaymentHash ( Sha256 :: hash ( & keysend_preimage. 0 ) . to_byte_array ( ) ) ;
1032
1034
let pay_params = PaymentParameters :: from_static_invoice ( invoice) ;
1033
1035
let mut route_params = RouteParameters :: from_payment_params_and_value ( pay_params, amount_msat) ;
1034
- route_params. max_total_routing_fee_msat = * max_total_routing_fee_msat;
1036
+ route_params. max_total_routing_fee_msat = manual_routing_params . map ( |params| params . max_total_routing_fee_msat ) . flatten ( ) ;
1035
1037
1036
1038
if let Err ( ( ) ) = onion_utils:: set_max_path_length (
1037
1039
& mut route_params, & RecipientOnionFields :: spontaneous_empty ( ) , Some ( keysend_preimage) ,
@@ -1599,6 +1601,10 @@ impl OutboundPayments {
1599
1601
max_total_routing_fee_msat : Option < u64 > , retryable_invoice_request : Option < RetryableInvoiceRequest >
1600
1602
) -> Result < ( ) , ( ) > {
1601
1603
let mut pending_outbounds = self . pending_outbound_payments . lock ( ) . unwrap ( ) ;
1604
+ let manual_routing_params = max_total_routing_fee_msat. map (
1605
+ |fee_msats| ManualRoutingParameters :: new ( )
1606
+ . with_max_total_routing_fee_msat ( fee_msats)
1607
+ ) ;
1602
1608
match pending_outbounds. entry ( payment_id) {
1603
1609
hash_map:: Entry :: Occupied ( _) => Err ( ( ) ) ,
1604
1610
hash_map:: Entry :: Vacant ( entry) => {
@@ -1608,7 +1614,7 @@ impl OutboundPayments {
1608
1614
entry. insert ( PendingOutboundPayment :: AwaitingInvoice {
1609
1615
expiration,
1610
1616
retry_strategy,
1611
- max_total_routing_fee_msat ,
1617
+ manual_routing_params ,
1612
1618
retryable_invoice_request,
1613
1619
} ) ;
1614
1620
@@ -2238,7 +2244,7 @@ impl_writeable_tlv_based_enum_upgradable!(PendingOutboundPayment,
2238
2244
( 5 , AwaitingInvoice ) => {
2239
2245
( 0 , expiration, required) ,
2240
2246
( 2 , retry_strategy, required) ,
2241
- ( 4 , max_total_routing_fee_msat , option) ,
2247
+ ( 4 , manual_routing_params , option) ,
2242
2248
( 5 , retryable_invoice_request, option) ,
2243
2249
} ,
2244
2250
( 7 , InvoiceReceived ) => {
0 commit comments