@@ -44,6 +44,43 @@ pub(crate) struct OnionKeys {
44
44
pub ( crate ) mu : [ u8 ; 32 ] ,
45
45
}
46
46
47
+ /// Information which is provided, encrypted, to the payment recipient when sending HTLCs.
48
+ ///
49
+ /// This should generally be constructed with data communicated to us from the recipient (via a
50
+ /// BOLT11 or BOLT12 invoice).
51
+ #[ derive( Clone , Debug , PartialEq , Eq ) ]
52
+ pub ( super ) struct TrampolineEntryOnionFields {
53
+ /// The trampoline packet is the inner onion that is used in conjunction with trampoline routing
54
+ pub trampoline_packet : msgs:: TrampolineOnionPacket ,
55
+ /// The payment metadata serves a similar purpose as [`RecipientOnionFields::payment_secret`] but is of
56
+ /// arbitrary length. This gives recipients substantially more flexibility to receive
57
+ /// additional data.
58
+ ///
59
+ /// In LDK, while the [`RecipientOnionFields::payment_secret`] is fixed based on an internal authentication
60
+ /// scheme to authenticate received payments against expected payments and invoices, this field
61
+ /// is not used in LDK for received payments, and can be used to store arbitrary data in
62
+ /// invoices which will be received with the payment.
63
+ ///
64
+ /// Note that this field was added to the lightning specification more recently than
65
+ /// [`RecipientOnionFields::payment_secret`] and while nearly all lightning senders support secrets, metadata
66
+ /// may not be supported as universally.
67
+ pub payment_metadata : Option < Vec < u8 > > ,
68
+ /// See [`Self::custom_tlvs`] for more info.
69
+ pub ( super ) custom_tlvs : Vec < ( u64 , Vec < u8 > ) > ,
70
+ }
71
+
72
+ #[ derive( Clone , Debug , PartialEq , Eq ) ]
73
+ pub ( super ) enum RecipientOnion {
74
+ TrampolineEntry ( TrampolineEntryOnionFields ) ,
75
+ Final ( RecipientOnionFields ) ,
76
+ }
77
+
78
+ impl From < RecipientOnionFields > for RecipientOnion {
79
+ fn from ( fields : RecipientOnionFields ) -> Self {
80
+ Self :: Final ( fields)
81
+ }
82
+ }
83
+
47
84
#[ inline]
48
85
pub ( crate ) fn gen_rho_from_shared_secret ( shared_secret : & [ u8 ] ) -> [ u8 ; 32 ] {
49
86
assert_eq ! ( shared_secret. len( ) , 32 ) ;
0 commit comments