@@ -159,7 +159,7 @@ pub struct PaymentInfo {
159159#[ derive( Clone , Debug , PartialEq , Eq , Deserialize , Serialize ) ]
160160pub struct Bolt11PaymentInfo {
161161 /// Indicates the current state of the payment.
162- pub state : Bolt11PaymentState ,
162+ pub state : PaymentState ,
163163 /// The datetime when the payment option expires.
164164 pub expires_at : chrono:: DateTime < Utc > ,
165165 /// The total fee the LSP will charge to open this channel in satoshi.
@@ -176,7 +176,7 @@ pub struct Bolt11PaymentInfo {
176176#[ derive( Clone , Debug , PartialEq , Eq , Deserialize , Serialize ) ]
177177pub struct OnchainPaymentInfo {
178178 /// Indicates the current state of the payment.
179- pub state : OnchainPaymentState ,
179+ pub state : PaymentState ,
180180 /// The datetime when the payment option expires.
181181 pub expires_at : chrono:: DateTime < Utc > ,
182182 /// The total fee the LSP will charge to open this channel in satoshi.
@@ -198,31 +198,19 @@ pub struct OnchainPaymentInfo {
198198 pub min_fee_for_0conf : FeeRate ,
199199}
200200
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.
218205#[ derive( Clone , Debug , PartialEq , Eq , Deserialize , Serialize ) ]
219206#[ serde( rename_all = "SCREAMING_SNAKE_CASE" ) ]
220- pub enum OnchainPaymentState {
207+ pub enum PaymentState {
221208 /// A payment is expected.
222209 ExpectPayment ,
223210 /// A sufficient payment has been received.
224211 Paid ,
225212 /// The payment has been refunded.
213+ #[ serde( alias = "CANCELLED" ) ]
226214 Refunded ,
227215}
228216
@@ -467,5 +455,13 @@ mod tests {
467455 "expires_at": "2012-04-23T18:25:43.511Z"
468456 }"# ;
469457 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 ) ;
470466 }
471467}
0 commit comments