@@ -22,6 +22,7 @@ use crate::offers::invoice_macros::{invoice_accessors_common, invoice_builder_me
2222use crate :: offers:: merkle:: {
2323 self , SignError , SignFn , SignatureTlvStream , SignatureTlvStreamRef , TaggedHash ,
2424} ;
25+ use crate :: offers:: nonce:: Nonce ;
2526use crate :: offers:: offer:: {
2627 Amount , Offer , OfferContents , OfferTlvStream , OfferTlvStreamRef , Quantity ,
2728} ;
@@ -99,7 +100,7 @@ impl<'a> StaticInvoiceBuilder<'a> {
99100 pub fn for_offer_using_derived_keys < T : secp256k1:: Signing > (
100101 offer : & ' a Offer , payment_paths : Vec < ( BlindedPayInfo , BlindedPath ) > ,
101102 message_paths : Vec < BlindedPath > , created_at : Duration , expanded_key : & ExpandedKey ,
102- secp_ctx : & Secp256k1 < T > ,
103+ nonce : Nonce , secp_ctx : & Secp256k1 < T > ,
103104 ) -> Result < Self , Bolt12SemanticError > {
104105 if offer. chains ( ) . len ( ) > 1 {
105106 return Err ( Bolt12SemanticError :: UnexpectedChain ) ;
@@ -113,7 +114,7 @@ impl<'a> StaticInvoiceBuilder<'a> {
113114 offer. signing_pubkey ( ) . ok_or ( Bolt12SemanticError :: MissingSigningPubkey ) ?;
114115
115116 let keys = offer
116- . verify ( & expanded_key, & secp_ctx)
117+ . verify ( nonce , & expanded_key, & secp_ctx)
117118 . map_err ( |( ) | Bolt12SemanticError :: InvalidMetadata ) ?
118119 . 1
119120 . ok_or ( Bolt12SemanticError :: MissingSigningPubkey ) ?;
@@ -625,6 +626,7 @@ mod tests {
625626 vec ! [ blinded_path( ) ] ,
626627 now,
627628 & expanded_key,
629+ nonce,
628630 & secp_ctx,
629631 )
630632 . unwrap ( )
@@ -664,6 +666,7 @@ mod tests {
664666 vec ! [ blinded_path( ) ] ,
665667 now,
666668 & expanded_key,
669+ nonce,
667670 & secp_ctx,
668671 )
669672 . unwrap ( )
@@ -674,7 +677,7 @@ mod tests {
674677 invoice. write ( & mut buffer) . unwrap ( ) ;
675678
676679 assert_eq ! ( invoice. bytes, buffer. as_slice( ) ) ;
677- assert ! ( invoice. metadata( ) . is_some ( ) ) ;
680+ assert_eq ! ( invoice. metadata( ) , None ) ;
678681 assert_eq ! ( invoice. amount( ) , None ) ;
679682 assert_eq ! ( invoice. description( ) , None ) ;
680683 assert_eq ! ( invoice. offer_features( ) , & OfferFeatures :: empty( ) ) ;
@@ -700,13 +703,12 @@ mod tests {
700703 ) ;
701704
702705 let paths = vec ! [ blinded_path( ) ] ;
703- let metadata = vec ! [ 42 ; 16 ] ;
704706 assert_eq ! (
705707 invoice. as_tlv_stream( ) ,
706708 (
707709 OfferTlvStreamRef {
708710 chains: None ,
709- metadata: Some ( & metadata ) ,
711+ metadata: None ,
710712 currency: None ,
711713 amount: None ,
712714 description: None ,
@@ -764,6 +766,7 @@ mod tests {
764766 vec ! [ blinded_path( ) ] ,
765767 now,
766768 & expanded_key,
769+ nonce,
767770 & secp_ctx,
768771 )
769772 . unwrap ( )
@@ -784,6 +787,7 @@ mod tests {
784787 vec ! [ blinded_path( ) ] ,
785788 now,
786789 & expanded_key,
790+ nonce,
787791 & secp_ctx,
788792 )
789793 . unwrap ( )
@@ -817,6 +821,7 @@ mod tests {
817821 vec ! [ blinded_path( ) ] ,
818822 now,
819823 & expanded_key,
824+ nonce,
820825 & secp_ctx,
821826 ) {
822827 assert_eq ! ( e, Bolt12SemanticError :: MissingPaths ) ;
@@ -831,6 +836,7 @@ mod tests {
831836 Vec :: new ( ) ,
832837 now,
833838 & expanded_key,
839+ nonce,
834840 & secp_ctx,
835841 ) {
836842 assert_eq ! ( e, Bolt12SemanticError :: MissingPaths ) ;
@@ -851,6 +857,7 @@ mod tests {
851857 vec ! [ blinded_path( ) ] ,
852858 now,
853859 & expanded_key,
860+ nonce,
854861 & secp_ctx,
855862 ) {
856863 assert_eq ! ( e, Bolt12SemanticError :: MissingPaths ) ;
@@ -888,6 +895,7 @@ mod tests {
888895 vec ! [ blinded_path( ) ] ,
889896 now,
890897 & expanded_key,
898+ nonce,
891899 & secp_ctx,
892900 ) {
893901 assert_eq ! ( e, Bolt12SemanticError :: MissingSigningPubkey ) ;
@@ -908,6 +916,7 @@ mod tests {
908916 vec ! [ blinded_path( ) ] ,
909917 now,
910918 & expanded_key,
919+ nonce,
911920 & secp_ctx,
912921 ) {
913922 assert_eq ! ( e, Bolt12SemanticError :: InvalidMetadata ) ;
@@ -939,6 +948,7 @@ mod tests {
939948 vec ! [ blinded_path( ) ] ,
940949 now,
941950 & expanded_key,
951+ nonce,
942952 & secp_ctx,
943953 ) {
944954 assert_eq ! ( e, Bolt12SemanticError :: UnexpectedChain ) ;
@@ -969,6 +979,7 @@ mod tests {
969979 vec ! [ blinded_path( ) ] ,
970980 now,
971981 & expanded_key,
982+ nonce,
972983 & secp_ctx,
973984 )
974985 . unwrap ( )
@@ -1009,6 +1020,7 @@ mod tests {
10091020 vec ! [ blinded_path( ) ] ,
10101021 now,
10111022 & expanded_key,
1023+ nonce,
10121024 & secp_ctx,
10131025 )
10141026 . unwrap ( )
0 commit comments