-fn expiry_time_from_unix_epoch(invoice: &Invoice) -> Duration {
- invoice.signed_invoice.raw_invoice.data.timestamp.0 + invoice.expiry_time()
-}
-
-/// An error that may occur when making a payment.
-#[derive(Clone, Debug)]
-pub enum PaymentError {
- /// An error resulting from the provided [`Invoice`] or payment hash.
- Invoice(&'static str),
- /// An error occurring when sending a payment.
- Sending(RetryableSendFailure),
-}
-
-/// A trait defining behavior of an [`Invoice`] payer.
-///
-/// Useful for unit testing internal methods.
-trait Payer {
- /// Sends a payment over the Lightning Network using the given [`Route`].
- ///
- /// [`Route`]: lightning::routing::router::Route
- fn send_payment(
- &self, payment_hash: PaymentHash, recipient_onion: RecipientOnionFields,
- payment_id: PaymentId, route_params: RouteParameters, retry_strategy: Retry
- ) -> Result<(), PaymentError>;
-}
-
-impl<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F: Deref, R: Deref, L: Deref> Payer for ChannelManager<M, T, ES, NS, SP, F, R, L>
-where
- M::Target: chain::Watch<<SP::Target as SignerProvider>::Signer>,
- T::Target: BroadcasterInterface,
- ES::Target: EntropySource,
- NS::Target: NodeSigner,
- SP::Target: SignerProvider,
- F::Target: FeeEstimator,
- R::Target: Router,
- L::Target: Logger,
-{
- fn send_payment(
- &self, payment_hash: PaymentHash, recipient_onion: RecipientOnionFields,
- payment_id: PaymentId, route_params: RouteParameters, retry_strategy: Retry
- ) -> Result<(), PaymentError> {
- self.send_payment(payment_hash, recipient_onion, payment_id, route_params, retry_strategy)
- .map_err(PaymentError::Sending)
+ let mut payment_params = PaymentParameters::from_node_id(
+ invoice.recover_payee_pub_key(),
+ invoice.min_final_cltv_expiry_delta() as u32
+ )
+ .with_route_hints(invoice.route_hints()).unwrap();
+ if let Some(expiry) = invoice.expires_at() {
+ payment_params = payment_params.with_expiry_time(expiry.as_secs());
+ }
+ if let Some(features) = invoice.features() {
+ payment_params = payment_params.with_bolt11_features(features.clone()).unwrap();