@@ -9,6 +9,7 @@ use crate::Error;
9
9
use lightning:: ln:: channelmanager:: PaymentId ;
10
10
use lightning:: ln:: msgs:: DecodeError ;
11
11
use lightning:: ln:: { PaymentHash , PaymentPreimage , PaymentSecret } ;
12
+ use lightning:: offers:: offer:: OfferId ;
12
13
use lightning:: util:: ser:: { Readable , Writeable } ;
13
14
use lightning:: {
14
15
_init_and_read_len_prefixed_tlv_fields, impl_writeable_tlv_based,
@@ -145,7 +146,6 @@ pub enum PaymentKind {
145
146
/// A [BOLT 11] payment.
146
147
///
147
148
/// [BOLT 11]: https://github.com/lightning/bolts/blob/master/11-payment-encoding.md
148
- // TODO: Bolt11 { invoice: Option<Bolt11Invoice> },
149
149
Bolt11 {
150
150
/// The payment hash, i.e., the hash of the `preimage`.
151
151
hash : PaymentHash ,
@@ -158,7 +158,6 @@ pub enum PaymentKind {
158
158
///
159
159
/// [BOLT 11]: https://github.com/lightning/bolts/blob/master/11-payment-encoding.md
160
160
/// [LSPS 2]: https://github.com/BitcoinAndLightningLayerSpecs/lsp/blob/main/LSPS2/README.md
161
- // TODO: Bolt11Jit { invoice: Option<Bolt11Invoice> },
162
161
Bolt11Jit {
163
162
/// The payment hash, i.e., the hash of the `preimage`.
164
163
hash : PaymentHash ,
@@ -176,11 +175,23 @@ pub enum PaymentKind {
176
175
/// [`LdkChannelConfig::accept_underpaying_htlcs`]: lightning::util::config::ChannelConfig::accept_underpaying_htlcs
177
176
lsp_fee_limits : LSPFeeLimits ,
178
177
} ,
179
- /// A [BOLT 12] payment.
178
+ /// A [BOLT 12] 'offer' payment, i.e., a payment in response to an offer .
180
179
///
181
180
/// [BOLT 12]: https://github.com/lightning/bolts/blob/master/12-offer-encoding.md
182
- // TODO: Bolt12 { offer: Option<Offer>, refund: Option<Refund> },
183
- Bolt12 {
181
+ Bolt12Offer {
182
+ /// The payment hash, i.e., the hash of the `preimage`.
183
+ hash : Option < PaymentHash > ,
184
+ /// The pre-image used by the payment.
185
+ preimage : Option < PaymentPreimage > ,
186
+ /// The secret used by the payment.
187
+ secret : Option < PaymentSecret > ,
188
+ /// The ID of the offer this payment is for.
189
+ offer_id : OfferId ,
190
+ } ,
191
+ /// A [BOLT 12] 'refund' payment, i.e., a payment without a prior offer.
192
+ ///
193
+ /// [BOLT 12]: https://github.com/lightning/bolts/blob/master/12-offer-encoding.md
194
+ Bolt12Refund {
184
195
/// The payment hash, i.e., the hash of the `preimage`.
185
196
hash : Option < PaymentHash > ,
186
197
/// The pre-image used by the payment.
@@ -210,14 +221,20 @@ impl_writeable_tlv_based_enum!(PaymentKind,
210
221
( 4 , secret, option) ,
211
222
( 6 , lsp_fee_limits, required) ,
212
223
} ,
213
- ( 6 , Bolt12 ) => {
224
+ ( 6 , Bolt12Offer ) => {
214
225
( 0 , hash, option) ,
215
226
( 2 , preimage, option) ,
216
227
( 4 , secret, option) ,
228
+ ( 6 , offer_id, required) ,
217
229
} ,
218
230
( 8 , Spontaneous ) => {
219
231
( 0 , hash, required) ,
220
232
( 2 , preimage, option) ,
233
+ } ,
234
+ ( 10 , Bolt12Refund ) => {
235
+ ( 0 , hash, option) ,
236
+ ( 2 , preimage, option) ,
237
+ ( 4 , secret, option) ,
221
238
} ;
222
239
) ;
223
240
@@ -327,15 +344,17 @@ where
327
344
if let Some ( payment) = locked_payments. get_mut ( & update. id ) {
328
345
if let Some ( hash_opt) = update. hash {
329
346
match payment. kind {
330
- PaymentKind :: Bolt12 { ref mut hash, .. } => * hash = hash_opt,
347
+ PaymentKind :: Bolt12Offer { ref mut hash, .. } => * hash = hash_opt,
348
+ PaymentKind :: Bolt12Refund { ref mut hash, .. } => * hash = hash_opt,
331
349
_ => { } ,
332
350
}
333
351
}
334
352
if let Some ( preimage_opt) = update. preimage {
335
353
match payment. kind {
336
354
PaymentKind :: Bolt11 { ref mut preimage, .. } => * preimage = preimage_opt,
337
355
PaymentKind :: Bolt11Jit { ref mut preimage, .. } => * preimage = preimage_opt,
338
- PaymentKind :: Bolt12 { ref mut preimage, .. } => * preimage = preimage_opt,
356
+ PaymentKind :: Bolt12Offer { ref mut preimage, .. } => * preimage = preimage_opt,
357
+ PaymentKind :: Bolt12Refund { ref mut preimage, .. } => * preimage = preimage_opt,
339
358
PaymentKind :: Spontaneous { ref mut preimage, .. } => * preimage = preimage_opt,
340
359
_ => { } ,
341
360
}
@@ -345,7 +364,8 @@ where
345
364
match payment. kind {
346
365
PaymentKind :: Bolt11 { ref mut secret, .. } => * secret = secret_opt,
347
366
PaymentKind :: Bolt11Jit { ref mut secret, .. } => * secret = secret_opt,
348
- PaymentKind :: Bolt12 { ref mut secret, .. } => * secret = secret_opt,
367
+ PaymentKind :: Bolt12Offer { ref mut secret, .. } => * secret = secret_opt,
368
+ PaymentKind :: Bolt12Refund { ref mut secret, .. } => * secret = secret_opt,
349
369
_ => { } ,
350
370
}
351
371
}
0 commit comments