Struct lightning::offers::offer::OfferBuilder

source ·
pub struct OfferBuilder<'a, M: MetadataStrategy, T: Signing> { /* private fields */ }
Expand description

Builds an Offer for the “offer to be paid” flow.

See module-level documentation for usage.

This is not exported to bindings users as builder patterns don’t map outside of move semantics.

Implementations§

source§

impl<'a, M: MetadataStrategy, T: Signing> OfferBuilder<'a, M, T>

source

pub fn chain(self, network: Network) -> Self

Adds the chain hash of the given Network to Offer::chains. If not called, the chain hash of Network::Bitcoin is assumed to be the only one supported.

See Offer::chains on how this relates to the payment currency.

Successive calls to this method will add another chain hash.

source

pub fn amount_msats(self, amount_msats: u64) -> Self

Sets the Offer::amount as an Amount::Bitcoin.

Successive calls to this method will override the previous setting.

source

pub fn absolute_expiry(self, absolute_expiry: Duration) -> Self

Sets the Offer::absolute_expiry as seconds since the Unix epoch. Any expiry that has already passed is valid and can be checked for using Offer::is_expired.

Successive calls to this method will override the previous setting.

source

pub fn description(self, description: String) -> Self

Sets the Offer::description.

Successive calls to this method will override the previous setting.

source

pub fn issuer(self, issuer: String) -> Self

Sets the Offer::issuer.

Successive calls to this method will override the previous setting.

source

pub fn path(self, path: BlindedPath) -> Self

Adds a blinded path to Offer::paths. Must include at least one path if only connected by private channels or if Offer::signing_pubkey is not a public node id.

Successive calls to this method will add another blinded path. Caller is responsible for not adding duplicate paths.

source

pub fn supported_quantity(self, quantity: Quantity) -> Self

Sets the quantity of items for Offer::supported_quantity. If not called, defaults to Quantity::One.

Successive calls to this method will override the previous setting.

source

pub fn build(self) -> Result<Offer, Bolt12SemanticError>

Builds an Offer from the builder’s settings.

source§

impl<'a> OfferBuilder<'a, ExplicitMetadata, SignOnly>

source

pub fn new(signing_pubkey: PublicKey) -> Self

Creates a new builder for an offer using the Offer::signing_pubkey for signing invoices. The associated secret key must be remembered while the offer is valid.

Use a different pubkey per offer to avoid correlating offers.

§Note

If constructing an Offer for use with a ChannelManager, use ChannelManager::create_offer_builder instead of OfferBuilder::new.

source

pub fn metadata(self, metadata: Vec<u8>) -> Result<Self, Bolt12SemanticError>

Sets the Offer::metadata to the given bytes.

Successive calls to this method will override the previous setting.

source§

impl<'a, T: Signing> OfferBuilder<'a, DerivedMetadata, T>

source

pub fn deriving_signing_pubkey<ES: Deref>( node_id: PublicKey, expanded_key: &ExpandedKey, entropy_source: ES, secp_ctx: &'a Secp256k1<T> ) -> Self
where ES::Target: EntropySource,

Similar to OfferBuilder::new except, if OfferBuilder::path is called, the signing pubkey is derived from the given ExpandedKey and EntropySource. This provides recipient privacy by using a different signing pubkey for each offer. Otherwise, the provided node_id is used for the signing pubkey.

Also, sets the metadata when OfferBuilder::build is called such that it can be used by InvoiceRequest::verify to determine if the request was produced for the offer given an ExpandedKey.

Auto Trait Implementations§

§

impl<'a, M, T> Freeze for OfferBuilder<'a, M, T>

§

impl<'a, M, T> RefUnwindSafe for OfferBuilder<'a, M, T>

§

impl<'a, M, T> Send for OfferBuilder<'a, M, T>
where M: Send,

§

impl<'a, M, T> Sync for OfferBuilder<'a, M, T>
where M: Sync,

§

impl<'a, M, T> Unpin for OfferBuilder<'a, M, T>
where M: Unpin,

§

impl<'a, M, T> UnwindSafe for OfferBuilder<'a, M, T>

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, 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, U> TryFrom<U> for T
where 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 T
where 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.