9
9
10
10
//! Data structures and methods for constructing [`BlindedPaymentPath`]s to send a payment over.
11
11
12
+ use bitcoin:: hashes:: hmac:: Hmac ;
13
+ use bitcoin:: hashes:: sha256:: Hash as Sha256 ;
12
14
use bitcoin:: secp256k1:: { self , PublicKey , Secp256k1 , SecretKey } ;
13
15
14
16
use crate :: blinded_path:: { BlindedHop , BlindedPath , IntroductionNode , NodeIdLookUp } ;
@@ -22,6 +24,7 @@ use crate::types::features::BlindedHopFeatures;
22
24
use crate :: ln:: msgs:: DecodeError ;
23
25
use crate :: ln:: onion_utils;
24
26
use crate :: offers:: invoice_request:: InvoiceRequestFields ;
27
+ use crate :: offers:: nonce:: Nonce ;
25
28
use crate :: offers:: offer:: OfferId ;
26
29
use crate :: routing:: gossip:: { NodeId , ReadOnlyNetworkGraph } ;
27
30
use crate :: sign:: { EntropySource , NodeSigner , Recipient } ;
@@ -260,6 +263,8 @@ pub struct ReceiveTlvs {
260
263
pub payment_constraints : PaymentConstraints ,
261
264
/// Context for the receiver of this payment.
262
265
pub payment_context : PaymentContext ,
266
+ /// An HMAC of `payment_context` along with a nonce used to construct it.
267
+ pub authentication : ( Hmac < Sha256 > , Nonce ) ,
263
268
}
264
269
265
270
/// Data to construct a [`BlindedHop`] for sending a payment over.
@@ -404,7 +409,8 @@ impl Writeable for ReceiveTlvs {
404
409
encode_tlv_stream ! ( w, {
405
410
( 12 , self . payment_constraints, required) ,
406
411
( 65536 , self . payment_secret, required) ,
407
- ( 65537 , self . payment_context, required)
412
+ ( 65537 , self . payment_context, required) ,
413
+ ( 65539 , self . authentication, required) ,
408
414
} ) ;
409
415
Ok ( ( ) )
410
416
}
@@ -432,6 +438,7 @@ impl Readable for BlindedPaymentTlvs {
432
438
( 14 , features, ( option, encoding: ( BlindedHopFeatures , WithoutLength ) ) ) ,
433
439
( 65536 , payment_secret, option) ,
434
440
( 65537 , payment_context, ( default_value, PaymentContext :: unknown( ) ) ) ,
441
+ ( 65539 , authentication, option) ,
435
442
} ) ;
436
443
let _padding: Option < utils:: Padding > = _padding;
437
444
@@ -452,6 +459,7 @@ impl Readable for BlindedPaymentTlvs {
452
459
payment_secret : payment_secret. ok_or ( DecodeError :: InvalidValue ) ?,
453
460
payment_constraints : payment_constraints. 0 . unwrap ( ) ,
454
461
payment_context : payment_context. 0 . unwrap ( ) ,
462
+ authentication : authentication. ok_or ( DecodeError :: InvalidValue ) ?,
455
463
} ) )
456
464
}
457
465
}
0 commit comments