Struct Bolt11Payment

Source
pub struct Bolt11Payment { /* private fields */ }
Expand description

A payment handler allowing to create and pay BOLT 11 invoices.

Should be retrieved by calling Node::bolt11_payment.

Implementations§

Source§

impl Bolt11Payment

Source

pub fn send( &self, invoice: &Bolt11Invoice, sending_parameters: Option<SendingParameters>, ) -> Result<PaymentId, Error>

Send a payment given an invoice.

If sending_parameters are provided they will override the default as well as the node-wide parameters configured via Config::sending_parameters on a per-field basis.

Source

pub fn send_using_amount( &self, invoice: &Bolt11Invoice, amount_msat: u64, sending_parameters: Option<SendingParameters>, ) -> Result<PaymentId, Error>

Send a payment given an invoice and an amount in millisatoshis.

This will fail if the amount given is less than the value required by the given invoice.

This can be used to pay a so-called “zero-amount” invoice, i.e., an invoice that leaves the amount paid to be determined by the user.

If sending_parameters are provided they will override the default as well as the node-wide parameters configured via Config::sending_parameters on a per-field basis.

Source

pub fn claim_for_hash( &self, payment_hash: PaymentHash, claimable_amount_msat: u64, preimage: PaymentPreimage, ) -> Result<(), Error>

Allows to attempt manually claiming payments with the given preimage that have previously been registered via receive_for_hash or receive_variable_amount_for_hash.

This should be called in reponse to a PaymentClaimable event as soon as the preimage is available.

Will check that the payment is known, and that the given preimage and claimable amount match our expectations before attempting to claim the payment, and will return an error otherwise.

When claiming the payment has succeeded, a PaymentReceived event will be emitted.

Source

pub fn fail_for_hash(&self, payment_hash: PaymentHash) -> Result<(), Error>

Allows to manually fail payments with the given hash that have previously been registered via receive_for_hash or receive_variable_amount_for_hash.

This should be called in reponse to a PaymentClaimable event if the payment needs to be failed back, e.g., if the correct preimage can’t be retrieved in time before the claim deadline has been reached.

Will check that the payment is known before failing the payment, and will return an error otherwise.

Source

pub fn receive( &self, amount_msat: u64, description: &Bolt11InvoiceDescription, expiry_secs: u32, ) -> Result<Bolt11Invoice, Error>

Returns a payable invoice that can be used to request and receive a payment of the amount given.

The inbound payment will be automatically claimed upon arrival.

Source

pub fn receive_for_hash( &self, amount_msat: u64, description: &Bolt11InvoiceDescription, expiry_secs: u32, payment_hash: PaymentHash, ) -> Result<Bolt11Invoice, Error>

Returns a payable invoice that can be used to request a payment of the amount given for the given payment hash.

We will register the given payment hash and emit a PaymentClaimable event once the inbound payment arrives.

Note: users MUST handle this event and claim the payment manually via claim_for_hash as soon as they have obtained access to the preimage of the given payment hash. If they’re unable to obtain the preimage, they MUST immediately fail the payment via fail_for_hash.

Source

pub fn receive_variable_amount( &self, description: &Bolt11InvoiceDescription, expiry_secs: u32, ) -> Result<Bolt11Invoice, Error>

Returns a payable invoice that can be used to request and receive a payment for which the amount is to be determined by the user, also known as a “zero-amount” invoice.

The inbound payment will be automatically claimed upon arrival.

Source

pub fn receive_variable_amount_for_hash( &self, description: &Bolt11InvoiceDescription, expiry_secs: u32, payment_hash: PaymentHash, ) -> Result<Bolt11Invoice, Error>

Returns a payable invoice that can be used to request a payment for the given payment hash and the amount to be determined by the user, also known as a “zero-amount” invoice.

We will register the given payment hash and emit a PaymentClaimable event once the inbound payment arrives.

Note: users MUST handle this event and claim the payment manually via claim_for_hash as soon as they have obtained access to the preimage of the given payment hash. If they’re unable to obtain the preimage, they MUST immediately fail the payment via fail_for_hash.

Source

pub fn receive_via_jit_channel( &self, amount_msat: u64, description: &Bolt11InvoiceDescription, expiry_secs: u32, max_total_lsp_fee_limit_msat: Option<u64>, ) -> Result<Bolt11Invoice, Error>

Returns a payable invoice that can be used to request a payment of the amount given and receive it via a newly created just-in-time (JIT) channel.

When the returned invoice is paid, the configured LSPS2-compliant LSP will open a channel to us, supplying just-in-time inbound liquidity.

If set, max_total_lsp_fee_limit_msat will limit how much fee we allow the LSP to take for opening the channel to us. We’ll use its cheapest offer otherwise.

Source

pub fn receive_variable_amount_via_jit_channel( &self, description: &Bolt11InvoiceDescription, expiry_secs: u32, max_proportional_lsp_fee_limit_ppm_msat: Option<u64>, ) -> Result<Bolt11Invoice, Error>

Returns a payable invoice that can be used to request a variable amount payment (also known as “zero-amount” invoice) and receive it via a newly created just-in-time (JIT) channel.

When the returned invoice is paid, the configured LSPS2-compliant LSP will open a channel to us, supplying just-in-time inbound liquidity.

If set, max_proportional_lsp_fee_limit_ppm_msat will limit how much proportional fee, in parts-per-million millisatoshis, we allow the LSP to take for opening the channel to us. We’ll use its cheapest offer otherwise.

Source

pub fn send_probes(&self, invoice: &Bolt11Invoice) -> Result<(), Error>

Sends payment probes over all paths of a route that would be used to pay the given invoice.

This may be used to send “pre-flight” probes, i.e., to train our scorer before conducting the actual payment. Note this is only useful if there likely is sufficient time for the probe to settle before sending out the actual payment, e.g., when waiting for user confirmation in a wallet UI.

Otherwise, there is a chance the probe could take up some liquidity needed to complete the actual payment. Users should therefore be cautious and might avoid sending probes if liquidity is scarce and/or they don’t expect the probe to return before they send the payment. To mitigate this issue, channels with available liquidity less than the required amount times Config::probing_liquidity_limit_multiplier won’t be used to send pre-flight probes.

Source

pub fn send_probes_using_amount( &self, invoice: &Bolt11Invoice, amount_msat: u64, ) -> Result<(), Error>

Sends payment probes over all paths of a route that would be used to pay the given zero-value invoice using the given amount.

This can be used to send pre-flight probes for a so-called “zero-amount” invoice, i.e., an invoice that leaves the amount paid to be determined by the user.

See Self::send_probes for more information.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,