/// These include payments that have yet to find a successful path, or have unresolved HTLCs.
#[derive(Debug, PartialEq)]
pub enum RecentPaymentDetails {
- /// When an invoice was requested but not yet received, and thus a payment has not been sent.
+ /// When an invoice was requested and thus a payment has not yet been sent.
AwaitingInvoice {
/// Identifier for the payment to ensure idempotency.
payment_id: PaymentId,
PendingOutboundPayment::AwaitingInvoice { .. } => {
Some(RecentPaymentDetails::AwaitingInvoice { payment_id: *payment_id })
},
+ // InvoiceReceived is an intermediate state and doesn't need to be exposed
+ PendingOutboundPayment::InvoiceReceived { .. } => {
+ Some(RecentPaymentDetails::AwaitingInvoice { payment_id: *payment_id })
+ },
PendingOutboundPayment::Retryable { payment_hash, total_msat, .. } => {
Some(RecentPaymentDetails::Pending {
payment_hash: *payment_hash,
}
}
PendingOutboundPayment::AwaitingInvoice { .. } => {},
+ PendingOutboundPayment::InvoiceReceived { .. } => {},
PendingOutboundPayment::Fulfilled { .. } => {},
PendingOutboundPayment::Abandoned { .. } => {},
}
AwaitingInvoice {
timer_ticks_without_response: u8,
},
+ InvoiceReceived {
+ payment_hash: PaymentHash,
+ },
Retryable {
retry_strategy: Option<Retry>,
attempts: PaymentAttempts,
match self {
PendingOutboundPayment::Legacy { .. } => None,
PendingOutboundPayment::AwaitingInvoice { .. } => None,
+ PendingOutboundPayment::InvoiceReceived { payment_hash } => Some(*payment_hash),
PendingOutboundPayment::Retryable { payment_hash, .. } => Some(*payment_hash),
PendingOutboundPayment::Fulfilled { payment_hash, .. } => *payment_hash,
PendingOutboundPayment::Abandoned { payment_hash, .. } => Some(*payment_hash),
PendingOutboundPayment::Retryable { session_privs, .. } |
PendingOutboundPayment::Fulfilled { session_privs, .. } |
PendingOutboundPayment::Abandoned { session_privs, .. } => session_privs,
- PendingOutboundPayment::AwaitingInvoice { .. } => {
- debug_assert!(false);
- return;
- },
+ PendingOutboundPayment::AwaitingInvoice { .. } |
+ PendingOutboundPayment::InvoiceReceived { .. } => { debug_assert!(false); return; },
});
let payment_hash = self.payment_hash();
*self = PendingOutboundPayment::Fulfilled { session_privs, payment_hash, timer_ticks_without_htlcs: 0 };
payment_hash: *payment_hash,
reason: Some(reason)
};
+ } else if let PendingOutboundPayment::InvoiceReceived { payment_hash } = self {
+ *self = PendingOutboundPayment::Abandoned {
+ session_privs: HashSet::new(),
+ payment_hash: *payment_hash,
+ reason: Some(reason)
+ };
}
}
PendingOutboundPayment::Abandoned { session_privs, .. } => {
session_privs.remove(session_priv)
},
- PendingOutboundPayment::AwaitingInvoice { .. } => {
- debug_assert!(false);
- false
- },
+ PendingOutboundPayment::AwaitingInvoice { .. } |
+ PendingOutboundPayment::InvoiceReceived { .. } => { debug_assert!(false); false },
};
if remove_res {
if let PendingOutboundPayment::Retryable { ref mut pending_amt_msat, ref mut pending_fee_msat, .. } = self {
PendingOutboundPayment::Legacy { session_privs } |
PendingOutboundPayment::Retryable { session_privs, .. } => {
session_privs.insert(session_priv)
- }
- PendingOutboundPayment::AwaitingInvoice { .. } => {
- debug_assert!(false);
- false
- },
+ },
+ PendingOutboundPayment::AwaitingInvoice { .. } |
+ PendingOutboundPayment::InvoiceReceived { .. } => { debug_assert!(false); false },
PendingOutboundPayment::Fulfilled { .. } => false,
PendingOutboundPayment::Abandoned { .. } => false,
};
session_privs.len()
},
PendingOutboundPayment::AwaitingInvoice { .. } => 0,
+ PendingOutboundPayment::InvoiceReceived { .. } => 0,
}
}
}
log_error!(logger, "Unable to retry payments that were initially sent on LDK versions prior to 0.0.102");
return
},
- PendingOutboundPayment::AwaitingInvoice { .. } => {
+ PendingOutboundPayment::AwaitingInvoice { .. } |
+ PendingOutboundPayment::InvoiceReceived { .. } =>
+ {
log_error!(logger, "Payment not yet sent");
return
},
(5, AwaitingInvoice) => {
(0, timer_ticks_without_response, required),
},
+ (7, InvoiceReceived) => {
+ (0, payment_hash, required),
+ },
);
#[cfg(test)]