@@ -22,6 +22,7 @@ use crate::offers::invoice_macros::{invoice_accessors_common, invoice_builder_me
22
22
use crate :: offers:: merkle:: {
23
23
self , SignError , SignFn , SignatureTlvStream , SignatureTlvStreamRef , TaggedHash ,
24
24
} ;
25
+ use crate :: offers:: nonce:: Nonce ;
25
26
use crate :: offers:: offer:: {
26
27
Amount , Offer , OfferContents , OfferTlvStream , OfferTlvStreamRef , Quantity ,
27
28
} ;
@@ -97,7 +98,7 @@ impl<'a> StaticInvoiceBuilder<'a> {
97
98
pub fn for_offer_using_derived_keys < T : secp256k1:: Signing > (
98
99
offer : & ' a Offer , payment_paths : Vec < ( BlindedPayInfo , BlindedPath ) > ,
99
100
message_paths : Vec < BlindedPath > , created_at : Duration , expanded_key : & ExpandedKey ,
100
- secp_ctx : & Secp256k1 < T > ,
101
+ nonce : Nonce , secp_ctx : & Secp256k1 < T > ,
101
102
) -> Result < Self , Bolt12SemanticError > {
102
103
if offer. chains ( ) . len ( ) > 1 {
103
104
return Err ( Bolt12SemanticError :: UnexpectedChain ) ;
@@ -111,7 +112,7 @@ impl<'a> StaticInvoiceBuilder<'a> {
111
112
offer. signing_pubkey ( ) . ok_or ( Bolt12SemanticError :: MissingSigningPubkey ) ?;
112
113
113
114
let keys = offer
114
- . verify ( & expanded_key, & secp_ctx)
115
+ . verify ( nonce , & expanded_key, & secp_ctx)
115
116
. map_err ( |( ) | Bolt12SemanticError :: InvalidMetadata ) ?
116
117
. 1
117
118
. ok_or ( Bolt12SemanticError :: MissingSigningPubkey ) ?;
@@ -623,6 +624,7 @@ mod tests {
623
624
vec ! [ blinded_path( ) ] ,
624
625
now,
625
626
& expanded_key,
627
+ nonce,
626
628
& secp_ctx,
627
629
)
628
630
. unwrap ( )
@@ -662,6 +664,7 @@ mod tests {
662
664
vec ! [ blinded_path( ) ] ,
663
665
now,
664
666
& expanded_key,
667
+ nonce,
665
668
& secp_ctx,
666
669
)
667
670
. unwrap ( )
@@ -672,7 +675,7 @@ mod tests {
672
675
invoice. write ( & mut buffer) . unwrap ( ) ;
673
676
674
677
assert_eq ! ( invoice. bytes, buffer. as_slice( ) ) ;
675
- assert ! ( invoice. metadata( ) . is_some ( ) ) ;
678
+ assert_eq ! ( invoice. metadata( ) , None ) ;
676
679
assert_eq ! ( invoice. amount( ) , None ) ;
677
680
assert_eq ! ( invoice. description( ) , None ) ;
678
681
assert_eq ! ( invoice. offer_features( ) , & OfferFeatures :: empty( ) ) ;
@@ -698,13 +701,12 @@ mod tests {
698
701
) ;
699
702
700
703
let paths = vec ! [ blinded_path( ) ] ;
701
- let metadata = vec ! [ 42 ; 16 ] ;
702
704
assert_eq ! (
703
705
invoice. as_tlv_stream( ) ,
704
706
(
705
707
OfferTlvStreamRef {
706
708
chains: None ,
707
- metadata: Some ( & metadata ) ,
709
+ metadata: None ,
708
710
currency: None ,
709
711
amount: None ,
710
712
description: None ,
@@ -762,6 +764,7 @@ mod tests {
762
764
vec ! [ blinded_path( ) ] ,
763
765
now,
764
766
& expanded_key,
767
+ nonce,
765
768
& secp_ctx,
766
769
)
767
770
. unwrap ( )
@@ -782,6 +785,7 @@ mod tests {
782
785
vec ! [ blinded_path( ) ] ,
783
786
now,
784
787
& expanded_key,
788
+ nonce,
785
789
& secp_ctx,
786
790
)
787
791
. unwrap ( )
@@ -815,6 +819,7 @@ mod tests {
815
819
vec ! [ blinded_path( ) ] ,
816
820
now,
817
821
& expanded_key,
822
+ nonce,
818
823
& secp_ctx,
819
824
) {
820
825
assert_eq ! ( e, Bolt12SemanticError :: MissingPaths ) ;
@@ -829,6 +834,7 @@ mod tests {
829
834
Vec :: new ( ) ,
830
835
now,
831
836
& expanded_key,
837
+ nonce,
832
838
& secp_ctx,
833
839
) {
834
840
assert_eq ! ( e, Bolt12SemanticError :: MissingPaths ) ;
@@ -849,6 +855,7 @@ mod tests {
849
855
vec ! [ blinded_path( ) ] ,
850
856
now,
851
857
& expanded_key,
858
+ nonce,
852
859
& secp_ctx,
853
860
) {
854
861
assert_eq ! ( e, Bolt12SemanticError :: MissingPaths ) ;
@@ -886,6 +893,7 @@ mod tests {
886
893
vec ! [ blinded_path( ) ] ,
887
894
now,
888
895
& expanded_key,
896
+ nonce,
889
897
& secp_ctx,
890
898
) {
891
899
assert_eq ! ( e, Bolt12SemanticError :: MissingSigningPubkey ) ;
@@ -906,6 +914,7 @@ mod tests {
906
914
vec ! [ blinded_path( ) ] ,
907
915
now,
908
916
& expanded_key,
917
+ nonce,
909
918
& secp_ctx,
910
919
) {
911
920
assert_eq ! ( e, Bolt12SemanticError :: InvalidMetadata ) ;
@@ -937,6 +946,7 @@ mod tests {
937
946
vec ! [ blinded_path( ) ] ,
938
947
now,
939
948
& expanded_key,
949
+ nonce,
940
950
& secp_ctx,
941
951
) {
942
952
assert_eq ! ( e, Bolt12SemanticError :: UnexpectedChain ) ;
@@ -967,6 +977,7 @@ mod tests {
967
977
vec ! [ blinded_path( ) ] ,
968
978
now,
969
979
& expanded_key,
980
+ nonce,
970
981
& secp_ctx,
971
982
)
972
983
. unwrap ( )
@@ -1007,6 +1018,7 @@ mod tests {
1007
1018
vec ! [ blinded_path( ) ] ,
1008
1019
now,
1009
1020
& expanded_key,
1021
+ nonce,
1010
1022
& secp_ctx,
1011
1023
)
1012
1024
. unwrap ( )
0 commit comments