@@ -75,6 +75,7 @@ use crate::offers::offer::{EXPERIMENTAL_OFFER_TYPES, ExperimentalOfferTlvStream,
75
75
use crate :: offers:: parse:: { Bolt12ParseError , ParsedMessage , Bolt12SemanticError } ;
76
76
use crate :: offers:: payer:: { PayerContents , PayerTlvStream , PayerTlvStreamRef } ;
77
77
use crate :: offers:: signer:: { Metadata , MetadataMaterial } ;
78
+ use crate :: onion_message:: dns_resolution:: HumanReadableName ;
78
79
use crate :: util:: ser:: { CursorReadable , HighZeroBytesDroppedBigSize , Readable , WithoutLength , Writeable , Writer } ;
79
80
use crate :: util:: string:: { PrintableString , UntrustedString } ;
80
81
@@ -241,6 +242,7 @@ macro_rules! invoice_request_builder_methods { (
241
242
InvoiceRequestContentsWithoutPayerSigningPubkey {
242
243
payer: PayerContents ( metadata) , offer, chain: None , amount_msats: None ,
243
244
features: InvoiceRequestFeatures :: empty( ) , quantity: None , payer_note: None ,
245
+ offer_from_hrn: None ,
244
246
#[ cfg( test) ]
245
247
experimental_bar: None ,
246
248
}
@@ -301,6 +303,14 @@ macro_rules! invoice_request_builder_methods { (
301
303
$return_value
302
304
}
303
305
306
+ /// Sets the [`InvoiceRequest::offer_from_hrn`].
307
+ ///
308
+ /// Successive calls to this method will override the previous setting.
309
+ pub fn sourced_from_human_readable_name( $( $self_mut) * $self: $self_type, hrn: HumanReadableName ) -> $return_type {
310
+ $self. invoice_request. offer_from_hrn = Some ( hrn) ;
311
+ $return_value
312
+ }
313
+
304
314
fn build_with_checks( $( $self_mut) * $self: $self_type) -> Result <
305
315
( UnsignedInvoiceRequest , Option <Keypair >, Option <& ' b Secp256k1 <$secp_context>>) ,
306
316
Bolt12SemanticError
@@ -699,6 +709,7 @@ pub(super) struct InvoiceRequestContentsWithoutPayerSigningPubkey {
699
709
features : InvoiceRequestFeatures ,
700
710
quantity : Option < u64 > ,
701
711
payer_note : Option < String > ,
712
+ offer_from_hrn : Option < HumanReadableName > ,
702
713
#[ cfg( test) ]
703
714
experimental_bar : Option < u64 > ,
704
715
}
@@ -745,6 +756,12 @@ macro_rules! invoice_request_accessors { ($self: ident, $contents: expr) => {
745
756
pub fn payer_note( & $self) -> Option <PrintableString > {
746
757
$contents. payer_note( )
747
758
}
759
+
760
+ /// If the [`Offer`] was sourced from a BIP 353 Human Readable Name, this should be set by the
761
+ /// builder to indicate the original [`HumanReadableName`] which was resolved.
762
+ pub fn offer_from_hrn( & $self) -> & Option <HumanReadableName > {
763
+ $contents. offer_from_hrn( )
764
+ }
748
765
} }
749
766
750
767
impl UnsignedInvoiceRequest {
@@ -1004,9 +1021,7 @@ impl VerifiedInvoiceRequest {
1004
1021
let InvoiceRequestContents {
1005
1022
payer_signing_pubkey,
1006
1023
inner : InvoiceRequestContentsWithoutPayerSigningPubkey {
1007
- payer : _, offer : _, chain : _, amount_msats : _, features : _, quantity, payer_note,
1008
- #[ cfg( test) ]
1009
- experimental_bar : _,
1024
+ quantity, payer_note, ..
1010
1025
} ,
1011
1026
} = & self . inner . contents ;
1012
1027
@@ -1049,6 +1064,10 @@ impl InvoiceRequestContents {
1049
1064
. map ( |payer_note| PrintableString ( payer_note. as_str ( ) ) )
1050
1065
}
1051
1066
1067
+ pub ( super ) fn offer_from_hrn ( & self ) -> & Option < HumanReadableName > {
1068
+ & self . inner . offer_from_hrn
1069
+ }
1070
+
1052
1071
pub ( super ) fn as_tlv_stream ( & self ) -> PartialInvoiceRequestTlvStreamRef {
1053
1072
let ( payer, offer, mut invoice_request, experimental_offer, experimental_invoice_request) =
1054
1073
self . inner . as_tlv_stream ( ) ;
@@ -1085,6 +1104,7 @@ impl InvoiceRequestContentsWithoutPayerSigningPubkey {
1085
1104
quantity : self . quantity ,
1086
1105
payer_id : None ,
1087
1106
payer_note : self . payer_note . as_ref ( ) ,
1107
+ offer_from_hrn : self . offer_from_hrn . as_ref ( ) ,
1088
1108
paths : None ,
1089
1109
} ;
1090
1110
@@ -1142,6 +1162,7 @@ tlv_stream!(InvoiceRequestTlvStream, InvoiceRequestTlvStreamRef<'a>, INVOICE_REQ
1142
1162
( 89 , payer_note: ( String , WithoutLength ) ) ,
1143
1163
// Only used for Refund since the onion message of an InvoiceRequest has a reply path.
1144
1164
( 90 , paths: ( Vec <BlindedMessagePath >, WithoutLength ) ) ,
1165
+ ( 91 , offer_from_hrn: HumanReadableName ) ,
1145
1166
} ) ;
1146
1167
1147
1168
/// Valid type range for experimental invoice_request TLV records.
@@ -1266,6 +1287,7 @@ impl TryFrom<PartialInvoiceRequestTlvStream> for InvoiceRequestContents {
1266
1287
offer_tlv_stream,
1267
1288
InvoiceRequestTlvStream {
1268
1289
chain, amount, features, quantity, payer_id, payer_note, paths,
1290
+ offer_from_hrn,
1269
1291
} ,
1270
1292
experimental_offer_tlv_stream,
1271
1293
ExperimentalInvoiceRequestTlvStream {
@@ -1305,6 +1327,7 @@ impl TryFrom<PartialInvoiceRequestTlvStream> for InvoiceRequestContents {
1305
1327
Ok ( InvoiceRequestContents {
1306
1328
inner : InvoiceRequestContentsWithoutPayerSigningPubkey {
1307
1329
payer, offer, chain, amount_msats : amount, features, quantity, payer_note,
1330
+ offer_from_hrn,
1308
1331
#[ cfg( test) ]
1309
1332
experimental_bar,
1310
1333
} ,
@@ -1484,6 +1507,7 @@ mod tests {
1484
1507
payer_id: Some ( & payer_pubkey( ) ) ,
1485
1508
payer_note: None ,
1486
1509
paths: None ,
1510
+ offer_from_hrn: None ,
1487
1511
} ,
1488
1512
SignatureTlvStreamRef { signature: Some ( & invoice_request. signature( ) ) } ,
1489
1513
ExperimentalOfferTlvStreamRef {
0 commit comments