@@ -961,9 +961,41 @@ macro_rules! invoice_request_respond_with_derived_signing_pubkey_methods { (
961961 }
962962} }
963963
964+ macro_rules! fields_accessor {
965+ ( $self: ident, $inner: expr) => {
966+ /// Fetch the [`InvoiceRequestFields`] for this verified invoice.
967+ ///
968+ /// These are fields which we expect to be useful when receiving a payment for this invoice
969+ /// request, and include the returned [`InvoiceRequestFields`] in the
970+ /// [`PaymentContext::Bolt12Offer`].
971+ ///
972+ /// [`PaymentContext::Bolt12Offer`]: crate::blinded_path::payment::PaymentContext::Bolt12Offer
973+ pub fn fields( & $self) -> InvoiceRequestFields {
974+ let InvoiceRequestContents {
975+ payer_signing_pubkey,
976+ inner: InvoiceRequestContentsWithoutPayerSigningPubkey {
977+ quantity,
978+ payer_note,
979+ ..
980+ } ,
981+ } = & $inner;
982+
983+ InvoiceRequestFields {
984+ payer_signing_pubkey: * payer_signing_pubkey,
985+ quantity: * quantity,
986+ payer_note_truncated: payer_note
987+ . clone( )
988+ . map( |s| UntrustedString ( string_truncate_safe( s, PAYER_NOTE_LIMIT ) ) ) ,
989+ human_readable_name: $self. offer_from_hrn( ) . clone( ) ,
990+ }
991+ }
992+ } ;
993+ }
994+
964995impl VerifiedInvoiceRequestLegacy {
965996 offer_accessors ! ( self , self . inner. contents. inner. offer) ;
966997 invoice_request_accessors ! ( self , self . inner. contents) ;
998+ fields_accessor ! ( self , self . inner. contents) ;
967999 #[ cfg( not( c_bindings) ) ]
9681000 invoice_request_respond_with_explicit_signing_pubkey_methods ! (
9691001 self ,
@@ -988,31 +1020,6 @@ impl VerifiedInvoiceRequestLegacy {
9881020 self . inner,
9891021 InvoiceWithDerivedSigningPubkeyBuilder
9901022 ) ;
991-
992- /// Fetch the [`InvoiceRequestFields`] for this verified invoice.
993- ///
994- /// These are fields which we expect to be useful when receiving a payment for this invoice
995- /// request, and include the returned [`InvoiceRequestFields`] in the
996- /// [`PaymentContext::Bolt12Offer`].
997- ///
998- /// [`PaymentContext::Bolt12Offer`]: crate::blinded_path::payment::PaymentContext::Bolt12Offer
999- pub fn fields ( & self ) -> InvoiceRequestFields {
1000- let InvoiceRequestContents {
1001- payer_signing_pubkey,
1002- inner : InvoiceRequestContentsWithoutPayerSigningPubkey { quantity, payer_note, .. } ,
1003- } = & self . inner . contents ;
1004-
1005- InvoiceRequestFields {
1006- payer_signing_pubkey : * payer_signing_pubkey,
1007- quantity : * quantity,
1008- payer_note_truncated : payer_note
1009- . clone ( )
1010- // Truncate the payer note to `PAYER_NOTE_LIMIT` bytes, rounding
1011- // down to the nearest valid UTF-8 code point boundary.
1012- . map ( |s| UntrustedString ( string_truncate_safe ( s, PAYER_NOTE_LIMIT ) ) ) ,
1013- human_readable_name : self . offer_from_hrn ( ) . clone ( ) ,
1014- }
1015- }
10161023}
10171024
10181025/// `String::truncate(new_len)` panics if you split inside a UTF-8 code point,
0 commit comments