Struct lightning_invoice::payment::InvoicePayer
source · [−]pub struct InvoicePayer<P: Deref, R, S: Deref, L: Deref, E: EventHandler> where
P::Target: Payer,
R: for<'a> Router<<<S as Deref>::Target as LockableScore<'a>>::Locked>,
S::Target: for<'a> LockableScore<'a>,
L::Target: Logger, { /* private fields */ }
Expand description
A utility for paying Invoice
s and sending spontaneous payments.
See module-level documentation for details.
Implementations
sourceimpl<P: Deref, R, S: Deref, L: Deref, E: EventHandler> InvoicePayer<P, R, S, L, E> where
P::Target: Payer,
R: for<'a> Router<<<S as Deref>::Target as LockableScore<'a>>::Locked>,
S::Target: for<'a> LockableScore<'a>,
L::Target: Logger,
impl<P: Deref, R, S: Deref, L: Deref, E: EventHandler> InvoicePayer<P, R, S, L, E> where
P::Target: Payer,
R: for<'a> Router<<<S as Deref>::Target as LockableScore<'a>>::Locked>,
S::Target: for<'a> LockableScore<'a>,
L::Target: Logger,
sourcepub fn new(
payer: P,
router: R,
scorer: S,
logger: L,
event_handler: E,
retry_attempts: RetryAttempts
) -> Self
pub fn new(
payer: P,
router: R,
scorer: S,
logger: L,
event_handler: E,
retry_attempts: RetryAttempts
) -> Self
Creates an invoice payer that retries failed payment paths.
Will forward any Event::PaymentPathFailed
events to the decorated event_handler
once
retry_attempts
has been exceeded for a given Invoice
.
sourcepub fn pay_invoice(&self, invoice: &Invoice) -> Result<PaymentId, PaymentError>
pub fn pay_invoice(&self, invoice: &Invoice) -> Result<PaymentId, PaymentError>
Pays the given Invoice
, caching it for later use in case a retry is needed.
You should ensure that the invoice.payment_hash()
is unique and the same payment_hash has
never been paid before. Because InvoicePayer
is stateless no effort is made to do so
for you.
sourcepub fn pay_zero_value_invoice(
&self,
invoice: &Invoice,
amount_msats: u64
) -> Result<PaymentId, PaymentError>
pub fn pay_zero_value_invoice(
&self,
invoice: &Invoice,
amount_msats: u64
) -> Result<PaymentId, PaymentError>
Pays the given zero-value Invoice
using the given amount, caching it for later use in
case a retry is needed.
You should ensure that the invoice.payment_hash()
is unique and the same payment_hash has
never been paid before. Because InvoicePayer
is stateless no effort is made to do so
for you.
sourcepub fn pay_pubkey(
&self,
pubkey: PublicKey,
payment_preimage: PaymentPreimage,
amount_msats: u64,
final_cltv_expiry_delta: u32
) -> Result<PaymentId, PaymentError>
pub fn pay_pubkey(
&self,
pubkey: PublicKey,
payment_preimage: PaymentPreimage,
amount_msats: u64,
final_cltv_expiry_delta: u32
) -> Result<PaymentId, PaymentError>
Pays pubkey
an amount using the hash of the given preimage, caching it for later use in
case a retry is needed.
You should ensure that payment_preimage
is unique and that its payment_hash
has never
been paid before. Because InvoicePayer
is stateless no effort is made to do so for you.
sourcepub fn remove_cached_payment(&self, payment_hash: &PaymentHash)
pub fn remove_cached_payment(&self, payment_hash: &PaymentHash)
Removes the payment cached by the given payment hash.
Should be called once a payment has failed or succeeded if not using InvoicePayer
as an
EventHandler
. Otherwise, calling this method is unnecessary.
Trait Implementations
sourceimpl<P: Deref, R, S: Deref, L: Deref, E: EventHandler> EventHandler for InvoicePayer<P, R, S, L, E> where
P::Target: Payer,
R: for<'a> Router<<<S as Deref>::Target as LockableScore<'a>>::Locked>,
S::Target: for<'a> LockableScore<'a>,
L::Target: Logger,
impl<P: Deref, R, S: Deref, L: Deref, E: EventHandler> EventHandler for InvoicePayer<P, R, S, L, E> where
P::Target: Payer,
R: for<'a> Router<<<S as Deref>::Target as LockableScore<'a>>::Locked>,
S::Target: for<'a> LockableScore<'a>,
L::Target: Logger,
sourcefn handle_event(&self, event: &Event)
fn handle_event(&self, event: &Event)
Auto Trait Implementations
impl<P, R, S, L, E> RefUnwindSafe for InvoicePayer<P, R, S, L, E> where
E: RefUnwindSafe,
L: RefUnwindSafe,
P: RefUnwindSafe,
R: RefUnwindSafe,
S: RefUnwindSafe,
impl<P, R, S, L, E> Send for InvoicePayer<P, R, S, L, E> where
E: Send,
L: Send,
P: Send,
R: Send,
S: Send,
impl<P, R, S, L, E> Sync for InvoicePayer<P, R, S, L, E> where
E: Sync,
L: Sync,
P: Sync,
R: Sync,
S: Sync,
impl<P, R, S, L, E> Unpin for InvoicePayer<P, R, S, L, E> where
E: Unpin,
L: Unpin,
P: Unpin,
R: Unpin,
S: Unpin,
impl<P, R, S, L, E> UnwindSafe for InvoicePayer<P, R, S, L, E> where
E: UnwindSafe,
L: UnwindSafe,
P: UnwindSafe,
R: UnwindSafe,
S: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more