use crate::ln::msgs::{ChannelMessageHandler, DecodeError, LightningError, MAX_VALUE_MSAT};
#[cfg(test)]
use crate::ln::outbound_payment;
-use crate::ln::outbound_payment::{OutboundPayments, PendingOutboundPayment, Retry};
+use crate::ln::outbound_payment::{OutboundPayments, PaymentAttempts, PendingOutboundPayment, Retry};
use crate::ln::wire::Encode;
use crate::chain::keysinterface::{EntropySource, KeysManager, NodeSigner, Recipient, Sign, SignerProvider};
use crate::util::config::{UserConfig, ChannelConfig};
hash_map::Entry::Vacant(entry) => {
let path_fee = path.get_path_fees();
entry.insert(PendingOutboundPayment::Retryable {
+ retry_strategy: Retry::Attempts(0),
+ attempts: PaymentAttempts::new(),
+ route_params: None,
session_privs: [session_priv_bytes].iter().map(|a| *a).collect(),
payment_hash: htlc.payment_hash,
payment_secret,
session_privs: HashSet<[u8; 32]>,
},
Retryable {
+ retry_strategy: Retry,
+ attempts: PaymentAttempts,
+ route_params: Option<RouteParameters>,
session_privs: HashSet<[u8; 32]>,
payment_hash: PaymentHash,
payment_secret: Option<PaymentSecret>,
}
impl PendingOutboundPayment {
+ fn increment_attempts(&mut self) {
+ if let PendingOutboundPayment::Retryable { attempts, .. } = self {
+ attempts.count += 1;
+ }
+ }
+ fn is_retryable_now(&self) -> bool {
+ if let PendingOutboundPayment::Retryable { retry_strategy, attempts, .. } = self {
+ return retry_strategy.is_retryable_now(&attempts)
+ }
+ false
+ }
pub(super) fn is_fulfilled(&self) -> bool {
match self {
PendingOutboundPayment::Fulfilled { .. } => true,
hash_map::Entry::Occupied(_) => Err(PaymentSendFailure::DuplicatePayment),
hash_map::Entry::Vacant(entry) => {
let payment = entry.insert(PendingOutboundPayment::Retryable {
+ retry_strategy,
+ attempts: PaymentAttempts::new(),
+ route_params,
session_privs: HashSet::new(),
pending_amt_msat: 0,
pending_fee_msat: Some(0),
(0, session_privs, required),
(1, pending_fee_msat, option),
(2, payment_hash, required),
+ (not_written, retry_strategy, (static_value, Retry::Attempts(0))),
(4, payment_secret, option),
+ (not_written, attempts, (static_value, PaymentAttempts::new())),
(6, total_msat, required),
+ (not_written, route_params, (static_value, None)),
(8, pending_amt_msat, required),
(10, starting_block_height, required),
},