Skip to content

Commit f28f919

Browse files
committed
f - define build_with_id instead of offer_id
1 parent 88080d5 commit f28f919

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

lightning/src/offers/offer.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,9 @@ macro_rules! offer_explicit_metadata_builder_methods { (
229229
}
230230
} }
231231

232-
macro_rules! offer_derived_metadata_builder_methods { ($secp_context: ty) => {
232+
macro_rules! offer_derived_metadata_builder_methods { (
233+
$secp_context: ty, $self: ident, $self_type: ty
234+
) => {
233235
/// Similar to [`OfferBuilder::new`] except, if [`OfferBuilder::path`] is called, the signing
234236
/// pubkey is derived from the given [`ExpandedKey`] and [`EntropySource`]. This provides
235237
/// recipient privacy by using a different signing pubkey for each offer. Otherwise, the
@@ -259,9 +261,11 @@ macro_rules! offer_derived_metadata_builder_methods { ($secp_context: ty) => {
259261
}
260262
}
261263

262-
/// Returns an identifier for the [`Offer`] constructed by the builder.
263-
pub fn offer_id(&self) -> OfferId {
264-
self.metadata_strategy.0
264+
/// Builds an [`Offer`] from the builder's settings. Returns both the offer and its [`OfferId`].
265+
pub fn build_with_id($self: $self_type) -> Result<(OfferId, Offer), Bolt12SemanticError> {
266+
let offer_id = $self.metadata_strategy.0;
267+
let offer = $self.build()?;
268+
Ok((offer_id, offer))
265269
}
266270
} }
267271

@@ -443,7 +447,7 @@ impl<'a> OfferBuilder<'a, ExplicitMetadata, secp256k1::SignOnly> {
443447
}
444448

445449
impl<'a, T: secp256k1::Signing> OfferBuilder<'a, DerivedMetadata, T> {
446-
offer_derived_metadata_builder_methods!(T);
450+
offer_derived_metadata_builder_methods!(T, self, Self);
447451
}
448452

449453
#[cfg(all(c_bindings, not(test)))]
@@ -461,13 +465,13 @@ impl<'a> OfferWithExplicitMetadataBuilder<'a> {
461465

462466
#[cfg(all(c_bindings, not(test)))]
463467
impl<'a> OfferWithDerivedMetadataBuilder<'a> {
464-
offer_derived_metadata_builder_methods!(secp256k1::All);
468+
offer_derived_metadata_builder_methods!(secp256k1::All, self, &mut Self);
465469
offer_builder_methods!(self, &mut Self, (), ());
466470
}
467471

468472
#[cfg(all(c_bindings, test))]
469473
impl<'a> OfferWithDerivedMetadataBuilder<'a> {
470-
offer_derived_metadata_builder_methods!(secp256k1::All);
474+
offer_derived_metadata_builder_methods!(secp256k1::All, self, &mut Self);
471475
offer_builder_methods!(self, &mut Self, &mut Self, self);
472476
offer_builder_test_methods!(self, &mut Self, &mut Self, self);
473477
}

0 commit comments

Comments
 (0)