@@ -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:: { EXPERIMENTAL_INVOICE_REQUEST_TYPES , 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 , SIGNATURE_TLV_RECORD_SIZE } ;
126
126
use crate :: offers:: nonce:: Nonce ;
127
127
use crate :: offers:: offer:: { Amount , EXPERIMENTAL_OFFER_TYPES , ExperimentalOfferTlvStream , ExperimentalOfferTlvStreamRef , OFFER_TYPES , OfferTlvStream , OfferTlvStreamRef , Quantity } ;
@@ -497,7 +497,7 @@ impl UnsignedBolt12Invoice {
497
497
const EXPERIMENTAL_TYPES : core:: ops:: Range < u64 > =
498
498
EXPERIMENTAL_OFFER_TYPES . start ..EXPERIMENTAL_INVOICE_REQUEST_TYPES . end ;
499
499
500
- let ( _, _, _, invoice_tlv_stream, _) = contents. as_tlv_stream ( ) ;
500
+ let ( _, _, _, invoice_tlv_stream, _, _ ) = contents. as_tlv_stream ( ) ;
501
501
502
502
// Allocate enough space for the invoice, which will include:
503
503
// - all TLV records from `invreq_bytes` except signatures,
@@ -903,14 +903,15 @@ impl Bolt12Invoice {
903
903
pub ( crate ) fn as_tlv_stream ( & self ) -> FullInvoiceTlvStreamRef {
904
904
let (
905
905
payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream, invoice_tlv_stream,
906
- experimental_offer_tlv_stream,
906
+ experimental_offer_tlv_stream, experimental_invoice_request_tlv_stream ,
907
907
) = self . contents . as_tlv_stream ( ) ;
908
908
let signature_tlv_stream = SignatureTlvStreamRef {
909
909
signature : Some ( & self . signature ) ,
910
910
} ;
911
911
(
912
912
payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream, invoice_tlv_stream,
913
913
signature_tlv_stream, experimental_offer_tlv_stream,
914
+ experimental_invoice_request_tlv_stream,
914
915
)
915
916
}
916
917
@@ -1172,13 +1173,15 @@ impl InvoiceContents {
1172
1173
}
1173
1174
1174
1175
fn as_tlv_stream ( & self ) -> PartialInvoiceTlvStreamRef {
1175
- let ( payer, offer, invoice_request, experimental_offer) = match self {
1176
+ let (
1177
+ payer, offer, invoice_request, experimental_offer, experimental_invoice_request,
1178
+ ) = match self {
1176
1179
InvoiceContents :: ForOffer { invoice_request, .. } => invoice_request. as_tlv_stream ( ) ,
1177
1180
InvoiceContents :: ForRefund { refund, .. } => refund. as_tlv_stream ( ) ,
1178
1181
} ;
1179
1182
let invoice = self . fields ( ) . as_tlv_stream ( ) ;
1180
1183
1181
- ( payer, offer, invoice_request, invoice, experimental_offer)
1184
+ ( payer, offer, invoice_request, invoice, experimental_offer, experimental_invoice_request )
1182
1185
}
1183
1186
}
1184
1187
@@ -1339,7 +1342,7 @@ impl_writeable!(FallbackAddress, { version, program });
1339
1342
1340
1343
type FullInvoiceTlvStream =(
1341
1344
PayerTlvStream , OfferTlvStream , InvoiceRequestTlvStream , InvoiceTlvStream , SignatureTlvStream ,
1342
- ExperimentalOfferTlvStream ,
1345
+ ExperimentalOfferTlvStream , ExperimentalInvoiceRequestTlvStream ,
1343
1346
) ;
1344
1347
1345
1348
type FullInvoiceTlvStreamRef < ' a > = (
@@ -1349,6 +1352,7 @@ type FullInvoiceTlvStreamRef<'a> = (
1349
1352
InvoiceTlvStreamRef < ' a > ,
1350
1353
SignatureTlvStreamRef < ' a > ,
1351
1354
ExperimentalOfferTlvStreamRef ,
1355
+ ExperimentalInvoiceRequestTlvStreamRef ,
1352
1356
) ;
1353
1357
1354
1358
impl CursorReadable for FullInvoiceTlvStream {
@@ -1359,14 +1363,20 @@ impl CursorReadable for FullInvoiceTlvStream {
1359
1363
let invoice = CursorReadable :: read ( r) ?;
1360
1364
let signature = CursorReadable :: read ( r) ?;
1361
1365
let experimental_offer = CursorReadable :: read ( r) ?;
1366
+ let experimental_invoice_request = CursorReadable :: read ( r) ?;
1362
1367
1363
- 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
+ )
1364
1374
}
1365
1375
}
1366
1376
1367
1377
type PartialInvoiceTlvStream = (
1368
1378
PayerTlvStream , OfferTlvStream , InvoiceRequestTlvStream , InvoiceTlvStream ,
1369
- ExperimentalOfferTlvStream ,
1379
+ ExperimentalOfferTlvStream , ExperimentalInvoiceRequestTlvStream ,
1370
1380
) ;
1371
1381
1372
1382
type PartialInvoiceTlvStreamRef < ' a > = (
@@ -1375,6 +1385,7 @@ type PartialInvoiceTlvStreamRef<'a> = (
1375
1385
InvoiceRequestTlvStreamRef < ' a > ,
1376
1386
InvoiceTlvStreamRef < ' a > ,
1377
1387
ExperimentalOfferTlvStreamRef ,
1388
+ ExperimentalInvoiceRequestTlvStreamRef ,
1378
1389
) ;
1379
1390
1380
1391
impl CursorReadable for PartialInvoiceTlvStream {
@@ -1384,8 +1395,14 @@ impl CursorReadable for PartialInvoiceTlvStream {
1384
1395
let invoice_request = CursorReadable :: read ( r) ?;
1385
1396
let invoice = CursorReadable :: read ( r) ?;
1386
1397
let experimental_offer = CursorReadable :: read ( r) ?;
1398
+ let experimental_invoice_request = CursorReadable :: read ( r) ?;
1387
1399
1388
- 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
+ )
1389
1406
}
1390
1407
}
1391
1408
@@ -1398,11 +1415,12 @@ impl TryFrom<ParsedMessage<FullInvoiceTlvStream>> for Bolt12Invoice {
1398
1415
payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream, invoice_tlv_stream,
1399
1416
SignatureTlvStream { signature } ,
1400
1417
experimental_offer_tlv_stream,
1418
+ experimental_invoice_request_tlv_stream,
1401
1419
) = tlv_stream;
1402
1420
let contents = InvoiceContents :: try_from (
1403
1421
(
1404
1422
payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream, invoice_tlv_stream,
1405
- experimental_offer_tlv_stream,
1423
+ experimental_offer_tlv_stream, experimental_invoice_request_tlv_stream ,
1406
1424
)
1407
1425
) ?;
1408
1426
@@ -1430,6 +1448,7 @@ impl TryFrom<PartialInvoiceTlvStream> for InvoiceContents {
1430
1448
features, node_id, message_paths,
1431
1449
} ,
1432
1450
experimental_offer_tlv_stream,
1451
+ experimental_invoice_request_tlv_stream,
1433
1452
) = tlv_stream;
1434
1453
1435
1454
if message_paths. is_some ( ) { return Err ( Bolt12SemanticError :: UnexpectedPaths ) }
@@ -1464,15 +1483,15 @@ impl TryFrom<PartialInvoiceTlvStream> for InvoiceContents {
1464
1483
let refund = RefundContents :: try_from (
1465
1484
(
1466
1485
payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream,
1467
- experimental_offer_tlv_stream,
1486
+ experimental_offer_tlv_stream, experimental_invoice_request_tlv_stream ,
1468
1487
)
1469
1488
) ?;
1470
1489
Ok ( InvoiceContents :: ForRefund { refund, fields } )
1471
1490
} else {
1472
1491
let invoice_request = InvoiceRequestContents :: try_from (
1473
1492
(
1474
1493
payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream,
1475
- experimental_offer_tlv_stream,
1494
+ experimental_offer_tlv_stream, experimental_invoice_request_tlv_stream ,
1476
1495
)
1477
1496
) ?;
1478
1497
Ok ( InvoiceContents :: ForOffer { invoice_request, fields } )
@@ -1545,7 +1564,7 @@ mod tests {
1545
1564
use crate :: ln:: features:: { Bolt12InvoiceFeatures , InvoiceRequestFeatures , OfferFeatures } ;
1546
1565
use crate :: ln:: inbound_payment:: ExpandedKey ;
1547
1566
use crate :: ln:: msgs:: DecodeError ;
1548
- use crate :: offers:: invoice_request:: InvoiceRequestTlvStreamRef ;
1567
+ use crate :: offers:: invoice_request:: { ExperimentalInvoiceRequestTlvStreamRef , InvoiceRequestTlvStreamRef } ;
1549
1568
use crate :: offers:: merkle:: { SignError , SignatureTlvStreamRef , TaggedHash , self } ;
1550
1569
use crate :: offers:: nonce:: Nonce ;
1551
1570
use crate :: offers:: offer:: { Amount , ExperimentalOfferTlvStreamRef , OfferTlvStreamRef , Quantity } ;
@@ -1719,6 +1738,7 @@ mod tests {
1719
1738
ExperimentalOfferTlvStreamRef {
1720
1739
experimental_foo: None ,
1721
1740
} ,
1741
+ ExperimentalInvoiceRequestTlvStreamRef { } ,
1722
1742
) ,
1723
1743
) ;
1724
1744
@@ -1815,6 +1835,7 @@ mod tests {
1815
1835
ExperimentalOfferTlvStreamRef {
1816
1836
experimental_foo: None ,
1817
1837
} ,
1838
+ ExperimentalInvoiceRequestTlvStreamRef { } ,
1818
1839
) ,
1819
1840
) ;
1820
1841
@@ -2011,7 +2032,7 @@ mod tests {
2011
2032
. relative_expiry ( one_hour. as_secs ( ) as u32 )
2012
2033
. build ( ) . unwrap ( )
2013
2034
. sign ( recipient_sign) . unwrap ( ) ;
2014
- let ( _, _, _, tlv_stream, _, _) = invoice. as_tlv_stream ( ) ;
2035
+ let ( _, _, _, tlv_stream, _, _, _ ) = invoice. as_tlv_stream ( ) ;
2015
2036
#[ cfg( feature = "std" ) ]
2016
2037
assert ! ( !invoice. is_expired( ) ) ;
2017
2038
assert_eq ! ( invoice. relative_expiry( ) , one_hour) ;
@@ -2027,7 +2048,7 @@ mod tests {
2027
2048
. relative_expiry ( one_hour. as_secs ( ) as u32 - 1 )
2028
2049
. build ( ) . unwrap ( )
2029
2050
. sign ( recipient_sign) . unwrap ( ) ;
2030
- let ( _, _, _, tlv_stream, _, _) = invoice. as_tlv_stream ( ) ;
2051
+ let ( _, _, _, tlv_stream, _, _, _ ) = invoice. as_tlv_stream ( ) ;
2031
2052
#[ cfg( feature = "std" ) ]
2032
2053
assert ! ( invoice. is_expired( ) ) ;
2033
2054
assert_eq ! ( invoice. relative_expiry( ) , one_hour - Duration :: from_secs( 1 ) ) ;
@@ -2046,7 +2067,7 @@ mod tests {
2046
2067
. respond_with_no_std ( payment_paths ( ) , payment_hash ( ) , now ( ) ) . unwrap ( )
2047
2068
. build ( ) . unwrap ( )
2048
2069
. sign ( recipient_sign) . unwrap ( ) ;
2049
- let ( _, _, _, tlv_stream, _, _) = invoice. as_tlv_stream ( ) ;
2070
+ let ( _, _, _, tlv_stream, _, _, _ ) = invoice. as_tlv_stream ( ) ;
2050
2071
assert_eq ! ( invoice. amount_msats( ) , 1001 ) ;
2051
2072
assert_eq ! ( tlv_stream. amount, Some ( 1001 ) ) ;
2052
2073
}
@@ -2064,7 +2085,7 @@ mod tests {
2064
2085
. respond_with_no_std ( payment_paths ( ) , payment_hash ( ) , now ( ) ) . unwrap ( )
2065
2086
. build ( ) . unwrap ( )
2066
2087
. sign ( recipient_sign) . unwrap ( ) ;
2067
- let ( _, _, _, tlv_stream, _, _) = invoice. as_tlv_stream ( ) ;
2088
+ let ( _, _, _, tlv_stream, _, _, _ ) = invoice. as_tlv_stream ( ) ;
2068
2089
assert_eq ! ( invoice. amount_msats( ) , 2000 ) ;
2069
2090
assert_eq ! ( tlv_stream. amount, Some ( 2000 ) ) ;
2070
2091
@@ -2102,7 +2123,7 @@ mod tests {
2102
2123
. fallback_v1_p2tr_tweaked ( & tweaked_pubkey)
2103
2124
. build ( ) . unwrap ( )
2104
2125
. sign ( recipient_sign) . unwrap ( ) ;
2105
- let ( _, _, _, tlv_stream, _, _) = invoice. as_tlv_stream ( ) ;
2126
+ let ( _, _, _, tlv_stream, _, _, _ ) = invoice. as_tlv_stream ( ) ;
2106
2127
assert_eq ! (
2107
2128
invoice. fallbacks( ) ,
2108
2129
vec![
@@ -2145,7 +2166,7 @@ mod tests {
2145
2166
. allow_mpp ( )
2146
2167
. build ( ) . unwrap ( )
2147
2168
. sign ( recipient_sign) . unwrap ( ) ;
2148
- let ( _, _, _, tlv_stream, _, _) = invoice. as_tlv_stream ( ) ;
2169
+ let ( _, _, _, tlv_stream, _, _, _ ) = invoice. as_tlv_stream ( ) ;
2149
2170
assert_eq ! ( invoice. invoice_features( ) , & features) ;
2150
2171
assert_eq ! ( tlv_stream. features, Some ( & features) ) ;
2151
2172
}
0 commit comments