Skip to content

Commit d5d502a

Browse files
Remove now-redundant PaymentParameters params
In the last commit, we made Route::route_params required instead of an Option. After this change, we can modify a few methods that took a Route in addition to a separate PaymentParameters argument, since the pay params can always be retrieved from the Route now.
1 parent 41f0809 commit d5d502a

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

lightning/src/ln/outbound_payment.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,14 +1203,13 @@ impl OutboundPayments {
12031203
},
12041204
};
12051205

1206-
let payment_params = Some(route_params.payment_params.clone());
12071206
let mut outbounds = self.pending_outbound_payments.lock().unwrap();
12081207
let onion_session_privs = match outbounds.entry(payment_id) {
12091208
hash_map::Entry::Occupied(entry) => match entry.get() {
12101209
PendingOutboundPayment::InvoiceReceived { .. } => {
12111210
let (retryable_payment, onion_session_privs) = Self::create_pending_payment(
12121211
payment_hash, recipient_onion.clone(), keysend_preimage, None, Some(bolt12_invoice.clone()), &route,
1213-
Some(retry_strategy), payment_params, entropy_source, best_block_height,
1212+
Some(retry_strategy), entropy_source, best_block_height,
12141213
);
12151214
*entry.into_mut() = retryable_payment;
12161215
onion_session_privs
@@ -1221,7 +1220,7 @@ impl OutboundPayments {
12211220
} else { unreachable!() };
12221221
let (retryable_payment, onion_session_privs) = Self::create_pending_payment(
12231222
payment_hash, recipient_onion.clone(), keysend_preimage, Some(invreq), Some(bolt12_invoice.clone()), &route,
1224-
Some(retry_strategy), payment_params, entropy_source, best_block_height
1223+
Some(retry_strategy), entropy_source, best_block_height
12251224
);
12261225
outbounds.insert(payment_id, retryable_payment);
12271226
onion_session_privs
@@ -1617,7 +1616,7 @@ impl OutboundPayments {
16171616

16181617
let onion_session_privs = self.add_new_pending_payment(payment_hash,
16191618
recipient_onion.clone(), payment_id, keysend_preimage, &route, Some(retry_strategy),
1620-
Some(route_params.payment_params.clone()), entropy_source, best_block_height, None)
1619+
entropy_source, best_block_height, None)
16211620
.map_err(|_| {
16221621
log_error!(logger, "Payment with id {} is already pending. New payment had payment hash {}",
16231622
payment_id, payment_hash);
@@ -1940,7 +1939,7 @@ impl OutboundPayments {
19401939
let recipient_onion_fields =
19411940
RecipientOnionFields::secret_only(payment_secret, route.get_total_amount());
19421941
let onion_session_privs = self.add_new_pending_payment(payment_hash,
1943-
recipient_onion_fields.clone(), payment_id, None, &route, None, None,
1942+
recipient_onion_fields.clone(), payment_id, None, &route, None,
19441943
entropy_source, best_block_height, None
19451944
).map_err(|e| {
19461945
debug_assert!(matches!(e, PaymentSendFailure::DuplicatePayment));
@@ -1996,14 +1995,14 @@ impl OutboundPayments {
19961995
&self, payment_hash: PaymentHash, recipient_onion: RecipientOnionFields, payment_id: PaymentId,
19971996
route: &Route, retry_strategy: Option<Retry>, entropy_source: &ES, best_block_height: u32
19981997
) -> Result<Vec<[u8; 32]>, PaymentSendFailure> {
1999-
self.add_new_pending_payment(payment_hash, recipient_onion, payment_id, None, route, retry_strategy, None, entropy_source, best_block_height, None)
1998+
self.add_new_pending_payment(payment_hash, recipient_onion, payment_id, None, route, retry_strategy, entropy_source, best_block_height, None)
20001999
}
20012000

20022001
#[rustfmt::skip]
20032002
pub(super) fn add_new_pending_payment<ES: EntropySource>(
20042003
&self, payment_hash: PaymentHash, recipient_onion: RecipientOnionFields, payment_id: PaymentId,
20052004
keysend_preimage: Option<PaymentPreimage>, route: &Route, retry_strategy: Option<Retry>,
2006-
payment_params: Option<PaymentParameters>, entropy_source: &ES, best_block_height: u32,
2005+
entropy_source: &ES, best_block_height: u32,
20072006
bolt12_invoice: Option<PaidBolt12Invoice>
20082007
) -> Result<Vec<[u8; 32]>, PaymentSendFailure> {
20092008
let mut pending_outbounds = self.pending_outbound_payments.lock().unwrap();
@@ -2012,7 +2011,7 @@ impl OutboundPayments {
20122011
hash_map::Entry::Vacant(entry) => {
20132012
let (payment, onion_session_privs) = Self::create_pending_payment(
20142013
payment_hash, recipient_onion, keysend_preimage, None, bolt12_invoice, route, retry_strategy,
2015-
payment_params, entropy_source, best_block_height
2014+
entropy_source, best_block_height
20162015
);
20172016
entry.insert(payment);
20182017
Ok(onion_session_privs)
@@ -2025,7 +2024,7 @@ impl OutboundPayments {
20252024
payment_hash: PaymentHash, recipient_onion: RecipientOnionFields,
20262025
keysend_preimage: Option<PaymentPreimage>, invoice_request: Option<InvoiceRequest>,
20272026
bolt12_invoice: Option<PaidBolt12Invoice>, route: &Route, retry_strategy: Option<Retry>,
2028-
payment_params: Option<PaymentParameters>, entropy_source: &ES, best_block_height: u32
2027+
entropy_source: &ES, best_block_height: u32
20292028
) -> (PendingOutboundPayment, Vec<[u8; 32]>) {
20302029
let mut onion_session_privs = Vec::with_capacity(route.paths.len());
20312030
for _ in 0..route.paths.len() {
@@ -2035,7 +2034,7 @@ impl OutboundPayments {
20352034
let mut payment = PendingOutboundPayment::Retryable {
20362035
retry_strategy,
20372036
attempts: PaymentAttempts::new(),
2038-
payment_params,
2037+
payment_params: Some(route.route_params.payment_params.clone()),
20392038
session_privs: new_hash_set(),
20402039
pending_amt_msat: 0,
20412040
pending_fee_msat: Some(0),
@@ -2965,7 +2964,7 @@ mod tests {
29652964
if on_retry {
29662965
outbound_payments.add_new_pending_payment(PaymentHash([0; 32]), RecipientOnionFields::spontaneous_empty(0),
29672966
PaymentId([0; 32]), None, &Route { paths: vec![], route_params: expired_route_params.clone() },
2968-
Some(Retry::Attempts(1)), Some(expired_route_params.payment_params.clone()),
2967+
Some(Retry::Attempts(1)),
29692968
&&keys_manager, 0, None).unwrap();
29702969
outbound_payments.find_route_and_send_payment(
29712970
PaymentHash([0; 32]), PaymentId([0; 32]), expired_route_params, &&router, vec![],
@@ -3011,7 +3010,7 @@ mod tests {
30113010
if on_retry {
30123011
outbound_payments.add_new_pending_payment(PaymentHash([0; 32]), RecipientOnionFields::spontaneous_empty(0),
30133012
PaymentId([0; 32]), None, &Route { paths: vec![], route_params: route_params.clone() },
3014-
Some(Retry::Attempts(1)), Some(route_params.payment_params.clone()),
3013+
Some(Retry::Attempts(1)),
30153014
&&keys_manager, 0, None).unwrap();
30163015
outbound_payments.find_route_and_send_payment(
30173016
PaymentHash([0; 32]), PaymentId([0; 32]), route_params, &&router, vec![],

0 commit comments

Comments
 (0)