@@ -117,7 +117,7 @@ use crate::ln::features::{BlindedHopFeatures, Bolt12InvoiceFeatures, InvoiceRequ
117
117
use crate :: ln:: inbound_payment:: { ExpandedKey , IV_LEN } ;
118
118
use crate :: ln:: msgs:: DecodeError ;
119
119
use crate :: offers:: invoice_macros:: { invoice_accessors_common, invoice_builder_methods_common} ;
120
- use crate :: offers:: invoice_request:: { INVOICE_REQUEST_PAYER_ID_TYPE , INVOICE_REQUEST_TYPES , IV_BYTES as INVOICE_REQUEST_IV_BYTES , InvoiceRequest , InvoiceRequestContents , InvoiceRequestTlvStream , InvoiceRequestTlvStreamRef } ;
120
+ 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 } ;
121
121
use crate :: offers:: merkle:: { SignError , SignFn , SignatureTlvStream , SignatureTlvStreamRef , TaggedHash , TlvStream , self } ;
122
122
use crate :: offers:: nonce:: Nonce ;
123
123
use crate :: offers:: offer:: { Amount , EXPERIMENTAL_OFFER_TYPES , ExperimentalOfferTlvStream , ExperimentalOfferTlvStreamRef , OFFER_TYPES , OfferTlvStream , OfferTlvStreamRef , Quantity } ;
@@ -484,7 +484,8 @@ where
484
484
impl UnsignedBolt12Invoice {
485
485
fn new ( invreq_bytes : & [ u8 ] , contents : InvoiceContents ) -> Self {
486
486
const NON_EXPERIMENTAL_TYPES : core:: ops:: Range < u64 > = 0 ..INVOICE_REQUEST_TYPES . end ;
487
- const EXPERIMENTAL_TYPES : core:: ops:: Range < u64 > = EXPERIMENTAL_OFFER_TYPES ;
487
+ const EXPERIMENTAL_TYPES : core:: ops:: Range < u64 > =
488
+ EXPERIMENTAL_OFFER_TYPES . start ..EXPERIMENTAL_INVOICE_REQUEST_TYPES . end ;
488
489
489
490
let mut bytes = Vec :: new ( ) ;
490
491
@@ -495,7 +496,7 @@ impl UnsignedBolt12Invoice {
495
496
record. write ( & mut bytes) . unwrap ( ) ;
496
497
}
497
498
498
- let ( _, _, _, invoice_tlv_stream, _) = contents. as_tlv_stream ( ) ;
499
+ let ( _, _, _, invoice_tlv_stream, _, _ ) = contents. as_tlv_stream ( ) ;
499
500
invoice_tlv_stream. write ( & mut bytes) . unwrap ( ) ;
500
501
501
502
let mut experimental_bytes = Vec :: new ( ) ;
@@ -860,14 +861,15 @@ impl Bolt12Invoice {
860
861
pub ( crate ) fn as_tlv_stream ( & self ) -> FullInvoiceTlvStreamRef {
861
862
let (
862
863
payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream, invoice_tlv_stream,
863
- experimental_offer_tlv_stream,
864
+ experimental_offer_tlv_stream, experimental_invoice_request_tlv_stream ,
864
865
) = self . contents . as_tlv_stream ( ) ;
865
866
let signature_tlv_stream = SignatureTlvStreamRef {
866
867
signature : Some ( & self . signature ) ,
867
868
} ;
868
869
(
869
870
payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream, invoice_tlv_stream,
870
871
signature_tlv_stream, experimental_offer_tlv_stream,
872
+ experimental_invoice_request_tlv_stream,
871
873
)
872
874
}
873
875
@@ -1101,7 +1103,8 @@ impl InvoiceContents {
1101
1103
& self , bytes : & [ u8 ] , metadata : & Metadata , key : & ExpandedKey , iv_bytes : & [ u8 ; IV_LEN ] ,
1102
1104
secp_ctx : & Secp256k1 < T > ,
1103
1105
) -> Result < PaymentId , ( ) > {
1104
- const EXPERIMENTAL_TYPES : core:: ops:: Range < u64 > = EXPERIMENTAL_OFFER_TYPES ;
1106
+ const EXPERIMENTAL_TYPES : core:: ops:: Range < u64 > =
1107
+ EXPERIMENTAL_OFFER_TYPES . start ..EXPERIMENTAL_INVOICE_REQUEST_TYPES . end ;
1105
1108
1106
1109
let offer_records = TlvStream :: new ( bytes) . range ( OFFER_TYPES ) ;
1107
1110
let invreq_records = TlvStream :: new ( bytes) . range ( INVOICE_REQUEST_TYPES ) . filter ( |record| {
@@ -1121,13 +1124,15 @@ impl InvoiceContents {
1121
1124
}
1122
1125
1123
1126
fn as_tlv_stream ( & self ) -> PartialInvoiceTlvStreamRef {
1124
- let ( payer, offer, invoice_request, experimental_offer) = match self {
1127
+ let (
1128
+ payer, offer, invoice_request, experimental_offer, experimental_invoice_request,
1129
+ ) = match self {
1125
1130
InvoiceContents :: ForOffer { invoice_request, .. } => invoice_request. as_tlv_stream ( ) ,
1126
1131
InvoiceContents :: ForRefund { refund, .. } => refund. as_tlv_stream ( ) ,
1127
1132
} ;
1128
1133
let invoice = self . fields ( ) . as_tlv_stream ( ) ;
1129
1134
1130
- ( payer, offer, invoice_request, invoice, experimental_offer)
1135
+ ( payer, offer, invoice_request, invoice, experimental_offer, experimental_invoice_request )
1131
1136
}
1132
1137
}
1133
1138
@@ -1230,12 +1235,12 @@ impl TryFrom<Vec<u8>> for UnsignedBolt12Invoice {
1230
1235
let ParsedMessage { mut bytes, tlv_stream } = invoice;
1231
1236
let (
1232
1237
payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream, invoice_tlv_stream,
1233
- experimental_offer_tlv_stream,
1238
+ experimental_offer_tlv_stream, experimental_invoice_request_tlv_stream ,
1234
1239
) = tlv_stream;
1235
1240
let contents = InvoiceContents :: try_from (
1236
1241
(
1237
1242
payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream, invoice_tlv_stream,
1238
- experimental_offer_tlv_stream,
1243
+ experimental_offer_tlv_stream, experimental_invoice_request_tlv_stream ,
1239
1244
)
1240
1245
) ?;
1241
1246
@@ -1337,7 +1342,7 @@ impl_writeable!(FallbackAddress, { version, program });
1337
1342
1338
1343
type FullInvoiceTlvStream =(
1339
1344
PayerTlvStream , OfferTlvStream , InvoiceRequestTlvStream , InvoiceTlvStream , SignatureTlvStream ,
1340
- ExperimentalOfferTlvStream ,
1345
+ ExperimentalOfferTlvStream , ExperimentalInvoiceRequestTlvStream ,
1341
1346
) ;
1342
1347
1343
1348
type FullInvoiceTlvStreamRef < ' a > = (
@@ -1347,6 +1352,7 @@ type FullInvoiceTlvStreamRef<'a> = (
1347
1352
InvoiceTlvStreamRef < ' a > ,
1348
1353
SignatureTlvStreamRef < ' a > ,
1349
1354
ExperimentalOfferTlvStreamRef ,
1355
+ ExperimentalInvoiceRequestTlvStreamRef ,
1350
1356
) ;
1351
1357
1352
1358
impl SeekReadable for FullInvoiceTlvStream {
@@ -1357,14 +1363,20 @@ impl SeekReadable for FullInvoiceTlvStream {
1357
1363
let invoice = SeekReadable :: read ( r) ?;
1358
1364
let signature = SeekReadable :: read ( r) ?;
1359
1365
let experimental_offer = SeekReadable :: read ( r) ?;
1366
+ let experimental_invoice_request = SeekReadable :: read ( r) ?;
1360
1367
1361
- Ok ( ( payer, offer, invoice_request, invoice, signature, experimental_offer) )
1368
+ Ok (
1369
+ (
1370
+ payer, offer, invoice_request, invoice, signature, experimental_offer,
1371
+ experimental_invoice_request,
1372
+ )
1373
+ )
1362
1374
}
1363
1375
}
1364
1376
1365
1377
type PartialInvoiceTlvStream = (
1366
1378
PayerTlvStream , OfferTlvStream , InvoiceRequestTlvStream , InvoiceTlvStream ,
1367
- ExperimentalOfferTlvStream ,
1379
+ ExperimentalOfferTlvStream , ExperimentalInvoiceRequestTlvStream ,
1368
1380
) ;
1369
1381
1370
1382
type PartialInvoiceTlvStreamRef < ' a > = (
@@ -1373,6 +1385,7 @@ type PartialInvoiceTlvStreamRef<'a> = (
1373
1385
InvoiceRequestTlvStreamRef < ' a > ,
1374
1386
InvoiceTlvStreamRef < ' a > ,
1375
1387
ExperimentalOfferTlvStreamRef ,
1388
+ ExperimentalInvoiceRequestTlvStreamRef ,
1376
1389
) ;
1377
1390
1378
1391
impl SeekReadable for PartialInvoiceTlvStream {
@@ -1382,8 +1395,14 @@ impl SeekReadable for PartialInvoiceTlvStream {
1382
1395
let invoice_request = SeekReadable :: read ( r) ?;
1383
1396
let invoice = SeekReadable :: read ( r) ?;
1384
1397
let experimental_offer = SeekReadable :: read ( r) ?;
1398
+ let experimental_invoice_request = SeekReadable :: read ( r) ?;
1385
1399
1386
- Ok ( ( payer, offer, invoice_request, invoice, experimental_offer) )
1400
+ Ok (
1401
+ (
1402
+ payer, offer, invoice_request, invoice, experimental_offer,
1403
+ experimental_invoice_request,
1404
+ )
1405
+ )
1387
1406
}
1388
1407
}
1389
1408
@@ -1396,11 +1415,12 @@ impl TryFrom<ParsedMessage<FullInvoiceTlvStream>> for Bolt12Invoice {
1396
1415
payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream, invoice_tlv_stream,
1397
1416
SignatureTlvStream { signature } ,
1398
1417
experimental_offer_tlv_stream,
1418
+ experimental_invoice_request_tlv_stream,
1399
1419
) = tlv_stream;
1400
1420
let contents = InvoiceContents :: try_from (
1401
1421
(
1402
1422
payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream, invoice_tlv_stream,
1403
- experimental_offer_tlv_stream,
1423
+ experimental_offer_tlv_stream, experimental_invoice_request_tlv_stream ,
1404
1424
)
1405
1425
) ?;
1406
1426
@@ -1428,6 +1448,7 @@ impl TryFrom<PartialInvoiceTlvStream> for InvoiceContents {
1428
1448
features, node_id, message_paths,
1429
1449
} ,
1430
1450
experimental_offer_tlv_stream,
1451
+ experimental_invoice_request_tlv_stream,
1431
1452
) = tlv_stream;
1432
1453
1433
1454
if message_paths. is_some ( ) { return Err ( Bolt12SemanticError :: UnexpectedPaths ) }
@@ -1462,15 +1483,15 @@ impl TryFrom<PartialInvoiceTlvStream> for InvoiceContents {
1462
1483
let refund = RefundContents :: try_from (
1463
1484
(
1464
1485
payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream,
1465
- experimental_offer_tlv_stream,
1486
+ experimental_offer_tlv_stream, experimental_invoice_request_tlv_stream ,
1466
1487
)
1467
1488
) ?;
1468
1489
Ok ( InvoiceContents :: ForRefund { refund, fields } )
1469
1490
} else {
1470
1491
let invoice_request = InvoiceRequestContents :: try_from (
1471
1492
(
1472
1493
payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream,
1473
- experimental_offer_tlv_stream,
1494
+ experimental_offer_tlv_stream, experimental_invoice_request_tlv_stream ,
1474
1495
)
1475
1496
) ?;
1476
1497
Ok ( InvoiceContents :: ForOffer { invoice_request, fields } )
@@ -1537,7 +1558,7 @@ mod tests {
1537
1558
use crate :: ln:: features:: { Bolt12InvoiceFeatures , InvoiceRequestFeatures , OfferFeatures } ;
1538
1559
use crate :: ln:: inbound_payment:: ExpandedKey ;
1539
1560
use crate :: ln:: msgs:: DecodeError ;
1540
- use crate :: offers:: invoice_request:: InvoiceRequestTlvStreamRef ;
1561
+ use crate :: offers:: invoice_request:: { ExperimentalInvoiceRequestTlvStreamRef , InvoiceRequestTlvStreamRef } ;
1541
1562
use crate :: offers:: merkle:: { SignError , SignatureTlvStreamRef , TaggedHash , self } ;
1542
1563
use crate :: offers:: nonce:: Nonce ;
1543
1564
use crate :: offers:: offer:: { Amount , ExperimentalOfferTlvStreamRef , OfferTlvStreamRef , Quantity } ;
@@ -1711,6 +1732,7 @@ mod tests {
1711
1732
ExperimentalOfferTlvStreamRef {
1712
1733
experimental_foo: None ,
1713
1734
} ,
1735
+ ExperimentalInvoiceRequestTlvStreamRef { } ,
1714
1736
) ,
1715
1737
) ;
1716
1738
@@ -1807,6 +1829,7 @@ mod tests {
1807
1829
ExperimentalOfferTlvStreamRef {
1808
1830
experimental_foo: None ,
1809
1831
} ,
1832
+ ExperimentalInvoiceRequestTlvStreamRef { } ,
1810
1833
) ,
1811
1834
) ;
1812
1835
@@ -2005,7 +2028,7 @@ mod tests {
2005
2028
. relative_expiry ( one_hour. as_secs ( ) as u32 )
2006
2029
. build ( ) . unwrap ( )
2007
2030
. sign ( recipient_sign) . unwrap ( ) ;
2008
- let ( _, _, _, tlv_stream, _, _) = invoice. as_tlv_stream ( ) ;
2031
+ let ( _, _, _, tlv_stream, _, _, _ ) = invoice. as_tlv_stream ( ) ;
2009
2032
#[ cfg( feature = "std" ) ]
2010
2033
assert ! ( !invoice. is_expired( ) ) ;
2011
2034
assert_eq ! ( invoice. relative_expiry( ) , one_hour) ;
@@ -2021,7 +2044,7 @@ mod tests {
2021
2044
. relative_expiry ( one_hour. as_secs ( ) as u32 - 1 )
2022
2045
. build ( ) . unwrap ( )
2023
2046
. sign ( recipient_sign) . unwrap ( ) ;
2024
- let ( _, _, _, tlv_stream, _, _) = invoice. as_tlv_stream ( ) ;
2047
+ let ( _, _, _, tlv_stream, _, _, _ ) = invoice. as_tlv_stream ( ) ;
2025
2048
#[ cfg( feature = "std" ) ]
2026
2049
assert ! ( invoice. is_expired( ) ) ;
2027
2050
assert_eq ! ( invoice. relative_expiry( ) , one_hour - Duration :: from_secs( 1 ) ) ;
@@ -2040,7 +2063,7 @@ mod tests {
2040
2063
. respond_with_no_std ( payment_paths ( ) , payment_hash ( ) , now ( ) ) . unwrap ( )
2041
2064
. build ( ) . unwrap ( )
2042
2065
. sign ( recipient_sign) . unwrap ( ) ;
2043
- let ( _, _, _, tlv_stream, _, _) = invoice. as_tlv_stream ( ) ;
2066
+ let ( _, _, _, tlv_stream, _, _, _ ) = invoice. as_tlv_stream ( ) ;
2044
2067
assert_eq ! ( invoice. amount_msats( ) , 1001 ) ;
2045
2068
assert_eq ! ( tlv_stream. amount, Some ( 1001 ) ) ;
2046
2069
}
@@ -2058,7 +2081,7 @@ mod tests {
2058
2081
. respond_with_no_std ( payment_paths ( ) , payment_hash ( ) , now ( ) ) . unwrap ( )
2059
2082
. build ( ) . unwrap ( )
2060
2083
. sign ( recipient_sign) . unwrap ( ) ;
2061
- let ( _, _, _, tlv_stream, _, _) = invoice. as_tlv_stream ( ) ;
2084
+ let ( _, _, _, tlv_stream, _, _, _ ) = invoice. as_tlv_stream ( ) ;
2062
2085
assert_eq ! ( invoice. amount_msats( ) , 2000 ) ;
2063
2086
assert_eq ! ( tlv_stream. amount, Some ( 2000 ) ) ;
2064
2087
@@ -2096,7 +2119,7 @@ mod tests {
2096
2119
. fallback_v1_p2tr_tweaked ( & tweaked_pubkey)
2097
2120
. build ( ) . unwrap ( )
2098
2121
. sign ( recipient_sign) . unwrap ( ) ;
2099
- let ( _, _, _, tlv_stream, _, _) = invoice. as_tlv_stream ( ) ;
2122
+ let ( _, _, _, tlv_stream, _, _, _ ) = invoice. as_tlv_stream ( ) ;
2100
2123
assert_eq ! (
2101
2124
invoice. fallbacks( ) ,
2102
2125
vec![
@@ -2139,7 +2162,7 @@ mod tests {
2139
2162
. allow_mpp ( )
2140
2163
. build ( ) . unwrap ( )
2141
2164
. sign ( recipient_sign) . unwrap ( ) ;
2142
- let ( _, _, _, tlv_stream, _, _) = invoice. as_tlv_stream ( ) ;
2165
+ let ( _, _, _, tlv_stream, _, _, _ ) = invoice. as_tlv_stream ( ) ;
2143
2166
assert_eq ! ( invoice. invoice_features( ) , & features) ;
2144
2167
assert_eq ! ( tlv_stream. features, Some ( & features) ) ;
2145
2168
}
0 commit comments