@@ -75,6 +75,7 @@ use crate::offers::offer::{Offer, OfferContents, OfferId, OfferTlvStream, OfferT
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
+ source_human_readable_name: None ,
244
246
}
245
247
}
246
248
@@ -299,6 +301,14 @@ macro_rules! invoice_request_builder_methods { (
299
301
$return_value
300
302
}
301
303
304
+ /// Sets the [`InvoiceRequest::source_human_readable_name`].
305
+ ///
306
+ /// Successive calls to this method will override the previous setting.
307
+ pub fn sourced_from_human_readable_name( $( $self_mut) * $self: $self_type, hrn: HumanReadableName ) -> $return_type {
308
+ $self. invoice_request. source_human_readable_name = Some ( hrn) ;
309
+ $return_value
310
+ }
311
+
302
312
fn build_with_checks( $( $self_mut) * $self: $self_type) -> Result <
303
313
( UnsignedInvoiceRequest , Option <Keypair >, Option <& ' b Secp256k1 <$secp_context>>) ,
304
314
Bolt12SemanticError
@@ -643,6 +653,7 @@ pub(super) struct InvoiceRequestContentsWithoutPayerSigningPubkey {
643
653
features : InvoiceRequestFeatures ,
644
654
quantity : Option < u64 > ,
645
655
payer_note : Option < String > ,
656
+ source_human_readable_name : Option < HumanReadableName > ,
646
657
}
647
658
648
659
macro_rules! invoice_request_accessors { ( $self: ident, $contents: expr) => {
@@ -687,6 +698,12 @@ macro_rules! invoice_request_accessors { ($self: ident, $contents: expr) => {
687
698
pub fn payer_note( & $self) -> Option <PrintableString > {
688
699
$contents. payer_note( )
689
700
}
701
+
702
+ /// If the [`Offer`] was sourced from a BIP 353 Human Readable Name, this should be set by the
703
+ /// builder to indicate the original [`HumanReadableName`] which was resolved.
704
+ pub fn source_human_readable_name( & $self) -> & Option <HumanReadableName > {
705
+ $contents. source_human_readable_name( )
706
+ }
690
707
} }
691
708
692
709
impl UnsignedInvoiceRequest {
@@ -940,7 +957,7 @@ impl VerifiedInvoiceRequest {
940
957
let InvoiceRequestContents {
941
958
payer_signing_pubkey,
942
959
inner : InvoiceRequestContentsWithoutPayerSigningPubkey {
943
- payer : _ , offer : _ , chain : _ , amount_msats : _ , features : _ , quantity, payer_note
960
+ quantity, payer_note, ..
944
961
} ,
945
962
} = & self . inner . contents ;
946
963
@@ -983,6 +1000,10 @@ impl InvoiceRequestContents {
983
1000
. map ( |payer_note| PrintableString ( payer_note. as_str ( ) ) )
984
1001
}
985
1002
1003
+ pub ( super ) fn source_human_readable_name ( & self ) -> & Option < HumanReadableName > {
1004
+ & self . inner . source_human_readable_name
1005
+ }
1006
+
986
1007
pub ( super ) fn as_tlv_stream ( & self ) -> PartialInvoiceRequestTlvStreamRef {
987
1008
let ( payer, offer, mut invoice_request) = self . inner . as_tlv_stream ( ) ;
988
1009
invoice_request. payer_id = Some ( & self . payer_signing_pubkey ) ;
@@ -1018,6 +1039,7 @@ impl InvoiceRequestContentsWithoutPayerSigningPubkey {
1018
1039
quantity : self . quantity ,
1019
1040
payer_id : None ,
1020
1041
payer_note : self . payer_note . as_ref ( ) ,
1042
+ source_human_readable_name : self . source_human_readable_name . as_ref ( ) ,
1021
1043
paths : None ,
1022
1044
} ;
1023
1045
@@ -1070,6 +1092,7 @@ tlv_stream!(InvoiceRequestTlvStream, InvoiceRequestTlvStreamRef, INVOICE_REQUEST
1070
1092
( 89 , payer_note: ( String , WithoutLength ) ) ,
1071
1093
// Only used for Refund since the onion message of an InvoiceRequest has a reply path.
1072
1094
( 90 , paths: ( Vec <BlindedMessagePath >, WithoutLength ) ) ,
1095
+ ( 91 , source_human_readable_name: HumanReadableName ) ,
1073
1096
} ) ;
1074
1097
1075
1098
type FullInvoiceRequestTlvStream =
@@ -1154,6 +1177,7 @@ impl TryFrom<PartialInvoiceRequestTlvStream> for InvoiceRequestContents {
1154
1177
offer_tlv_stream,
1155
1178
InvoiceRequestTlvStream {
1156
1179
chain, amount, features, quantity, payer_id, payer_note, paths,
1180
+ source_human_readable_name,
1157
1181
} ,
1158
1182
) = tlv_stream;
1159
1183
@@ -1188,6 +1212,7 @@ impl TryFrom<PartialInvoiceRequestTlvStream> for InvoiceRequestContents {
1188
1212
Ok ( InvoiceRequestContents {
1189
1213
inner : InvoiceRequestContentsWithoutPayerSigningPubkey {
1190
1214
payer, offer, chain, amount_msats : amount, features, quantity, payer_note,
1215
+ source_human_readable_name,
1191
1216
} ,
1192
1217
payer_signing_pubkey,
1193
1218
} )
@@ -1365,6 +1390,7 @@ mod tests {
1365
1390
payer_id: Some ( & payer_pubkey( ) ) ,
1366
1391
payer_note: None ,
1367
1392
paths: None ,
1393
+ source_human_readable_name: None ,
1368
1394
} ,
1369
1395
SignatureTlvStreamRef { signature: Some ( & invoice_request. signature( ) ) } ,
1370
1396
) ,
0 commit comments