Struct lightning::offers::refund::Refund

source ·
pub struct Refund { /* private fields */ }
Expand description

A Refund is a request to send an Invoice without a preceding Offer.

Typically, after an invoice is paid, the recipient may publish a refund allowing the sender to recoup their funds. A refund may be used more generally as an “offer for money”, such as with a bitcoin ATM.

Implementations§

source§

impl Refund

source

pub fn description(&self) -> PrintableString<'_>

A complete description of the purpose of the refund. Intended to be displayed to the user but with the caveat that it has not been verified in any way.

source

pub fn absolute_expiry(&self) -> Option<Duration>

Duration since the Unix epoch when an invoice should no longer be sent.

If None, the refund does not expire.

source

pub fn is_expired(&self) -> bool

Available on crate feature std only.

Whether the refund has expired.

source

pub fn issuer(&self) -> Option<PrintableString<'_>>

The issuer of the refund, possibly beginning with user@domain or domain. Intended to be displayed to the user but with the caveat that it has not been verified in any way.

source

pub fn paths(&self) -> &[BlindedPath]

Paths to the sender originating from publicly reachable nodes. Blinded paths provide sender privacy by obfuscating its node id.

source

pub fn metadata(&self) -> &[u8]

An unpredictable series of bytes, typically containing information about the derivation of payer_id.

source

pub fn chain(&self) -> ChainHash

A chain that the refund is valid for.

source

pub fn amount_msats(&self) -> u64

The amount to refund in msats (i.e., the minimum lightning-payable unit for chain).

source

pub fn features(&self) -> &InvoiceRequestFeatures

Features pertaining to requesting an invoice.

source

pub fn quantity(&self) -> Option<u64>

The quantity of an item that refund is for.

source

pub fn payer_id(&self) -> PublicKey

A public node id to send to in the case where there are no paths. Otherwise, a possibly transient pubkey.

source

pub fn payer_note(&self) -> Option<PrintableString<'_>>

Payer provided note to include in the invoice.

source

pub fn respond_with( &self, payment_paths: Vec<(BlindedPath, BlindedPayInfo)>, payment_hash: PaymentHash, signing_pubkey: PublicKey ) -> Result<InvoiceBuilder<'_, ExplicitSigningPubkey>, SemanticError>

Available on crate feature std only.

Creates an InvoiceBuilder for the refund with the given required fields and using the Duration since std::time::SystemTime::UNIX_EPOCH as the creation time.

See Refund::respond_with_no_std for further details where the aforementioned creation time is used for the created_at parameter.

source

pub fn respond_with_no_std( &self, payment_paths: Vec<(BlindedPath, BlindedPayInfo)>, payment_hash: PaymentHash, signing_pubkey: PublicKey, created_at: Duration ) -> Result<InvoiceBuilder<'_, ExplicitSigningPubkey>, SemanticError>

Creates an InvoiceBuilder for the refund with the given required fields.

Unless InvoiceBuilder::relative_expiry is set, the invoice will expire two hours after created_at, which is used to set Invoice::created_at. Useful for no-std builds where std::time::SystemTime is not available.

The caller is expected to remember the preimage of payment_hash in order to claim a payment for the invoice.

The signing_pubkey is required to sign the invoice since refunds are not in response to an offer, which does have a signing_pubkey.

The payment_paths parameter is useful for maintaining the payment recipient’s privacy. It must contain one or more elements ordered from most-preferred to least-preferred, if there’s a preference. Note, however, that any privacy is lost if a public node id is used for signing_pubkey.

Errors if the request contains unknown required features.

source

pub fn respond_using_derived_keys<ES: Deref>( &self, payment_paths: Vec<(BlindedPath, BlindedPayInfo)>, payment_hash: PaymentHash, expanded_key: &ExpandedKey, entropy_source: ES ) -> Result<InvoiceBuilder<'_, DerivedSigningPubkey>, SemanticError>where ES::Target: EntropySource,

Available on crate feature std only.

Creates an InvoiceBuilder for the refund using the given required fields and that uses derived signing keys to sign the Invoice.

See Refund::respond_with for further details.

source

pub fn respond_using_derived_keys_no_std<ES: Deref>( &self, payment_paths: Vec<(BlindedPath, BlindedPayInfo)>, payment_hash: PaymentHash, created_at: Duration, expanded_key: &ExpandedKey, entropy_source: ES ) -> Result<InvoiceBuilder<'_, DerivedSigningPubkey>, SemanticError>where ES::Target: EntropySource,

Creates an InvoiceBuilder for the refund using the given required fields and that uses derived signing keys to sign the Invoice.

See Refund::respond_with_no_std for further details.

Trait Implementations§

source§

impl AsRef<[u8]> for Refund

source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Clone for Refund

source§

fn clone(&self) -> Refund

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Refund

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for Refund

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl FromStr for Refund

§

type Err = ParseError

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, <Self as FromStr>::Err>

Parses a string s to return a value of this type. Read more
source§

impl TryFrom<Vec<u8, Global>> for Refund

§

type Error = ParseError

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

fn try_from(bytes: Vec<u8>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Writeable for Refund

source§

fn write<W: Writer>(&self, writer: &mut W) -> Result<(), Error>

Writes self out to the given Writer.
source§

fn encode(&self) -> Vec<u8>

Writes self out to a Vec<u8>.
source§

fn serialized_length(&self) -> usize

Gets the length of this object after it has been serialized. This can be overridden to optimize cases where we prepend an object with its length.

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Base32Len for Twhere T: AsRef<[u8]>,

§

fn base32_len(&self) -> usize

Calculate the base32 serialized length
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
§

impl<T> CheckBase32<Vec<u5, Global>> for Twhere T: AsRef<[u8]>,

§

type Err = Error

Error type if conversion fails
§

fn check_base32( self ) -> Result<Vec<u5, Global>, <T as CheckBase32<Vec<u5, Global>>>::Err>

Check if all values are in range and return array-like struct of u5 values
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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.

§

impl<T> ToBase32 for Twhere T: AsRef<[u8]>,

§

fn write_base32<W>(&self, writer: &mut W) -> Result<(), <W as WriteBase32>::Err>where W: WriteBase32,

Encode as base32 and write it to the supplied writer Implementations shouldn’t allocate.
§

fn to_base32(&self) -> Vec<u5, Global>

Convert Self to base32 vector
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.