@@ -159,7 +159,7 @@ pub struct PaymentInfo {
159
159
#[ derive( Clone , Debug , PartialEq , Eq , Deserialize , Serialize ) ]
160
160
pub struct Bolt11PaymentInfo {
161
161
/// Indicates the current state of the payment.
162
- pub state : Bolt11PaymentState ,
162
+ pub state : PaymentState ,
163
163
/// The datetime when the payment option expires.
164
164
pub expires_at : chrono:: DateTime < Utc > ,
165
165
/// The total fee the LSP will charge to open this channel in satoshi.
@@ -176,7 +176,7 @@ pub struct Bolt11PaymentInfo {
176
176
#[ derive( Clone , Debug , PartialEq , Eq , Deserialize , Serialize ) ]
177
177
pub struct OnchainPaymentInfo {
178
178
/// Indicates the current state of the payment.
179
- pub state : OnchainPaymentState ,
179
+ pub state : PaymentState ,
180
180
/// The datetime when the payment option expires.
181
181
pub expires_at : chrono:: DateTime < Utc > ,
182
182
/// The total fee the LSP will charge to open this channel in satoshi.
@@ -203,31 +203,19 @@ pub struct OnchainPaymentInfo {
203
203
pub refund_onchain_address : Option < Address > ,
204
204
}
205
205
206
- /// The state of a BOLT 11 payment.
207
- #[ derive( Clone , Debug , PartialEq , Eq , Deserialize , Serialize ) ]
208
- #[ serde( rename_all = "SCREAMING_SNAKE_CASE" ) ]
209
- pub enum Bolt11PaymentState {
210
- /// A payment is expected.
211
- ExpectPayment ,
212
- /// A Lighting payment has arrived, but the preimage has not been released yet.
213
- Hold ,
214
- /// A sufficient payment has been received.
215
- Paid ,
216
- /// The payment has been refunded.
217
- Refunded ,
218
- /// The payment has been cancelled.
219
- Cancelled ,
220
- }
221
-
222
- /// The state of an onchain payment.
206
+ /// The state of a payment.
207
+ ///
208
+ /// *Note*: Previously, the spec also knew a `CANCELLED` state for BOLT11 payments, which has since
209
+ /// been deprecated and `REFUNDED` should be used instead.
223
210
#[ derive( Clone , Debug , PartialEq , Eq , Deserialize , Serialize ) ]
224
211
#[ serde( rename_all = "SCREAMING_SNAKE_CASE" ) ]
225
- pub enum OnchainPaymentState {
212
+ pub enum PaymentState {
226
213
/// A payment is expected.
227
214
ExpectPayment ,
228
215
/// A sufficient payment has been received.
229
216
Paid ,
230
217
/// The payment has been refunded.
218
+ #[ serde( alias = "CANCELLED" ) ]
231
219
Refunded ,
232
220
}
233
221
@@ -473,5 +461,13 @@ mod tests {
473
461
"expires_at": "2012-04-23T18:25:43.511Z"
474
462
}"# ;
475
463
let _channel: ChannelInfo = serde_json:: from_str ( json_str) . unwrap ( ) ;
464
+
465
+ let json_str = r#""CANCELLED""# ;
466
+ let payment_state: PaymentState = serde_json:: from_str ( json_str) . unwrap ( ) ;
467
+ assert_eq ! ( payment_state, PaymentState :: Refunded ) ;
468
+
469
+ let json_str = r#""REFUNDED""# ;
470
+ let payment_state: PaymentState = serde_json:: from_str ( json_str) . unwrap ( ) ;
471
+ assert_eq ! ( payment_state, PaymentState :: Refunded ) ;
476
472
}
477
473
}
0 commit comments