Struct breez_sdk_core::lightning::offers::offer::OfferBuilder
pub struct OfferBuilder<'a, M, T>where
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§
§impl<'a> OfferBuilder<'a, ExplicitMetadata, SignOnly>
impl<'a> OfferBuilder<'a, ExplicitMetadata, SignOnly>
pub fn new(
description: String,
signing_pubkey: PublicKey,
) -> OfferBuilder<'a, ExplicitMetadata, SignOnly>
pub fn new( description: String, signing_pubkey: PublicKey, ) -> OfferBuilder<'a, ExplicitMetadata, SignOnly>
Creates a new builder for an offer setting the Offer::description
and 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
.
pub fn metadata(
self,
metadata: Vec<u8>,
) -> Result<OfferBuilder<'a, ExplicitMetadata, SignOnly>, Bolt12SemanticError>
pub fn metadata( self, metadata: Vec<u8>, ) -> Result<OfferBuilder<'a, ExplicitMetadata, SignOnly>, Bolt12SemanticError>
Sets the Offer::metadata
to the given bytes.
Successive calls to this method will override the previous setting.
§impl<'a, T> OfferBuilder<'a, DerivedMetadata, T>where
T: Signing,
impl<'a, T> OfferBuilder<'a, DerivedMetadata, T>where
T: Signing,
pub fn deriving_signing_pubkey<ES>(
description: String,
node_id: PublicKey,
expanded_key: &ExpandedKey,
entropy_source: ES,
secp_ctx: &'a Secp256k1<T>,
) -> OfferBuilder<'a, DerivedMetadata, T>
pub fn deriving_signing_pubkey<ES>( description: String, node_id: PublicKey, expanded_key: &ExpandedKey, entropy_source: ES, secp_ctx: &'a Secp256k1<T>, ) -> OfferBuilder<'a, DerivedMetadata, T>
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
.
§impl<'a, M, T> OfferBuilder<'a, M, T>where
M: MetadataStrategy,
T: Signing,
impl<'a, M, T> OfferBuilder<'a, M, T>where
M: MetadataStrategy,
T: Signing,
pub fn chain(self, network: Network) -> OfferBuilder<'a, M, T>
pub fn chain(self, network: Network) -> OfferBuilder<'a, M, T>
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.
pub fn amount_msats(self, amount_msats: u64) -> OfferBuilder<'a, M, T>
pub fn amount_msats(self, amount_msats: u64) -> OfferBuilder<'a, M, T>
Sets the Offer::amount
as an Amount::Bitcoin
.
Successive calls to this method will override the previous setting.
pub fn absolute_expiry(
self,
absolute_expiry: Duration,
) -> OfferBuilder<'a, M, T>
pub fn absolute_expiry( self, absolute_expiry: Duration, ) -> OfferBuilder<'a, M, T>
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.
pub fn issuer(self, issuer: String) -> OfferBuilder<'a, M, T>
pub fn issuer(self, issuer: String) -> OfferBuilder<'a, M, T>
Sets the Offer::issuer
.
Successive calls to this method will override the previous setting.
pub fn path(self, path: BlindedPath) -> OfferBuilder<'a, M, T>
pub fn path(self, path: BlindedPath) -> OfferBuilder<'a, M, T>
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.
pub fn supported_quantity(self, quantity: Quantity) -> OfferBuilder<'a, M, T>
pub fn supported_quantity(self, quantity: Quantity) -> OfferBuilder<'a, M, T>
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.
pub fn build(self) -> Result<Offer, Bolt12SemanticError>
pub fn build(self) -> Result<Offer, Bolt12SemanticError>
Builds an Offer
from the builder’s settings.
Auto Trait Implementations§
impl<'a, M, T> Freeze for OfferBuilder<'a, M, T>
impl<'a, M, T> RefUnwindSafe for OfferBuilder<'a, M, T>where
M: RefUnwindSafe,
T: RefUnwindSafe,
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>where
M: UnwindSafe,
T: RefUnwindSafe,
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: AsAny + ?Sized,
impl<T> Downcast for Twhere
T: AsAny + ?Sized,
§fn downcast_ref<T>(&self) -> Option<&T>where
T: AsAny,
fn downcast_ref<T>(&self) -> Option<&T>where
T: AsAny,
Any
.§fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: AsAny,
fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: AsAny,
Any
.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request