Trait lightning_invoice::payment::Payer
source · pub trait Payer {
fn node_id(&self) -> PublicKey;
fn first_hops(&self) -> Vec<ChannelDetails> ⓘ;
fn send_payment(
&self,
route: &Route,
payment_hash: PaymentHash,
payment_secret: &Option<PaymentSecret>,
payment_id: PaymentId
) -> Result<(), PaymentSendFailure>;
fn send_spontaneous_payment(
&self,
route: &Route,
payment_preimage: PaymentPreimage,
payment_id: PaymentId
) -> Result<(), PaymentSendFailure>;
fn retry_payment(
&self,
route: &Route,
payment_id: PaymentId
) -> Result<(), PaymentSendFailure>;
fn abandon_payment(&self, payment_id: PaymentId);
fn inflight_htlcs(&self) -> InFlightHtlcs;
}
Expand description
A trait defining behavior of an Invoice
payer.
While the behavior of InvoicePayer
provides idempotency of duplicate send_*payment
calls
with the same PaymentHash
, it is up to the Payer
to provide idempotency across restarts.
ChannelManager
provides idempotency for duplicate payments with the same PaymentId
.
In order to trivially ensure idempotency for payments, the default Payer
implementation
reuses the PaymentHash
bytes as the PaymentId
. Custom implementations wishing to
provide payment idempotency with a different idempotency key (i.e. PaymentId
) should map
the Invoice
or spontaneous payment target pubkey to their own idempotency key.
Required Methods§
sourcefn first_hops(&self) -> Vec<ChannelDetails> ⓘ
fn first_hops(&self) -> Vec<ChannelDetails> ⓘ
Returns the payer’s channels.
sourcefn send_payment(
&self,
route: &Route,
payment_hash: PaymentHash,
payment_secret: &Option<PaymentSecret>,
payment_id: PaymentId
) -> Result<(), PaymentSendFailure>
fn send_payment(
&self,
route: &Route,
payment_hash: PaymentHash,
payment_secret: &Option<PaymentSecret>,
payment_id: PaymentId
) -> Result<(), PaymentSendFailure>
Sends a payment over the Lightning Network using the given Route
.
sourcefn send_spontaneous_payment(
&self,
route: &Route,
payment_preimage: PaymentPreimage,
payment_id: PaymentId
) -> Result<(), PaymentSendFailure>
fn send_spontaneous_payment(
&self,
route: &Route,
payment_preimage: PaymentPreimage,
payment_id: PaymentId
) -> Result<(), PaymentSendFailure>
Sends a spontaneous payment over the Lightning Network using the given Route
.
sourcefn retry_payment(
&self,
route: &Route,
payment_id: PaymentId
) -> Result<(), PaymentSendFailure>
fn retry_payment(
&self,
route: &Route,
payment_id: PaymentId
) -> Result<(), PaymentSendFailure>
sourcefn abandon_payment(&self, payment_id: PaymentId)
fn abandon_payment(&self, payment_id: PaymentId)
Signals that no further retries for the given payment will occur.
sourcefn inflight_htlcs(&self) -> InFlightHtlcs
fn inflight_htlcs(&self) -> InFlightHtlcs
Construct an InFlightHtlcs
containing information about currently used up liquidity
across payments.