@@ -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.
@@ -198,31 +198,19 @@ pub struct OnchainPaymentInfo {
198
198
pub min_fee_for_0conf : FeeRate ,
199
199
}
200
200
201
- /// The state of a BOLT 11 payment.
202
- #[ derive( Clone , Debug , PartialEq , Eq , Deserialize , Serialize ) ]
203
- #[ serde( rename_all = "SCREAMING_SNAKE_CASE" ) ]
204
- pub enum Bolt11PaymentState {
205
- /// A payment is expected.
206
- ExpectPayment ,
207
- /// A Lighting payment has arrived, but the preimage has not been released yet.
208
- Hold ,
209
- /// A sufficient payment has been received.
210
- Paid ,
211
- /// The payment has been refunded.
212
- Refunded ,
213
- /// The payment has been cancelled.
214
- Cancelled ,
215
- }
216
-
217
- /// The state of an onchain payment.
201
+ /// The state of a payment.
202
+ ///
203
+ /// *Note*: Previously, the spec also knew a `CANCELLED` state for BOLT11 payments, which has since
204
+ /// been deprecated and `REFUNDED` should be used instead.
218
205
#[ derive( Clone , Debug , PartialEq , Eq , Deserialize , Serialize ) ]
219
206
#[ serde( rename_all = "SCREAMING_SNAKE_CASE" ) ]
220
- pub enum OnchainPaymentState {
207
+ pub enum PaymentState {
221
208
/// A payment is expected.
222
209
ExpectPayment ,
223
210
/// A sufficient payment has been received.
224
211
Paid ,
225
212
/// The payment has been refunded.
213
+ #[ serde( alias = "CANCELLED" ) ]
226
214
Refunded ,
227
215
}
228
216
@@ -467,5 +455,13 @@ mod tests {
467
455
"expires_at": "2012-04-23T18:25:43.511Z"
468
456
}"# ;
469
457
let _channel: ChannelInfo = serde_json:: from_str ( json_str) . unwrap ( ) ;
458
+
459
+ let json_str = r#""CANCELLED""# ;
460
+ let payment_state: PaymentState = serde_json:: from_str ( json_str) . unwrap ( ) ;
461
+ assert_eq ! ( payment_state, PaymentState :: Refunded ) ;
462
+
463
+ let json_str = r#""REFUNDED""# ;
464
+ let payment_state: PaymentState = serde_json:: from_str ( json_str) . unwrap ( ) ;
465
+ assert_eq ! ( payment_state, PaymentState :: Refunded ) ;
470
466
}
471
467
}
0 commit comments