@@ -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 } ;
126
126
use crate :: offers:: nonce:: Nonce ;
127
127
use crate :: offers:: offer:: { Amount , EXPERIMENTAL_OFFER_TYPES , ExperimentalOfferTlvStream , ExperimentalOfferTlvStreamRef , OFFER_TYPES , OfferTlvStream , OfferTlvStreamRef , Quantity } ;
@@ -506,7 +506,7 @@ impl UnsignedBolt12Invoice {
506
506
record. write ( & mut bytes) . unwrap ( ) ;
507
507
}
508
508
509
- let ( _, _, _, invoice_tlv_stream, _) = contents. as_tlv_stream ( ) ;
509
+ let ( _, _, _, invoice_tlv_stream, _, _ ) = contents. as_tlv_stream ( ) ;
510
510
invoice_tlv_stream. write ( & mut bytes) . unwrap ( ) ;
511
511
512
512
let mut experimental_bytes = Vec :: new ( ) ;
@@ -871,14 +871,15 @@ impl Bolt12Invoice {
871
871
pub ( crate ) fn as_tlv_stream ( & self ) -> FullInvoiceTlvStreamRef {
872
872
let (
873
873
payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream, invoice_tlv_stream,
874
- experimental_offer_tlv_stream,
874
+ experimental_offer_tlv_stream, experimental_invoice_request_tlv_stream ,
875
875
) = self . contents . as_tlv_stream ( ) ;
876
876
let signature_tlv_stream = SignatureTlvStreamRef {
877
877
signature : Some ( & self . signature ) ,
878
878
} ;
879
879
(
880
880
payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream, invoice_tlv_stream,
881
881
signature_tlv_stream, experimental_offer_tlv_stream,
882
+ experimental_invoice_request_tlv_stream,
882
883
)
883
884
}
884
885
@@ -1133,13 +1134,15 @@ impl InvoiceContents {
1133
1134
}
1134
1135
1135
1136
fn as_tlv_stream ( & self ) -> PartialInvoiceTlvStreamRef {
1136
- let ( payer, offer, invoice_request, experimental_offer) = match self {
1137
+ let (
1138
+ payer, offer, invoice_request, experimental_offer, experimental_invoice_request,
1139
+ ) = match self {
1137
1140
InvoiceContents :: ForOffer { invoice_request, .. } => invoice_request. as_tlv_stream ( ) ,
1138
1141
InvoiceContents :: ForRefund { refund, .. } => refund. as_tlv_stream ( ) ,
1139
1142
} ;
1140
1143
let invoice = self . fields ( ) . as_tlv_stream ( ) ;
1141
1144
1142
- ( payer, offer, invoice_request, invoice, experimental_offer)
1145
+ ( payer, offer, invoice_request, invoice, experimental_offer, experimental_invoice_request )
1143
1146
}
1144
1147
}
1145
1148
@@ -1241,12 +1244,12 @@ impl TryFrom<Vec<u8>> for UnsignedBolt12Invoice {
1241
1244
let ParsedMessage { mut bytes, tlv_stream } = invoice;
1242
1245
let (
1243
1246
payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream, invoice_tlv_stream,
1244
- experimental_offer_tlv_stream,
1247
+ experimental_offer_tlv_stream, experimental_invoice_request_tlv_stream ,
1245
1248
) = tlv_stream;
1246
1249
let contents = InvoiceContents :: try_from (
1247
1250
(
1248
1251
payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream, invoice_tlv_stream,
1249
- experimental_offer_tlv_stream,
1252
+ experimental_offer_tlv_stream, experimental_invoice_request_tlv_stream ,
1250
1253
)
1251
1254
) ?;
1252
1255
@@ -1310,7 +1313,7 @@ impl_writeable!(FallbackAddress, { version, program });
1310
1313
1311
1314
type FullInvoiceTlvStream =(
1312
1315
PayerTlvStream , OfferTlvStream , InvoiceRequestTlvStream , InvoiceTlvStream , SignatureTlvStream ,
1313
- ExperimentalOfferTlvStream ,
1316
+ ExperimentalOfferTlvStream , ExperimentalInvoiceRequestTlvStream ,
1314
1317
) ;
1315
1318
1316
1319
type FullInvoiceTlvStreamRef < ' a > = (
@@ -1320,6 +1323,7 @@ type FullInvoiceTlvStreamRef<'a> = (
1320
1323
InvoiceTlvStreamRef < ' a > ,
1321
1324
SignatureTlvStreamRef < ' a > ,
1322
1325
ExperimentalOfferTlvStreamRef ,
1326
+ ExperimentalInvoiceRequestTlvStreamRef ,
1323
1327
) ;
1324
1328
1325
1329
impl CursorReadable for FullInvoiceTlvStream {
@@ -1330,14 +1334,20 @@ impl CursorReadable for FullInvoiceTlvStream {
1330
1334
let invoice = CursorReadable :: read ( r) ?;
1331
1335
let signature = CursorReadable :: read ( r) ?;
1332
1336
let experimental_offer = CursorReadable :: read ( r) ?;
1337
+ let experimental_invoice_request = CursorReadable :: read ( r) ?;
1333
1338
1334
- Ok ( ( payer, offer, invoice_request, invoice, signature, experimental_offer) )
1339
+ Ok (
1340
+ (
1341
+ payer, offer, invoice_request, invoice, signature, experimental_offer,
1342
+ experimental_invoice_request,
1343
+ )
1344
+ )
1335
1345
}
1336
1346
}
1337
1347
1338
1348
type PartialInvoiceTlvStream = (
1339
1349
PayerTlvStream , OfferTlvStream , InvoiceRequestTlvStream , InvoiceTlvStream ,
1340
- ExperimentalOfferTlvStream ,
1350
+ ExperimentalOfferTlvStream , ExperimentalInvoiceRequestTlvStream ,
1341
1351
) ;
1342
1352
1343
1353
type PartialInvoiceTlvStreamRef < ' a > = (
@@ -1346,6 +1356,7 @@ type PartialInvoiceTlvStreamRef<'a> = (
1346
1356
InvoiceRequestTlvStreamRef < ' a > ,
1347
1357
InvoiceTlvStreamRef < ' a > ,
1348
1358
ExperimentalOfferTlvStreamRef ,
1359
+ ExperimentalInvoiceRequestTlvStreamRef ,
1349
1360
) ;
1350
1361
1351
1362
impl CursorReadable for PartialInvoiceTlvStream {
@@ -1355,8 +1366,14 @@ impl CursorReadable for PartialInvoiceTlvStream {
1355
1366
let invoice_request = CursorReadable :: read ( r) ?;
1356
1367
let invoice = CursorReadable :: read ( r) ?;
1357
1368
let experimental_offer = CursorReadable :: read ( r) ?;
1369
+ let experimental_invoice_request = CursorReadable :: read ( r) ?;
1358
1370
1359
- Ok ( ( payer, offer, invoice_request, invoice, experimental_offer) )
1371
+ Ok (
1372
+ (
1373
+ payer, offer, invoice_request, invoice, experimental_offer,
1374
+ experimental_invoice_request,
1375
+ )
1376
+ )
1360
1377
}
1361
1378
}
1362
1379
@@ -1369,11 +1386,12 @@ impl TryFrom<ParsedMessage<FullInvoiceTlvStream>> for Bolt12Invoice {
1369
1386
payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream, invoice_tlv_stream,
1370
1387
SignatureTlvStream { signature } ,
1371
1388
experimental_offer_tlv_stream,
1389
+ experimental_invoice_request_tlv_stream,
1372
1390
) = tlv_stream;
1373
1391
let contents = InvoiceContents :: try_from (
1374
1392
(
1375
1393
payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream, invoice_tlv_stream,
1376
- experimental_offer_tlv_stream,
1394
+ experimental_offer_tlv_stream, experimental_invoice_request_tlv_stream ,
1377
1395
)
1378
1396
) ?;
1379
1397
@@ -1401,6 +1419,7 @@ impl TryFrom<PartialInvoiceTlvStream> for InvoiceContents {
1401
1419
features, node_id, message_paths,
1402
1420
} ,
1403
1421
experimental_offer_tlv_stream,
1422
+ experimental_invoice_request_tlv_stream,
1404
1423
) = tlv_stream;
1405
1424
1406
1425
if message_paths. is_some ( ) { return Err ( Bolt12SemanticError :: UnexpectedPaths ) }
@@ -1435,15 +1454,15 @@ impl TryFrom<PartialInvoiceTlvStream> for InvoiceContents {
1435
1454
let refund = RefundContents :: try_from (
1436
1455
(
1437
1456
payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream,
1438
- experimental_offer_tlv_stream,
1457
+ experimental_offer_tlv_stream, experimental_invoice_request_tlv_stream ,
1439
1458
)
1440
1459
) ?;
1441
1460
Ok ( InvoiceContents :: ForRefund { refund, fields } )
1442
1461
} else {
1443
1462
let invoice_request = InvoiceRequestContents :: try_from (
1444
1463
(
1445
1464
payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream,
1446
- experimental_offer_tlv_stream,
1465
+ experimental_offer_tlv_stream, experimental_invoice_request_tlv_stream ,
1447
1466
)
1448
1467
) ?;
1449
1468
Ok ( InvoiceContents :: ForOffer { invoice_request, fields } )
@@ -1516,7 +1535,7 @@ mod tests {
1516
1535
use crate :: ln:: features:: { Bolt12InvoiceFeatures , InvoiceRequestFeatures , OfferFeatures } ;
1517
1536
use crate :: ln:: inbound_payment:: ExpandedKey ;
1518
1537
use crate :: ln:: msgs:: DecodeError ;
1519
- use crate :: offers:: invoice_request:: InvoiceRequestTlvStreamRef ;
1538
+ use crate :: offers:: invoice_request:: { ExperimentalInvoiceRequestTlvStreamRef , InvoiceRequestTlvStreamRef } ;
1520
1539
use crate :: offers:: merkle:: { SignError , SignatureTlvStreamRef , TaggedHash , self } ;
1521
1540
use crate :: offers:: nonce:: Nonce ;
1522
1541
use crate :: offers:: offer:: { Amount , ExperimentalOfferTlvStreamRef , OfferTlvStreamRef , Quantity } ;
@@ -1690,6 +1709,7 @@ mod tests {
1690
1709
ExperimentalOfferTlvStreamRef {
1691
1710
experimental_foo: None ,
1692
1711
} ,
1712
+ ExperimentalInvoiceRequestTlvStreamRef { } ,
1693
1713
) ,
1694
1714
) ;
1695
1715
@@ -1786,6 +1806,7 @@ mod tests {
1786
1806
ExperimentalOfferTlvStreamRef {
1787
1807
experimental_foo: None ,
1788
1808
} ,
1809
+ ExperimentalInvoiceRequestTlvStreamRef { } ,
1789
1810
) ,
1790
1811
) ;
1791
1812
@@ -1982,7 +2003,7 @@ mod tests {
1982
2003
. relative_expiry ( one_hour. as_secs ( ) as u32 )
1983
2004
. build ( ) . unwrap ( )
1984
2005
. sign ( recipient_sign) . unwrap ( ) ;
1985
- let ( _, _, _, tlv_stream, _, _) = invoice. as_tlv_stream ( ) ;
2006
+ let ( _, _, _, tlv_stream, _, _, _ ) = invoice. as_tlv_stream ( ) ;
1986
2007
#[ cfg( feature = "std" ) ]
1987
2008
assert ! ( !invoice. is_expired( ) ) ;
1988
2009
assert_eq ! ( invoice. relative_expiry( ) , one_hour) ;
@@ -1998,7 +2019,7 @@ mod tests {
1998
2019
. relative_expiry ( one_hour. as_secs ( ) as u32 - 1 )
1999
2020
. build ( ) . unwrap ( )
2000
2021
. sign ( recipient_sign) . unwrap ( ) ;
2001
- let ( _, _, _, tlv_stream, _, _) = invoice. as_tlv_stream ( ) ;
2022
+ let ( _, _, _, tlv_stream, _, _, _ ) = invoice. as_tlv_stream ( ) ;
2002
2023
#[ cfg( feature = "std" ) ]
2003
2024
assert ! ( invoice. is_expired( ) ) ;
2004
2025
assert_eq ! ( invoice. relative_expiry( ) , one_hour - Duration :: from_secs( 1 ) ) ;
@@ -2017,7 +2038,7 @@ mod tests {
2017
2038
. respond_with_no_std ( payment_paths ( ) , payment_hash ( ) , now ( ) ) . unwrap ( )
2018
2039
. build ( ) . unwrap ( )
2019
2040
. sign ( recipient_sign) . unwrap ( ) ;
2020
- let ( _, _, _, tlv_stream, _, _) = invoice. as_tlv_stream ( ) ;
2041
+ let ( _, _, _, tlv_stream, _, _, _ ) = invoice. as_tlv_stream ( ) ;
2021
2042
assert_eq ! ( invoice. amount_msats( ) , 1001 ) ;
2022
2043
assert_eq ! ( tlv_stream. amount, Some ( 1001 ) ) ;
2023
2044
}
@@ -2035,7 +2056,7 @@ mod tests {
2035
2056
. respond_with_no_std ( payment_paths ( ) , payment_hash ( ) , now ( ) ) . unwrap ( )
2036
2057
. build ( ) . unwrap ( )
2037
2058
. sign ( recipient_sign) . unwrap ( ) ;
2038
- let ( _, _, _, tlv_stream, _, _) = invoice. as_tlv_stream ( ) ;
2059
+ let ( _, _, _, tlv_stream, _, _, _ ) = invoice. as_tlv_stream ( ) ;
2039
2060
assert_eq ! ( invoice. amount_msats( ) , 2000 ) ;
2040
2061
assert_eq ! ( tlv_stream. amount, Some ( 2000 ) ) ;
2041
2062
@@ -2073,7 +2094,7 @@ mod tests {
2073
2094
. fallback_v1_p2tr_tweaked ( & tweaked_pubkey)
2074
2095
. build ( ) . unwrap ( )
2075
2096
. sign ( recipient_sign) . unwrap ( ) ;
2076
- let ( _, _, _, tlv_stream, _, _) = invoice. as_tlv_stream ( ) ;
2097
+ let ( _, _, _, tlv_stream, _, _, _ ) = invoice. as_tlv_stream ( ) ;
2077
2098
assert_eq ! (
2078
2099
invoice. fallbacks( ) ,
2079
2100
vec![
@@ -2116,7 +2137,7 @@ mod tests {
2116
2137
. allow_mpp ( )
2117
2138
. build ( ) . unwrap ( )
2118
2139
. sign ( recipient_sign) . unwrap ( ) ;
2119
- let ( _, _, _, tlv_stream, _, _) = invoice. as_tlv_stream ( ) ;
2140
+ let ( _, _, _, tlv_stream, _, _, _ ) = invoice. as_tlv_stream ( ) ;
2120
2141
assert_eq ! ( invoice. invoice_features( ) , & features) ;
2121
2142
assert_eq ! ( tlv_stream. features, Some ( & features) ) ;
2122
2143
}
0 commit comments