Skip to content

Commit ae34533

Browse files
Parameterize add_new_pending_payment with retry strategy and route params
1 parent cbb75e2 commit ae34533

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ use crate::ln::onion_utils::HTLCFailReason;
5353
use crate::ln::msgs::{ChannelMessageHandler, DecodeError, LightningError, MAX_VALUE_MSAT};
5454
#[cfg(test)]
5555
use crate::ln::outbound_payment;
56-
use crate::ln::outbound_payment::{OutboundPayments, PendingOutboundPayment};
56+
use crate::ln::outbound_payment::{OutboundPayments, PendingOutboundPayment, Retry};
5757
use crate::ln::wire::Encode;
5858
use crate::chain::keysinterface::{EntropySource, KeysManager, NodeSigner, Recipient, Sign, SignerProvider};
5959
use crate::util::config::{UserConfig, ChannelConfig};
@@ -2457,7 +2457,7 @@ where
24572457
#[cfg(test)]
24582458
pub(crate) fn test_add_new_pending_payment(&self, payment_hash: PaymentHash, payment_secret: Option<PaymentSecret>, payment_id: PaymentId, route: &Route) -> Result<Vec<[u8; 32]>, PaymentSendFailure> {
24592459
let best_block_height = self.best_block.read().unwrap().height();
2460-
self.pending_outbound_payments.test_add_new_pending_payment(payment_hash, payment_secret, payment_id, route, &self.entropy_source, best_block_height)
2460+
self.pending_outbound_payments.test_add_new_pending_payment(payment_hash, payment_secret, payment_id, route, Retry::Attempts(0), &self.entropy_source, best_block_height)
24612461
}
24622462

24632463

lightning/src/ln/outbound_payment.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ impl OutboundPayments {
359359
F: Fn(&Vec<RouteHop>, &Option<PaymentParameters>, &PaymentHash, &Option<PaymentSecret>, u64,
360360
u32, PaymentId, &Option<PaymentPreimage>, [u8; 32]) -> Result<(), APIError>
361361
{
362-
let onion_session_privs = self.add_new_pending_payment(payment_hash, *payment_secret, payment_id, route, entropy_source, best_block_height)?;
362+
let onion_session_privs = self.add_new_pending_payment(payment_hash, *payment_secret, payment_id, route, Retry::Attempts(0), None, entropy_source, best_block_height)?;
363363
self.send_payment_internal(route, payment_hash, payment_secret, None, payment_id, None, onion_session_privs, node_signer, best_block_height, send_payment_along_path)
364364
}
365365

@@ -378,7 +378,7 @@ impl OutboundPayments {
378378
None => PaymentPreimage(entropy_source.get_secure_random_bytes()),
379379
};
380380
let payment_hash = PaymentHash(Sha256::hash(&preimage.0).into_inner());
381-
let onion_session_privs = self.add_new_pending_payment(payment_hash, None, payment_id, &route, entropy_source, best_block_height)?;
381+
let onion_session_privs = self.add_new_pending_payment(payment_hash, None, payment_id, &route, Retry::Attempts(0), None, entropy_source, best_block_height)?;
382382

383383
match self.send_payment_internal(route, payment_hash, &None, Some(preimage), payment_id, None, onion_session_privs, node_signer, best_block_height, send_payment_along_path) {
384384
Ok(()) => Ok(payment_hash),
@@ -477,7 +477,7 @@ impl OutboundPayments {
477477
}
478478

479479
let route = Route { paths: vec![hops], payment_params: None };
480-
let onion_session_privs = self.add_new_pending_payment(payment_hash, None, payment_id, &route, entropy_source, best_block_height)?;
480+
let onion_session_privs = self.add_new_pending_payment(payment_hash, None, payment_id, &route, Retry::Attempts(0), None, entropy_source, best_block_height)?;
481481

482482
match self.send_payment_internal(&route, payment_hash, &None, None, payment_id, None, onion_session_privs, node_signer, best_block_height, send_payment_along_path) {
483483
Ok(()) => Ok((payment_hash, payment_id)),
@@ -488,14 +488,15 @@ impl OutboundPayments {
488488
#[cfg(test)]
489489
pub(super) fn test_add_new_pending_payment<ES: Deref>(
490490
&self, payment_hash: PaymentHash, payment_secret: Option<PaymentSecret>, payment_id: PaymentId,
491-
route: &Route, entropy_source: &ES, best_block_height: u32
491+
route: &Route, retry_strategy: Retry, entropy_source: &ES, best_block_height: u32
492492
) -> Result<Vec<[u8; 32]>, PaymentSendFailure> where ES::Target: EntropySource {
493-
self.add_new_pending_payment(payment_hash, payment_secret, payment_id, route, entropy_source, best_block_height)
493+
self.add_new_pending_payment(payment_hash, payment_secret, payment_id, route, retry_strategy, None, entropy_source, best_block_height)
494494
}
495495

496496
pub(super) fn add_new_pending_payment<ES: Deref>(
497497
&self, payment_hash: PaymentHash, payment_secret: Option<PaymentSecret>, payment_id: PaymentId,
498-
route: &Route, entropy_source: &ES, best_block_height: u32
498+
route: &Route, retry_strategy: Retry, route_params: Option<RouteParameters>,
499+
entropy_source: &ES, best_block_height: u32
499500
) -> Result<Vec<[u8; 32]>, PaymentSendFailure> where ES::Target: EntropySource {
500501
let mut onion_session_privs = Vec::with_capacity(route.paths.len());
501502
for _ in 0..route.paths.len() {

0 commit comments

Comments
 (0)