@@ -121,7 +121,7 @@ use crate::ln::msgs::DecodeError;
121
121
use crate :: offers:: invoice_macros:: { invoice_accessors_common, invoice_builder_methods_common} ;
122
122
#[ cfg( test) ]
123
123
use crate :: offers:: invoice_macros:: invoice_builder_methods_test;
124
- use crate :: offers:: invoice_request:: { INVOICE_REQUEST_PAYER_ID_TYPE , INVOICE_REQUEST_TYPES , IV_BYTES as INVOICE_REQUEST_IV_BYTES , InvoiceRequest , InvoiceRequestContents , InvoiceRequestTlvStream , InvoiceRequestTlvStreamRef } ;
124
+ use crate :: offers:: invoice_request:: { EXPERIMENTAL_INVOICE_REQUEST_TYPES , ExperimentalInvoiceRequestTlvStream , ExperimentalInvoiceRequestTlvStreamRef , INVOICE_REQUEST_PAYER_ID_TYPE , INVOICE_REQUEST_TYPES , IV_BYTES as INVOICE_REQUEST_IV_BYTES , InvoiceRequest , InvoiceRequestContents , InvoiceRequestTlvStream , InvoiceRequestTlvStreamRef } ;
125
125
use crate :: offers:: merkle:: { SignError , SignFn , SignatureTlvStream , SignatureTlvStreamRef , TaggedHash , TlvStream , self } ;
126
126
use crate :: offers:: nonce:: Nonce ;
127
127
use crate :: offers:: offer:: { Amount , EXPERIMENTAL_OFFER_TYPES , ExperimentalOfferTlvStream , ExperimentalOfferTlvStreamRef , OFFER_TYPES , OfferTlvStream , OfferTlvStreamRef , Quantity } ;
@@ -493,7 +493,8 @@ where
493
493
impl UnsignedBolt12Invoice {
494
494
fn new ( invreq_bytes : & [ u8 ] , contents : InvoiceContents ) -> Self {
495
495
const NON_EXPERIMENTAL_TYPES : core:: ops:: Range < u64 > = 0 ..INVOICE_REQUEST_TYPES . end ;
496
- const EXPERIMENTAL_TYPES : core:: ops:: Range < u64 > = EXPERIMENTAL_OFFER_TYPES ;
496
+ const EXPERIMENTAL_TYPES : core:: ops:: Range < u64 > =
497
+ EXPERIMENTAL_OFFER_TYPES . start ..EXPERIMENTAL_INVOICE_REQUEST_TYPES . end ;
497
498
498
499
let mut bytes = Vec :: new ( ) ;
499
500
@@ -504,7 +505,7 @@ impl UnsignedBolt12Invoice {
504
505
record. write ( & mut bytes) . unwrap ( ) ;
505
506
}
506
507
507
- let ( _, _, _, invoice_tlv_stream, _) = contents. as_tlv_stream ( ) ;
508
+ let ( _, _, _, invoice_tlv_stream, _, _ ) = contents. as_tlv_stream ( ) ;
508
509
invoice_tlv_stream. write ( & mut bytes) . unwrap ( ) ;
509
510
510
511
let mut experimental_bytes = Vec :: new ( ) ;
@@ -869,14 +870,15 @@ impl Bolt12Invoice {
869
870
pub ( crate ) fn as_tlv_stream ( & self ) -> FullInvoiceTlvStreamRef {
870
871
let (
871
872
payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream, invoice_tlv_stream,
872
- experimental_offer_tlv_stream,
873
+ experimental_offer_tlv_stream, experimental_invoice_request_tlv_stream ,
873
874
) = self . contents . as_tlv_stream ( ) ;
874
875
let signature_tlv_stream = SignatureTlvStreamRef {
875
876
signature : Some ( & self . signature ) ,
876
877
} ;
877
878
(
878
879
payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream, invoice_tlv_stream,
879
880
signature_tlv_stream, experimental_offer_tlv_stream,
881
+ experimental_invoice_request_tlv_stream,
880
882
)
881
883
}
882
884
@@ -1110,7 +1112,8 @@ impl InvoiceContents {
1110
1112
& self , bytes : & [ u8 ] , metadata : & Metadata , key : & ExpandedKey , iv_bytes : & [ u8 ; IV_LEN ] ,
1111
1113
secp_ctx : & Secp256k1 < T > ,
1112
1114
) -> Result < PaymentId , ( ) > {
1113
- const EXPERIMENTAL_TYPES : core:: ops:: Range < u64 > = EXPERIMENTAL_OFFER_TYPES ;
1115
+ const EXPERIMENTAL_TYPES : core:: ops:: Range < u64 > =
1116
+ EXPERIMENTAL_OFFER_TYPES . start ..EXPERIMENTAL_INVOICE_REQUEST_TYPES . end ;
1114
1117
1115
1118
let offer_records = TlvStream :: new ( bytes) . range ( OFFER_TYPES ) ;
1116
1119
let invreq_records = TlvStream :: new ( bytes) . range ( INVOICE_REQUEST_TYPES ) . filter ( |record| {
@@ -1130,13 +1133,15 @@ impl InvoiceContents {
1130
1133
}
1131
1134
1132
1135
fn as_tlv_stream ( & self ) -> PartialInvoiceTlvStreamRef {
1133
- let ( payer, offer, invoice_request, experimental_offer) = match self {
1136
+ let (
1137
+ payer, offer, invoice_request, experimental_offer, experimental_invoice_request,
1138
+ ) = match self {
1134
1139
InvoiceContents :: ForOffer { invoice_request, .. } => invoice_request. as_tlv_stream ( ) ,
1135
1140
InvoiceContents :: ForRefund { refund, .. } => refund. as_tlv_stream ( ) ,
1136
1141
} ;
1137
1142
let invoice = self . fields ( ) . as_tlv_stream ( ) ;
1138
1143
1139
- ( payer, offer, invoice_request, invoice, experimental_offer)
1144
+ ( payer, offer, invoice_request, invoice, experimental_offer, experimental_invoice_request )
1140
1145
}
1141
1146
}
1142
1147
@@ -1238,12 +1243,12 @@ impl TryFrom<Vec<u8>> for UnsignedBolt12Invoice {
1238
1243
let ParsedMessage { mut bytes, tlv_stream } = invoice;
1239
1244
let (
1240
1245
payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream, invoice_tlv_stream,
1241
- experimental_offer_tlv_stream,
1246
+ experimental_offer_tlv_stream, experimental_invoice_request_tlv_stream ,
1242
1247
) = tlv_stream;
1243
1248
let contents = InvoiceContents :: try_from (
1244
1249
(
1245
1250
payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream, invoice_tlv_stream,
1246
- experimental_offer_tlv_stream,
1251
+ experimental_offer_tlv_stream, experimental_invoice_request_tlv_stream ,
1247
1252
)
1248
1253
) ?;
1249
1254
@@ -1307,7 +1312,7 @@ impl_writeable!(FallbackAddress, { version, program });
1307
1312
1308
1313
type FullInvoiceTlvStream =(
1309
1314
PayerTlvStream , OfferTlvStream , InvoiceRequestTlvStream , InvoiceTlvStream , SignatureTlvStream ,
1310
- ExperimentalOfferTlvStream ,
1315
+ ExperimentalOfferTlvStream , ExperimentalInvoiceRequestTlvStream ,
1311
1316
) ;
1312
1317
1313
1318
type FullInvoiceTlvStreamRef < ' a > = (
@@ -1317,6 +1322,7 @@ type FullInvoiceTlvStreamRef<'a> = (
1317
1322
InvoiceTlvStreamRef < ' a > ,
1318
1323
SignatureTlvStreamRef < ' a > ,
1319
1324
ExperimentalOfferTlvStreamRef ,
1325
+ ExperimentalInvoiceRequestTlvStreamRef ,
1320
1326
) ;
1321
1327
1322
1328
impl CursorReadable for FullInvoiceTlvStream {
@@ -1327,14 +1333,20 @@ impl CursorReadable for FullInvoiceTlvStream {
1327
1333
let invoice = CursorReadable :: read ( r) ?;
1328
1334
let signature = CursorReadable :: read ( r) ?;
1329
1335
let experimental_offer = CursorReadable :: read ( r) ?;
1336
+ let experimental_invoice_request = CursorReadable :: read ( r) ?;
1330
1337
1331
- Ok ( ( payer, offer, invoice_request, invoice, signature, experimental_offer) )
1338
+ Ok (
1339
+ (
1340
+ payer, offer, invoice_request, invoice, signature, experimental_offer,
1341
+ experimental_invoice_request,
1342
+ )
1343
+ )
1332
1344
}
1333
1345
}
1334
1346
1335
1347
type PartialInvoiceTlvStream = (
1336
1348
PayerTlvStream , OfferTlvStream , InvoiceRequestTlvStream , InvoiceTlvStream ,
1337
- ExperimentalOfferTlvStream ,
1349
+ ExperimentalOfferTlvStream , ExperimentalInvoiceRequestTlvStream ,
1338
1350
) ;
1339
1351
1340
1352
type PartialInvoiceTlvStreamRef < ' a > = (
@@ -1343,6 +1355,7 @@ type PartialInvoiceTlvStreamRef<'a> = (
1343
1355
InvoiceRequestTlvStreamRef < ' a > ,
1344
1356
InvoiceTlvStreamRef < ' a > ,
1345
1357
ExperimentalOfferTlvStreamRef ,
1358
+ ExperimentalInvoiceRequestTlvStreamRef ,
1346
1359
) ;
1347
1360
1348
1361
impl CursorReadable for PartialInvoiceTlvStream {
@@ -1352,8 +1365,14 @@ impl CursorReadable for PartialInvoiceTlvStream {
1352
1365
let invoice_request = CursorReadable :: read ( r) ?;
1353
1366
let invoice = CursorReadable :: read ( r) ?;
1354
1367
let experimental_offer = CursorReadable :: read ( r) ?;
1368
+ let experimental_invoice_request = CursorReadable :: read ( r) ?;
1355
1369
1356
- Ok ( ( payer, offer, invoice_request, invoice, experimental_offer) )
1370
+ Ok (
1371
+ (
1372
+ payer, offer, invoice_request, invoice, experimental_offer,
1373
+ experimental_invoice_request,
1374
+ )
1375
+ )
1357
1376
}
1358
1377
}
1359
1378
@@ -1366,11 +1385,12 @@ impl TryFrom<ParsedMessage<FullInvoiceTlvStream>> for Bolt12Invoice {
1366
1385
payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream, invoice_tlv_stream,
1367
1386
SignatureTlvStream { signature } ,
1368
1387
experimental_offer_tlv_stream,
1388
+ experimental_invoice_request_tlv_stream,
1369
1389
) = tlv_stream;
1370
1390
let contents = InvoiceContents :: try_from (
1371
1391
(
1372
1392
payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream, invoice_tlv_stream,
1373
- experimental_offer_tlv_stream,
1393
+ experimental_offer_tlv_stream, experimental_invoice_request_tlv_stream ,
1374
1394
)
1375
1395
) ?;
1376
1396
@@ -1398,6 +1418,7 @@ impl TryFrom<PartialInvoiceTlvStream> for InvoiceContents {
1398
1418
features, node_id, message_paths,
1399
1419
} ,
1400
1420
experimental_offer_tlv_stream,
1421
+ experimental_invoice_request_tlv_stream,
1401
1422
) = tlv_stream;
1402
1423
1403
1424
if message_paths. is_some ( ) { return Err ( Bolt12SemanticError :: UnexpectedPaths ) }
@@ -1432,15 +1453,15 @@ impl TryFrom<PartialInvoiceTlvStream> for InvoiceContents {
1432
1453
let refund = RefundContents :: try_from (
1433
1454
(
1434
1455
payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream,
1435
- experimental_offer_tlv_stream,
1456
+ experimental_offer_tlv_stream, experimental_invoice_request_tlv_stream ,
1436
1457
)
1437
1458
) ?;
1438
1459
Ok ( InvoiceContents :: ForRefund { refund, fields } )
1439
1460
} else {
1440
1461
let invoice_request = InvoiceRequestContents :: try_from (
1441
1462
(
1442
1463
payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream,
1443
- experimental_offer_tlv_stream,
1464
+ experimental_offer_tlv_stream, experimental_invoice_request_tlv_stream ,
1444
1465
)
1445
1466
) ?;
1446
1467
Ok ( InvoiceContents :: ForOffer { invoice_request, fields } )
@@ -1513,7 +1534,7 @@ mod tests {
1513
1534
use crate :: ln:: features:: { Bolt12InvoiceFeatures , InvoiceRequestFeatures , OfferFeatures } ;
1514
1535
use crate :: ln:: inbound_payment:: ExpandedKey ;
1515
1536
use crate :: ln:: msgs:: DecodeError ;
1516
- use crate :: offers:: invoice_request:: InvoiceRequestTlvStreamRef ;
1537
+ use crate :: offers:: invoice_request:: { ExperimentalInvoiceRequestTlvStreamRef , InvoiceRequestTlvStreamRef } ;
1517
1538
use crate :: offers:: merkle:: { SignError , SignatureTlvStreamRef , TaggedHash , self } ;
1518
1539
use crate :: offers:: nonce:: Nonce ;
1519
1540
use crate :: offers:: offer:: { Amount , ExperimentalOfferTlvStreamRef , OfferTlvStreamRef , Quantity } ;
@@ -1687,6 +1708,7 @@ mod tests {
1687
1708
ExperimentalOfferTlvStreamRef {
1688
1709
experimental_foo: None ,
1689
1710
} ,
1711
+ ExperimentalInvoiceRequestTlvStreamRef { } ,
1690
1712
) ,
1691
1713
) ;
1692
1714
@@ -1783,6 +1805,7 @@ mod tests {
1783
1805
ExperimentalOfferTlvStreamRef {
1784
1806
experimental_foo: None ,
1785
1807
} ,
1808
+ ExperimentalInvoiceRequestTlvStreamRef { } ,
1786
1809
) ,
1787
1810
) ;
1788
1811
@@ -1979,7 +2002,7 @@ mod tests {
1979
2002
. relative_expiry ( one_hour. as_secs ( ) as u32 )
1980
2003
. build ( ) . unwrap ( )
1981
2004
. sign ( recipient_sign) . unwrap ( ) ;
1982
- let ( _, _, _, tlv_stream, _, _) = invoice. as_tlv_stream ( ) ;
2005
+ let ( _, _, _, tlv_stream, _, _, _ ) = invoice. as_tlv_stream ( ) ;
1983
2006
#[ cfg( feature = "std" ) ]
1984
2007
assert ! ( !invoice. is_expired( ) ) ;
1985
2008
assert_eq ! ( invoice. relative_expiry( ) , one_hour) ;
@@ -1995,7 +2018,7 @@ mod tests {
1995
2018
. relative_expiry ( one_hour. as_secs ( ) as u32 - 1 )
1996
2019
. build ( ) . unwrap ( )
1997
2020
. sign ( recipient_sign) . unwrap ( ) ;
1998
- let ( _, _, _, tlv_stream, _, _) = invoice. as_tlv_stream ( ) ;
2021
+ let ( _, _, _, tlv_stream, _, _, _ ) = invoice. as_tlv_stream ( ) ;
1999
2022
#[ cfg( feature = "std" ) ]
2000
2023
assert ! ( invoice. is_expired( ) ) ;
2001
2024
assert_eq ! ( invoice. relative_expiry( ) , one_hour - Duration :: from_secs( 1 ) ) ;
@@ -2014,7 +2037,7 @@ mod tests {
2014
2037
. respond_with_no_std ( payment_paths ( ) , payment_hash ( ) , now ( ) ) . unwrap ( )
2015
2038
. build ( ) . unwrap ( )
2016
2039
. sign ( recipient_sign) . unwrap ( ) ;
2017
- let ( _, _, _, tlv_stream, _, _) = invoice. as_tlv_stream ( ) ;
2040
+ let ( _, _, _, tlv_stream, _, _, _ ) = invoice. as_tlv_stream ( ) ;
2018
2041
assert_eq ! ( invoice. amount_msats( ) , 1001 ) ;
2019
2042
assert_eq ! ( tlv_stream. amount, Some ( 1001 ) ) ;
2020
2043
}
@@ -2032,7 +2055,7 @@ mod tests {
2032
2055
. respond_with_no_std ( payment_paths ( ) , payment_hash ( ) , now ( ) ) . unwrap ( )
2033
2056
. build ( ) . unwrap ( )
2034
2057
. sign ( recipient_sign) . unwrap ( ) ;
2035
- let ( _, _, _, tlv_stream, _, _) = invoice. as_tlv_stream ( ) ;
2058
+ let ( _, _, _, tlv_stream, _, _, _ ) = invoice. as_tlv_stream ( ) ;
2036
2059
assert_eq ! ( invoice. amount_msats( ) , 2000 ) ;
2037
2060
assert_eq ! ( tlv_stream. amount, Some ( 2000 ) ) ;
2038
2061
@@ -2070,7 +2093,7 @@ mod tests {
2070
2093
. fallback_v1_p2tr_tweaked ( & tweaked_pubkey)
2071
2094
. build ( ) . unwrap ( )
2072
2095
. sign ( recipient_sign) . unwrap ( ) ;
2073
- let ( _, _, _, tlv_stream, _, _) = invoice. as_tlv_stream ( ) ;
2096
+ let ( _, _, _, tlv_stream, _, _, _ ) = invoice. as_tlv_stream ( ) ;
2074
2097
assert_eq ! (
2075
2098
invoice. fallbacks( ) ,
2076
2099
vec![
@@ -2113,7 +2136,7 @@ mod tests {
2113
2136
. allow_mpp ( )
2114
2137
. build ( ) . unwrap ( )
2115
2138
. sign ( recipient_sign) . unwrap ( ) ;
2116
- let ( _, _, _, tlv_stream, _, _) = invoice. as_tlv_stream ( ) ;
2139
+ let ( _, _, _, tlv_stream, _, _, _ ) = invoice. as_tlv_stream ( ) ;
2117
2140
assert_eq ! ( invoice. invoice_features( ) , & features) ;
2118
2141
assert_eq ! ( tlv_stream. features, Some ( & features) ) ;
2119
2142
}
0 commit comments