@@ -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
} ;
@@ -99,7 +100,7 @@ impl<'a> StaticInvoiceBuilder<'a> {
99
100
pub fn for_offer_using_derived_keys < T : secp256k1:: Signing > (
100
101
offer : & ' a Offer , payment_paths : Vec < ( BlindedPayInfo , BlindedPath ) > ,
101
102
message_paths : Vec < BlindedPath > , created_at : Duration , expanded_key : & ExpandedKey ,
102
- secp_ctx : & Secp256k1 < T > ,
103
+ nonce : Nonce , secp_ctx : & Secp256k1 < T > ,
103
104
) -> Result < Self , Bolt12SemanticError > {
104
105
if offer. chains ( ) . len ( ) > 1 {
105
106
return Err ( Bolt12SemanticError :: UnexpectedChain ) ;
@@ -113,7 +114,7 @@ impl<'a> StaticInvoiceBuilder<'a> {
113
114
offer. signing_pubkey ( ) . ok_or ( Bolt12SemanticError :: MissingSigningPubkey ) ?;
114
115
115
116
let keys = offer
116
- . verify ( & expanded_key, & secp_ctx)
117
+ . verify ( nonce , & expanded_key, & secp_ctx)
117
118
. map_err ( |( ) | Bolt12SemanticError :: InvalidMetadata ) ?
118
119
. 1
119
120
. ok_or ( Bolt12SemanticError :: MissingSigningPubkey ) ?;
@@ -625,6 +626,7 @@ mod tests {
625
626
vec ! [ blinded_path( ) ] ,
626
627
now,
627
628
& expanded_key,
629
+ nonce,
628
630
& secp_ctx,
629
631
)
630
632
. unwrap ( )
@@ -664,6 +666,7 @@ mod tests {
664
666
vec ! [ blinded_path( ) ] ,
665
667
now,
666
668
& expanded_key,
669
+ nonce,
667
670
& secp_ctx,
668
671
)
669
672
. unwrap ( )
@@ -674,7 +677,7 @@ mod tests {
674
677
invoice. write ( & mut buffer) . unwrap ( ) ;
675
678
676
679
assert_eq ! ( invoice. bytes, buffer. as_slice( ) ) ;
677
- assert ! ( invoice. metadata( ) . is_some ( ) ) ;
680
+ assert_eq ! ( invoice. metadata( ) , None ) ;
678
681
assert_eq ! ( invoice. amount( ) , None ) ;
679
682
assert_eq ! ( invoice. description( ) , None ) ;
680
683
assert_eq ! ( invoice. offer_features( ) , & OfferFeatures :: empty( ) ) ;
@@ -700,13 +703,12 @@ mod tests {
700
703
) ;
701
704
702
705
let paths = vec ! [ blinded_path( ) ] ;
703
- let metadata = vec ! [ 42 ; 16 ] ;
704
706
assert_eq ! (
705
707
invoice. as_tlv_stream( ) ,
706
708
(
707
709
OfferTlvStreamRef {
708
710
chains: None ,
709
- metadata: Some ( & metadata ) ,
711
+ metadata: None ,
710
712
currency: None ,
711
713
amount: None ,
712
714
description: None ,
@@ -764,6 +766,7 @@ mod tests {
764
766
vec ! [ blinded_path( ) ] ,
765
767
now,
766
768
& expanded_key,
769
+ nonce,
767
770
& secp_ctx,
768
771
)
769
772
. unwrap ( )
@@ -784,6 +787,7 @@ mod tests {
784
787
vec ! [ blinded_path( ) ] ,
785
788
now,
786
789
& expanded_key,
790
+ nonce,
787
791
& secp_ctx,
788
792
)
789
793
. unwrap ( )
@@ -817,6 +821,7 @@ mod tests {
817
821
vec ! [ blinded_path( ) ] ,
818
822
now,
819
823
& expanded_key,
824
+ nonce,
820
825
& secp_ctx,
821
826
) {
822
827
assert_eq ! ( e, Bolt12SemanticError :: MissingPaths ) ;
@@ -831,6 +836,7 @@ mod tests {
831
836
Vec :: new ( ) ,
832
837
now,
833
838
& expanded_key,
839
+ nonce,
834
840
& secp_ctx,
835
841
) {
836
842
assert_eq ! ( e, Bolt12SemanticError :: MissingPaths ) ;
@@ -851,6 +857,7 @@ mod tests {
851
857
vec ! [ blinded_path( ) ] ,
852
858
now,
853
859
& expanded_key,
860
+ nonce,
854
861
& secp_ctx,
855
862
) {
856
863
assert_eq ! ( e, Bolt12SemanticError :: MissingPaths ) ;
@@ -888,6 +895,7 @@ mod tests {
888
895
vec ! [ blinded_path( ) ] ,
889
896
now,
890
897
& expanded_key,
898
+ nonce,
891
899
& secp_ctx,
892
900
) {
893
901
assert_eq ! ( e, Bolt12SemanticError :: MissingSigningPubkey ) ;
@@ -908,6 +916,7 @@ mod tests {
908
916
vec ! [ blinded_path( ) ] ,
909
917
now,
910
918
& expanded_key,
919
+ nonce,
911
920
& secp_ctx,
912
921
) {
913
922
assert_eq ! ( e, Bolt12SemanticError :: InvalidMetadata ) ;
@@ -939,6 +948,7 @@ mod tests {
939
948
vec ! [ blinded_path( ) ] ,
940
949
now,
941
950
& expanded_key,
951
+ nonce,
942
952
& secp_ctx,
943
953
) {
944
954
assert_eq ! ( e, Bolt12SemanticError :: UnexpectedChain ) ;
@@ -969,6 +979,7 @@ mod tests {
969
979
vec ! [ blinded_path( ) ] ,
970
980
now,
971
981
& expanded_key,
982
+ nonce,
972
983
& secp_ctx,
973
984
)
974
985
. unwrap ( )
@@ -1009,6 +1020,7 @@ mod tests {
1009
1020
vec ! [ blinded_path( ) ] ,
1010
1021
now,
1011
1022
& expanded_key,
1023
+ nonce,
1012
1024
& secp_ctx,
1013
1025
)
1014
1026
. unwrap ( )
0 commit comments