pub struct RefundBuilder<'a, T: Signing> { /* private fields */ }
Expand description
Builds a Refund
for the “offer for money” 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> RefundBuilder<'a, SignOnly>
impl<'a> RefundBuilder<'a, SignOnly>
Sourcepub fn new(
metadata: Vec<u8>,
signing_pubkey: PublicKey,
amount_msats: u64,
) -> Result<Self, Bolt12SemanticError>
pub fn new( metadata: Vec<u8>, signing_pubkey: PublicKey, amount_msats: u64, ) -> Result<Self, Bolt12SemanticError>
Creates a new builder for a refund using the signing_pubkey
for the public node id to send
to if no Refund::paths
are set. Otherwise, signing_pubkey
may be a transient pubkey.
Additionally, sets the required (empty) Refund::description
, Refund::payer_metadata
,
and Refund::amount_msats
.
§Note
If constructing a Refund
for use with a ChannelManager
, use
ChannelManager::create_refund_builder
instead of RefundBuilder::new
.
Source§impl<'a, T: Signing> RefundBuilder<'a, T>
impl<'a, T: Signing> RefundBuilder<'a, T>
Sourcepub fn deriving_signing_pubkey(
node_id: PublicKey,
expanded_key: &ExpandedKey,
nonce: Nonce,
secp_ctx: &'a Secp256k1<T>,
amount_msats: u64,
payment_id: PaymentId,
) -> Result<Self, Bolt12SemanticError>
pub fn deriving_signing_pubkey( node_id: PublicKey, expanded_key: &ExpandedKey, nonce: Nonce, secp_ctx: &'a Secp256k1<T>, amount_msats: u64, payment_id: PaymentId, ) -> Result<Self, Bolt12SemanticError>
Similar to RefundBuilder::new
except, if RefundBuilder::path
is called, the payer id
is derived from the given ExpandedKey
and nonce. This provides sender privacy by using a
different payer id for each refund, assuming a different nonce is used. Otherwise, the
provided node_id
is used for the payer id.
Also, sets the metadata when RefundBuilder::build
is called such that it can be used by
Bolt12Invoice::verify_using_metadata
to determine if the invoice was produced for the
refund given an ExpandedKey
. However, if RefundBuilder::path
is called, then the
metadata must be included in each BlindedMessagePath
instead. In this case, use
Bolt12Invoice::verify_using_payer_data
.
The payment_id
is encrypted in the metadata and should be unique. This ensures that only
one invoice will be paid for the refund and that payments can be uniquely identified.
Sourcepub fn description(self, description: String) -> Self
pub fn description(self, description: String) -> Self
Sets the Refund::description
.
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 Refund::absolute_expiry
as seconds since the Unix epoch.
Any expiry that has already passed is valid and can be checked for using Refund::is_expired
.
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 Refund::issuer
.
Successive calls to this method will override the previous setting.
Sourcepub fn path(self, path: BlindedMessagePath) -> Self
pub fn path(self, path: BlindedMessagePath) -> Self
Adds a blinded path to Refund::paths
. Must include at least one path if only connected
by private channels or if Refund::payer_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 chain(self, network: Network) -> Self
pub fn chain(self, network: Network) -> Self
Sets the Refund::chain
of the given Network
for paying an invoice. If not
called, Network::Bitcoin
is assumed.
Successive calls to this method will override the previous setting.
Sourcepub fn quantity(self, quantity: u64) -> Self
pub fn quantity(self, quantity: u64) -> Self
Sets Refund::quantity
of items. This is purely for informational purposes. It is useful
when the refund pertains to a Bolt12Invoice
that paid for more than one item from an
Offer
as specified by InvoiceRequest::quantity
.
Successive calls to this method will override the previous setting.
Sourcepub fn payer_note(self, payer_note: String) -> Self
pub fn payer_note(self, payer_note: String) -> Self
Sets the Refund::payer_note
.
Successive calls to this method will override the previous setting.