Skip to content

Commit 9d28bed

Browse files
Parameterize add_new_pending_payment with retry strategy
1 parent 5156b8f commit 9d28bed

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ use crate::ln::onion_utils::HTLCFailReason;
5555
use crate::ln::msgs::{ChannelMessageHandler, DecodeError, LightningError, MAX_VALUE_MSAT};
5656
#[cfg(test)]
5757
use crate::ln::outbound_payment;
58-
use crate::ln::outbound_payment::{OutboundPayments, PendingOutboundPayment};
58+
use crate::ln::outbound_payment::{OutboundPayments, PendingOutboundPayment, Retry};
5959
use crate::ln::wire::Encode;
6060
use crate::chain::keysinterface::{EntropySource, KeysInterface, KeysManager, NodeSigner, Recipient, Sign, SignerProvider};
6161
use crate::util::config::{UserConfig, ChannelConfig};
@@ -2406,7 +2406,7 @@ where
24062406
#[cfg(test)]
24072407
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> {
24082408
let best_block_height = self.best_block.read().unwrap().height();
2409-
self.pending_outbound_payments.test_add_new_pending_payment(payment_hash, payment_secret, payment_id, route, &self.keys_manager, best_block_height)
2409+
self.pending_outbound_payments.test_add_new_pending_payment(payment_hash, payment_secret, payment_id, route, Retry::Attempts(0),&self.keys_manager, best_block_height)
24102410
}
24112411

24122412

lightning/src/ln/outbound_payment.rs

Lines changed: 6 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, keys_manager, best_block_height)?;
362+
let onion_session_privs = self.add_new_pending_payment(payment_hash, *payment_secret, payment_id, route, Retry::Attempts(0), keys_manager, best_block_height)?;
363363
self.send_payment_internal(route, payment_hash, payment_secret, None, payment_id, None, onion_session_privs, keys_manager, best_block_height, send_payment_along_path)
364364
}
365365

@@ -377,7 +377,7 @@ impl OutboundPayments {
377377
None => PaymentPreimage(keys_manager.get_secure_random_bytes()),
378378
};
379379
let payment_hash = PaymentHash(Sha256::hash(&preimage.0).into_inner());
380-
let onion_session_privs = self.add_new_pending_payment(payment_hash, None, payment_id, &route, keys_manager, best_block_height)?;
380+
let onion_session_privs = self.add_new_pending_payment(payment_hash, None, payment_id, &route, Retry::Attempts(0), keys_manager, best_block_height)?;
381381

382382
match self.send_payment_internal(route, payment_hash, &None, Some(preimage), payment_id, None, onion_session_privs, keys_manager, best_block_height, send_payment_along_path) {
383383
Ok(()) => Ok(payment_hash),
@@ -474,7 +474,7 @@ impl OutboundPayments {
474474
}
475475

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

479479
match self.send_payment_internal(&route, payment_hash, &None, None, payment_id, None, onion_session_privs, keys_manager, best_block_height, send_payment_along_path) {
480480
Ok(()) => Ok((payment_hash, payment_id)),
@@ -485,14 +485,14 @@ impl OutboundPayments {
485485
#[cfg(test)]
486486
pub(super) fn test_add_new_pending_payment<K: Deref>(
487487
&self, payment_hash: PaymentHash, payment_secret: Option<PaymentSecret>, payment_id: PaymentId,
488-
route: &Route, keys_manager: &K, best_block_height: u32
488+
route: &Route, retry_strategy: Retry, keys_manager: &K, best_block_height: u32
489489
) -> Result<Vec<[u8; 32]>, PaymentSendFailure> where K::Target: KeysInterface {
490-
self.add_new_pending_payment(payment_hash, payment_secret, payment_id, route, keys_manager, best_block_height)
490+
self.add_new_pending_payment(payment_hash, payment_secret, payment_id, route, retry_strategy, keys_manager, best_block_height)
491491
}
492492

493493
fn add_new_pending_payment<K: Deref>(
494494
&self, payment_hash: PaymentHash, payment_secret: Option<PaymentSecret>, payment_id: PaymentId,
495-
route: &Route, keys_manager: &K, best_block_height: u32
495+
route: &Route, retry_strategy: Retry, keys_manager: &K, best_block_height: u32
496496
) -> Result<Vec<[u8; 32]>, PaymentSendFailure> where K::Target: KeysInterface {
497497
let mut onion_session_privs = Vec::with_capacity(route.paths.len());
498498
for _ in 0..route.paths.len() {

0 commit comments

Comments
 (0)