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>
impl<'a, M: MetadataStrategy, T: Signing> OfferBuilder<'a, M, T>
sourcepub fn chain(self, network: Network) -> Self
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.
sourcepub fn amount_msats(self, amount_msats: u64) -> Self
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.
sourcepub fn absolute_expiry(self, absolute_expiry: Duration) -> Self
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.
sourcepub fn description(self, description: String) -> Self
pub fn description(self, description: String) -> Self
Sets the Offer::description
.
Successive calls to this method will override the previous setting.
sourcepub fn issuer(self, issuer: String) -> Self
pub fn issuer(self, issuer: String) -> Self
Sets the Offer::issuer
.
Successive calls to this method will override the previous setting.
sourcepub fn path(self, path: BlindedPath) -> Self
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.
sourcepub fn supported_quantity(self, quantity: Quantity) -> Self
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§impl<'a> OfferBuilder<'a, ExplicitMetadata, SignOnly>
impl<'a> OfferBuilder<'a, ExplicitMetadata, SignOnly>
sourcepub fn new(signing_pubkey: PublicKey) -> Self
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
.
sourcepub fn metadata(self, metadata: Vec<u8>) -> Result<Self, Bolt12SemanticError>
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>
impl<'a, T: Signing> OfferBuilder<'a, DerivedMetadata, T>
sourcepub fn deriving_signing_pubkey<ES: Deref>(
node_id: PublicKey,
expanded_key: &ExpandedKey,
entropy_source: ES,
secp_ctx: &'a Secp256k1<T>
) -> Selfwhere
ES::Target: EntropySource,
pub fn deriving_signing_pubkey<ES: Deref>(
node_id: PublicKey,
expanded_key: &ExpandedKey,
entropy_source: ES,
secp_ctx: &'a Secp256k1<T>
) -> Selfwhere
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
.