@@ -176,6 +176,18 @@ pub enum PaymentKind {
176
176
/// [`LdkChannelConfig::accept_underpaying_htlcs`]: lightning::util::config::ChannelConfig::accept_underpaying_htlcs
177
177
lsp_fee_limits : LSPFeeLimits ,
178
178
} ,
179
+ /// A [BOLT 12] payment.
180
+ ///
181
+ /// [BOLT 12]: https://github.com/lightning/bolts/blob/master/12-offer-encoding.md
182
+ // TODO: Bolt12 { offer: Option<Offer>, refund: Option<Refund> },
183
+ Bolt12 {
184
+ /// The payment hash, i.e., the hash of the `preimage`.
185
+ hash : Option < PaymentHash > ,
186
+ /// The pre-image used by the payment.
187
+ preimage : Option < PaymentPreimage > ,
188
+ /// The secret used by the payment.
189
+ secret : Option < PaymentSecret > ,
190
+ } ,
179
191
/// A spontaneous ("keysend") payment.
180
192
Spontaneous {
181
193
/// The payment hash, i.e., the hash of the `preimage`.
@@ -198,6 +210,11 @@ impl_writeable_tlv_based_enum!(PaymentKind,
198
210
( 4 , secret, option) ,
199
211
( 6 , lsp_fee_limits, required) ,
200
212
} ,
213
+ ( 6 , Bolt12 ) => {
214
+ ( 0 , hash, option) ,
215
+ ( 2 , preimage, option) ,
216
+ ( 4 , secret, option) ,
217
+ } ,
201
218
( 8 , Spontaneous ) => {
202
219
( 0 , hash, required) ,
203
220
( 2 , preimage, option) ,
@@ -227,6 +244,7 @@ impl_writeable_tlv_based!(LSPFeeLimits, {
227
244
#[ derive( Clone , Debug , PartialEq , Eq ) ]
228
245
pub ( crate ) struct PaymentDetailsUpdate {
229
246
pub id : PaymentId ,
247
+ pub hash : Option < Option < PaymentHash > > ,
230
248
pub preimage : Option < Option < PaymentPreimage > > ,
231
249
pub secret : Option < Option < PaymentSecret > > ,
232
250
pub amount_msat : Option < Option < u64 > > ,
@@ -236,7 +254,15 @@ pub(crate) struct PaymentDetailsUpdate {
236
254
237
255
impl PaymentDetailsUpdate {
238
256
pub fn new ( id : PaymentId ) -> Self {
239
- Self { id, preimage : None , secret : None , amount_msat : None , direction : None , status : None }
257
+ Self {
258
+ id,
259
+ hash : None ,
260
+ preimage : None ,
261
+ secret : None ,
262
+ amount_msat : None ,
263
+ direction : None ,
264
+ status : None ,
265
+ }
240
266
}
241
267
}
242
268
@@ -299,10 +325,17 @@ where
299
325
let mut locked_payments = self . payments . lock ( ) . unwrap ( ) ;
300
326
301
327
if let Some ( payment) = locked_payments. get_mut ( & update. id ) {
328
+ if let Some ( hash_opt) = update. hash {
329
+ match payment. kind {
330
+ PaymentKind :: Bolt12 { ref mut hash, .. } => * hash = hash_opt,
331
+ _ => { } ,
332
+ }
333
+ }
302
334
if let Some ( preimage_opt) = update. preimage {
303
335
match payment. kind {
304
336
PaymentKind :: Bolt11 { ref mut preimage, .. } => * preimage = preimage_opt,
305
337
PaymentKind :: Bolt11Jit { ref mut preimage, .. } => * preimage = preimage_opt,
338
+ PaymentKind :: Bolt12 { ref mut preimage, .. } => * preimage = preimage_opt,
306
339
PaymentKind :: Spontaneous { ref mut preimage, .. } => * preimage = preimage_opt,
307
340
_ => { } ,
308
341
}
@@ -312,6 +345,7 @@ where
312
345
match payment. kind {
313
346
PaymentKind :: Bolt11 { ref mut secret, .. } => * secret = secret_opt,
314
347
PaymentKind :: Bolt11Jit { ref mut secret, .. } => * secret = secret_opt,
348
+ PaymentKind :: Bolt12 { ref mut secret, .. } => * secret = secret_opt,
315
349
_ => { } ,
316
350
}
317
351
}
0 commit comments