4141//! let pubkey = PublicKey::from(keys);
4242//!
4343//! let expiration = SystemTime::now() + Duration::from_secs(24 * 60 * 60);
44- //! let offer = OfferBuilder::new("coffee, large".to_string(), pubkey)
44+ //! let offer = OfferBuilder::new("coffee, large".to_string(), pubkey.into() )
4545//! .amount_msats(20_000)
4646//! .supported_quantity(Quantity::Unbounded)
4747//! .absolute_expiry(expiration.duration_since(SystemTime::UNIX_EPOCH).unwrap())
@@ -92,19 +92,12 @@ use crate::prelude::*;
9292#[ cfg( feature = "std" ) ]
9393use std:: time:: SystemTime ;
9494
95- /// Builds an [`Offer`] for the "offer to be paid" flow.
96- ///
97- /// See [module-level documentation] for usage.
98- ///
99- /// [module-level documentation]: self
100- pub struct OfferBuilder {
101- offer : OfferContents ,
102- metadata_material : Option < ( Nonce , HmacEngine < Sha256 > ) > ,
103- }
104-
105- ///
95+ /// A pubkey for signing invoices, either given explicitly or derived.
10696pub enum SigningPubkey < ' a > {
97+ /// A pubkey that is typically known like a node id.
10798 Explicit ( PublicKey ) ,
99+
100+ /// Data needed to derive a pubkey.
108101 Derived ( & ' a ExpandedKey , Nonce ) ,
109102}
110103
@@ -114,6 +107,16 @@ impl<'a> From<PublicKey> for SigningPubkey<'a> {
114107 }
115108}
116109
110+ /// Builds an [`Offer`] for the "offer to be paid" flow.
111+ ///
112+ /// See [module-level documentation] for usage.
113+ ///
114+ /// [module-level documentation]: self
115+ pub struct OfferBuilder {
116+ offer : OfferContents ,
117+ metadata_material : Option < ( Nonce , HmacEngine < Sha256 > ) > ,
118+ }
119+
117120impl OfferBuilder {
118121 /// Creates a new builder for an offer setting the [`Offer::description`] and using the
119122 /// [`Offer::signing_pubkey`] for signing invoices. The associated secret key must be remembered
@@ -250,7 +253,8 @@ impl OfferBuilder {
250253 }
251254 }
252255
253- // Created the metadata for stateless verification.
256+ // Create the metadata for stateless verification. It consists of a 16-byte nonce and a
257+ // 32-byte HMAC of the offer bytes excluding the signing pubkey.
254258 if let Some ( ( nonce, mut hmac) ) = self . metadata_material {
255259 debug_assert ! ( self . offer. metadata. is_none( ) ) ;
256260 let mut tlv_stream = self . offer . as_tlv_stream ( ) ;
0 commit comments