@@ -413,14 +413,17 @@ macro_rules! invoice_builder_methods {
413
413
payment_paths: Vec <BlindedPaymentPath >, created_at: Duration ,
414
414
payment_hash: PaymentHash , amount_msats: u64 , signing_pubkey: PublicKey ,
415
415
) -> InvoiceFields {
416
+ let mut features = Bolt12InvoiceFeatures :: empty( ) ;
417
+ features. set_attributable_failures_optional( ) ;
418
+
416
419
InvoiceFields {
417
420
payment_paths,
418
421
created_at,
419
422
relative_expiry: None ,
420
423
payment_hash,
421
424
amount_msats,
422
425
fallbacks: None ,
423
- features: Bolt12InvoiceFeatures :: empty ( ) ,
426
+ features,
424
427
signing_pubkey,
425
428
#[ cfg( test) ]
426
429
experimental_baz: None ,
@@ -1777,6 +1780,7 @@ mod tests {
1777
1780
use bitcoin:: secp256k1:: { self , Keypair , Message , Secp256k1 , SecretKey , XOnlyPublicKey } ;
1778
1781
use bitcoin:: { CompressedPublicKey , WitnessProgram , WitnessVersion } ;
1779
1782
1783
+ use core:: f32:: consts:: E ;
1780
1784
use core:: time:: Duration ;
1781
1785
1782
1786
use crate :: blinded_path:: message:: BlindedMessagePath ;
@@ -1878,7 +1882,10 @@ mod tests {
1878
1882
assert ! ( !unsigned_invoice. is_expired( ) ) ;
1879
1883
assert_eq ! ( unsigned_invoice. payment_hash( ) , payment_hash) ;
1880
1884
assert ! ( unsigned_invoice. fallbacks( ) . is_empty( ) ) ;
1881
- assert_eq ! ( unsigned_invoice. invoice_features( ) , & Bolt12InvoiceFeatures :: empty( ) ) ;
1885
+
1886
+ let mut expected_features = Bolt12InvoiceFeatures :: empty ( ) ;
1887
+ expected_features. set_attributable_failures_optional ( ) ;
1888
+ assert_eq ! ( unsigned_invoice. invoice_features( ) , & expected_features) ;
1882
1889
1883
1890
match UnsignedBolt12Invoice :: try_from ( buffer) {
1884
1891
Err ( e) => panic ! ( "error parsing unsigned invoice: {:?}" , e) ,
@@ -1926,7 +1933,7 @@ mod tests {
1926
1933
assert ! ( !invoice. is_expired( ) ) ;
1927
1934
assert_eq ! ( invoice. payment_hash( ) , payment_hash) ;
1928
1935
assert ! ( invoice. fallbacks( ) . is_empty( ) ) ;
1929
- assert_eq ! ( invoice. invoice_features( ) , & Bolt12InvoiceFeatures :: empty ( ) ) ;
1936
+ assert_eq ! ( invoice. invoice_features( ) , & expected_features ) ;
1930
1937
assert ! ( !invoice. is_for_refund_without_paths( ) ) ;
1931
1938
1932
1939
let message = TaggedHash :: from_valid_tlv_stream_bytes ( SIGNATURE_TAG , & invoice. bytes ) ;
@@ -1974,7 +1981,7 @@ mod tests {
1974
1981
payment_hash: Some ( & payment_hash) ,
1975
1982
amount: Some ( 1000 ) ,
1976
1983
fallbacks: None ,
1977
- features: None ,
1984
+ features: Some ( & expected_features ) ,
1978
1985
node_id: Some ( & recipient_pubkey( ) ) ,
1979
1986
message_paths: None ,
1980
1987
} ,
@@ -2009,6 +2016,9 @@ mod tests {
2009
2016
let mut buffer = Vec :: new ( ) ;
2010
2017
invoice. write ( & mut buffer) . unwrap ( ) ;
2011
2018
2019
+ let mut expected_features = Bolt12InvoiceFeatures :: empty ( ) ;
2020
+ expected_features. set_attributable_failures_optional ( ) ;
2021
+
2012
2022
assert_eq ! ( invoice. bytes, buffer. as_slice( ) ) ;
2013
2023
assert_eq ! ( invoice. payer_metadata( ) , & [ 1 ; 32 ] ) ;
2014
2024
assert_eq ! ( invoice. offer_chains( ) , None ) ;
@@ -2034,7 +2044,7 @@ mod tests {
2034
2044
assert ! ( !invoice. is_expired( ) ) ;
2035
2045
assert_eq ! ( invoice. payment_hash( ) , payment_hash) ;
2036
2046
assert ! ( invoice. fallbacks( ) . is_empty( ) ) ;
2037
- assert_eq ! ( invoice. invoice_features( ) , & Bolt12InvoiceFeatures :: empty ( ) ) ;
2047
+ assert_eq ! ( invoice. invoice_features( ) , & expected_features ) ;
2038
2048
assert ! ( invoice. is_for_refund_without_paths( ) ) ;
2039
2049
2040
2050
let message = TaggedHash :: from_valid_tlv_stream_bytes ( SIGNATURE_TAG , & invoice. bytes ) ;
@@ -2077,7 +2087,7 @@ mod tests {
2077
2087
payment_hash: Some ( & payment_hash) ,
2078
2088
amount: Some ( 1000 ) ,
2079
2089
fallbacks: None ,
2080
- features: None ,
2090
+ features: Some ( & expected_features ) ,
2081
2091
node_id: Some ( & recipient_pubkey( ) ) ,
2082
2092
message_paths: None ,
2083
2093
} ,
@@ -2501,6 +2511,7 @@ mod tests {
2501
2511
2502
2512
let mut features = Bolt12InvoiceFeatures :: empty ( ) ;
2503
2513
features. set_basic_mpp_optional ( ) ;
2514
+ features. set_attributable_failures_optional ( ) ;
2504
2515
2505
2516
let invoice = OfferBuilder :: new ( recipient_pubkey ( ) )
2506
2517
. amount_msats ( 1000 )
@@ -2838,6 +2849,7 @@ mod tests {
2838
2849
Ok ( invoice) => {
2839
2850
let mut features = Bolt12InvoiceFeatures :: empty ( ) ;
2840
2851
features. set_basic_mpp_optional ( ) ;
2852
+ features. set_attributable_failures_optional ( ) ;
2841
2853
assert_eq ! ( invoice. invoice_features( ) , & features) ;
2842
2854
} ,
2843
2855
Err ( e) => panic ! ( "error parsing invoice: {:?}" , e) ,
0 commit comments