Skip to content

Commit 0c10e67

Browse files
Parameterize add_new_pending_payment with retry strategy
1 parent e853793 commit 0c10e67

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
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, KeysInterface, KeysManager, NodeSigner, Recipient, Sign, SignerProvider};
5959
use crate::util::config::{UserConfig, ChannelConfig};
@@ -2393,7 +2393,7 @@ where
23932393
#[cfg(test)]
23942394
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> {
23952395
let best_block_height = self.best_block.read().unwrap().height();
2396-
self.pending_outbound_payments.add_new_pending_payment(payment_hash, payment_secret, payment_id, route, &self.keys_manager, best_block_height)
2396+
self.pending_outbound_payments.add_new_pending_payment(payment_hash, payment_secret, payment_id, route, Retry::Attempts(0), &self.keys_manager, best_block_height)
23972397
}
23982398

23992399

lightning/src/ln/outbound_payment.rs

Lines changed: 4 additions & 4 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)),
@@ -484,7 +484,7 @@ impl OutboundPayments {
484484

485485
pub(super) fn add_new_pending_payment<K: Deref>(
486486
&self, payment_hash: PaymentHash, payment_secret: Option<PaymentSecret>, payment_id: PaymentId,
487-
route: &Route, keys_manager: &K, best_block_height: u32
487+
route: &Route, retry_strategy: Retry, keys_manager: &K, best_block_height: u32
488488
) -> Result<Vec<[u8; 32]>, PaymentSendFailure> where K::Target: KeysInterface {
489489
let mut onion_session_privs = Vec::with_capacity(route.paths.len());
490490
for _ in 0..route.paths.len() {

0 commit comments

Comments
 (0)