@@ -1102,6 +1102,7 @@ impl InvoiceFields {
1102
1102
fallbacks : self . fallbacks . as_ref ( ) ,
1103
1103
features,
1104
1104
node_id : Some ( & self . signing_pubkey ) ,
1105
+ message_paths : None ,
1105
1106
}
1106
1107
}
1107
1108
}
@@ -1162,6 +1163,8 @@ tlv_stream!(InvoiceTlvStream, InvoiceTlvStreamRef, 160..240, {
1162
1163
( 172 , fallbacks: ( Vec <FallbackAddress >, WithoutLength ) ) ,
1163
1164
( 174 , features: ( Bolt12InvoiceFeatures , WithoutLength ) ) ,
1164
1165
( 176 , node_id: PublicKey ) ,
1166
+ // Only present in `StaticInvoice`s.
1167
+ ( 238 , message_paths: ( Vec <BlindedPath >, WithoutLength ) ) ,
1165
1168
} ) ;
1166
1169
1167
1170
pub ( super ) type BlindedPathIter < ' a > = core:: iter:: Map <
@@ -1299,10 +1302,12 @@ impl TryFrom<PartialInvoiceTlvStream> for InvoiceContents {
1299
1302
invoice_request_tlv_stream,
1300
1303
InvoiceTlvStream {
1301
1304
paths, blindedpay, created_at, relative_expiry, payment_hash, amount, fallbacks,
1302
- features, node_id,
1305
+ features, node_id, message_paths ,
1303
1306
} ,
1304
1307
) = tlv_stream;
1305
1308
1309
+ if message_paths. is_some ( ) { return Err ( Bolt12SemanticError :: UnexpectedPaths ) }
1310
+
1306
1311
let payment_paths = construct_payment_paths ( blindedpay, paths) ?;
1307
1312
1308
1313
let created_at = match created_at {
@@ -1568,6 +1573,7 @@ mod tests {
1568
1573
fallbacks: None ,
1569
1574
features: None ,
1570
1575
node_id: Some ( & recipient_pubkey( ) ) ,
1576
+ message_paths: None ,
1571
1577
} ,
1572
1578
SignatureTlvStreamRef { signature: Some ( & invoice. signature( ) ) } ,
1573
1579
) ,
@@ -1659,6 +1665,7 @@ mod tests {
1659
1665
fallbacks: None ,
1660
1666
features: None ,
1661
1667
node_id: Some ( & recipient_pubkey( ) ) ,
1668
+ message_paths: None ,
1662
1669
} ,
1663
1670
SignatureTlvStreamRef { signature: Some ( & invoice. signature( ) ) } ,
1664
1671
) ,
@@ -2429,4 +2436,35 @@ mod tests {
2429
2436
Err ( e) => assert_eq ! ( e, Bolt12ParseError :: Decode ( DecodeError :: InvalidValue ) ) ,
2430
2437
}
2431
2438
}
2439
+
2440
+ #[ test]
2441
+ fn fails_parsing_invoice_with_message_paths ( ) {
2442
+ let invoice = OfferBuilder :: new ( recipient_pubkey ( ) )
2443
+ . amount_msats ( 1000 )
2444
+ . build ( ) . unwrap ( )
2445
+ . request_invoice ( vec ! [ 1 ; 32 ] , payer_pubkey ( ) ) . unwrap ( )
2446
+ . build ( ) . unwrap ( )
2447
+ . sign ( payer_sign) . unwrap ( )
2448
+ . respond_with_no_std ( payment_paths ( ) , payment_hash ( ) , now ( ) ) . unwrap ( )
2449
+ . build ( ) . unwrap ( )
2450
+ . sign ( recipient_sign) . unwrap ( ) ;
2451
+
2452
+ let blinded_path = BlindedPath {
2453
+ introduction_node : IntroductionNode :: NodeId ( pubkey ( 40 ) ) ,
2454
+ blinding_point : pubkey ( 41 ) ,
2455
+ blinded_hops : vec ! [
2456
+ BlindedHop { blinded_node_id: pubkey( 42 ) , encrypted_payload: vec![ 0 ; 43 ] } ,
2457
+ BlindedHop { blinded_node_id: pubkey( 43 ) , encrypted_payload: vec![ 0 ; 44 ] } ,
2458
+ ] ,
2459
+ } ;
2460
+
2461
+ let mut tlv_stream = invoice. as_tlv_stream ( ) ;
2462
+ let message_paths = vec ! [ blinded_path] ;
2463
+ tlv_stream. 3 . message_paths = Some ( & message_paths) ;
2464
+
2465
+ match Bolt12Invoice :: try_from ( tlv_stream. to_bytes ( ) ) {
2466
+ Ok ( _) => panic ! ( "expected error" ) ,
2467
+ Err ( e) => assert_eq ! ( e, Bolt12ParseError :: InvalidSemantics ( Bolt12SemanticError :: UnexpectedPaths ) ) ,
2468
+ }
2469
+ }
2432
2470
}
0 commit comments