@@ -961,9 +961,41 @@ macro_rules! invoice_request_respond_with_derived_signing_pubkey_methods { (
961
961
}
962
962
} }
963
963
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
+
964
995
impl VerifiedInvoiceRequestLegacy {
965
996
offer_accessors ! ( self , self . inner. contents. inner. offer) ;
966
997
invoice_request_accessors ! ( self , self . inner. contents) ;
998
+ fields_accessor ! ( self , self . inner. contents) ;
967
999
#[ cfg( not( c_bindings) ) ]
968
1000
invoice_request_respond_with_explicit_signing_pubkey_methods ! (
969
1001
self ,
@@ -988,31 +1020,6 @@ impl VerifiedInvoiceRequestLegacy {
988
1020
self . inner,
989
1021
InvoiceWithDerivedSigningPubkeyBuilder
990
1022
) ;
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
- }
1016
1023
}
1017
1024
1018
1025
/// `String::truncate(new_len)` panics if you split inside a UTF-8 code point,
0 commit comments