+macro_rules! invoice_request_respond_with_derived_signing_pubkey_methods { (
+ $self: ident, $contents: expr, $builder: ty
+) => {
+ /// Creates an [`InvoiceBuilder`] for the request using the given required fields and that uses
+ /// derived signing keys from the originating [`Offer`] to sign the [`Bolt12Invoice`]. Must use
+ /// the same [`ExpandedKey`] as the one used to create the offer.
+ ///
+ /// See [`InvoiceRequest::respond_with`] for further details.
+ ///
+ /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
+ #[cfg(feature = "std")]
+ pub fn respond_using_derived_keys(
+ &$self, payment_paths: Vec<(BlindedPayInfo, BlindedPath)>, payment_hash: PaymentHash
+ ) -> Result<$builder, Bolt12SemanticError> {
+ let created_at = std::time::SystemTime::now()
+ .duration_since(std::time::SystemTime::UNIX_EPOCH)
+ .expect("SystemTime::now() should come after SystemTime::UNIX_EPOCH");
+
+ $self.respond_using_derived_keys_no_std(payment_paths, payment_hash, created_at)
+ }
+
+ /// Creates an [`InvoiceBuilder`] for the request using the given required fields and that uses
+ /// derived signing keys from the originating [`Offer`] to sign the [`Bolt12Invoice`]. Must use
+ /// the same [`ExpandedKey`] as the one used to create the offer.
+ ///
+ /// See [`InvoiceRequest::respond_with_no_std`] for further details.
+ ///
+ /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
+ pub fn respond_using_derived_keys_no_std(
+ &$self, payment_paths: Vec<(BlindedPayInfo, BlindedPath)>, payment_hash: PaymentHash,
+ created_at: core::time::Duration
+ ) -> Result<$builder, Bolt12SemanticError> {
+ if $self.inner.invoice_request_features().requires_unknown_bits() {
+ return Err(Bolt12SemanticError::UnknownRequiredFeatures);
+ }
+
+ let keys = match $self.keys {
+ None => return Err(Bolt12SemanticError::InvalidMetadata),
+ Some(keys) => keys,
+ };
+
+ <$builder>::for_offer_using_keys(
+ &$self.inner, payment_paths, created_at, payment_hash, keys
+ )
+ }
+} }
+
+impl VerifiedInvoiceRequest {
+ offer_accessors!(self, self.inner.contents.inner.offer);
+ invoice_request_accessors!(self, self.inner.contents);
+ #[cfg(not(c_bindings))]
+ invoice_request_respond_with_explicit_signing_pubkey_methods!(self, self.inner, InvoiceBuilder<ExplicitSigningPubkey>);
+ #[cfg(c_bindings)]
+ invoice_request_respond_with_explicit_signing_pubkey_methods!(self, self.inner, InvoiceWithExplicitSigningPubkeyBuilder);
+ #[cfg(not(c_bindings))]
+ invoice_request_respond_with_derived_signing_pubkey_methods!(self, self.inner, InvoiceBuilder<DerivedSigningPubkey>);
+ #[cfg(c_bindings)]
+ invoice_request_respond_with_derived_signing_pubkey_methods!(self, self.inner, InvoiceWithDerivedSigningPubkeyBuilder);
+}
+