@@ -44,14 +44,8 @@ pub struct OptionsSupported {
44
44
pub min_required_channel_confirmations : u16 ,
45
45
/// The smallest number of blocks in which the LSP can confirm the funding transaction.
46
46
pub min_funding_confirms_within_blocks : u16 ,
47
- /// The minimum number of block confirmations before the LSP accepts an on-chain payment as confirmed.
48
- pub min_onchain_payment_confirmations : Option < u16 > ,
49
47
/// Indicates if the LSP supports zero reserve.
50
48
pub supports_zero_channel_reserve : bool ,
51
- /// Indicates the minimum amount of satoshi that is required for the LSP to accept a payment
52
- /// on-chain.
53
- #[ serde( with = "string_amount_option" ) ]
54
- pub min_onchain_payment_size_sat : Option < u64 > ,
55
49
/// The maximum number of blocks a channel can be leased for.
56
50
pub max_channel_expiry_blocks : u32 ,
57
51
/// The minimum number of satoshi that the client MUST request.
@@ -78,6 +72,7 @@ pub struct OptionsSupported {
78
72
#[ derive( Clone , Debug , PartialEq , Eq , Deserialize , Serialize ) ]
79
73
pub struct GetInfoResponse {
80
74
/// All options supported by the LSP.
75
+ #[ serde( flatten) ]
81
76
pub options : OptionsSupported ,
82
77
}
83
78
@@ -128,8 +123,6 @@ pub struct CreateOrderResponse {
128
123
pub order : OrderParams ,
129
124
/// The datetime when the order was created
130
125
pub created_at : chrono:: DateTime < Utc > ,
131
- /// The datetime when the order expires.
132
- pub expires_at : chrono:: DateTime < Utc > ,
133
126
/// The current state of the order.
134
127
pub order_state : OrderState ,
135
128
/// Contains details about how to pay for the order.
@@ -153,34 +146,58 @@ pub enum OrderState {
153
146
/// Details regarding how to pay for an order.
154
147
#[ derive( Clone , Debug , PartialEq , Eq , Deserialize , Serialize ) ]
155
148
pub struct PaymentInfo {
149
+ /// A Lightning payment using BOLT 11.
150
+ pub bolt11 : Option < Bolt11PaymentInfo > ,
151
+ /// An onchain payment.
152
+ pub onchain : Option < OnchainPaymentInfo > ,
153
+ }
154
+
155
+ /// A Lightning payment using BOLT 11.
156
+ #[ derive( Clone , Debug , PartialEq , Eq , Deserialize , Serialize ) ]
157
+ pub struct Bolt11PaymentInfo {
156
158
/// Indicates the current state of the payment.
157
- pub state : PaymentState ,
159
+ pub state : Bolt11PaymentState ,
160
+ /// The datetime when the payment option expires.
161
+ pub expires_at : chrono:: DateTime < Utc > ,
158
162
/// The total fee the LSP will charge to open this channel in satoshi.
159
163
#[ serde( with = "string_amount" ) ]
160
164
pub fee_total_sat : u64 ,
161
- /// What the client needs to pay in total to open the requested channel.
165
+ /// The amount the client needs to pay to have the requested channel openend .
162
166
#[ serde( with = "string_amount" ) ]
163
167
pub order_total_sat : u64 ,
164
168
/// A BOLT11 invoice the client can pay to have to channel opened.
165
- pub bolt11_invoice : Bolt11Invoice ,
169
+ pub invoice : Bolt11Invoice ,
170
+ }
171
+
172
+ /// An onchain payment.
173
+ #[ derive( Clone , Debug , PartialEq , Eq , Deserialize , Serialize ) ]
174
+ pub struct OnchainPaymentInfo {
175
+ /// Indicates the current state of the payment.
176
+ pub state : OnchainPaymentState ,
177
+ /// The datetime when the payment option expires.
178
+ pub expires_at : chrono:: DateTime < Utc > ,
179
+ /// The total fee the LSP will charge to open this channel in satoshi.
180
+ #[ serde( with = "string_amount" ) ]
181
+ pub fee_total_sat : u64 ,
182
+ /// The amount the client needs to pay to have the requested channel openend.
183
+ #[ serde( with = "string_amount" ) ]
184
+ pub order_total_sat : u64 ,
166
185
/// An on-chain address the client can send [`Self::order_total_sat`] to to have the channel
167
186
/// opened.
168
- pub onchain_address : Address < NetworkUnchecked > ,
187
+ pub address : Address < NetworkUnchecked > ,
169
188
/// The minimum number of block confirmations that are required for the on-chain payment to be
170
189
/// considered confirmed.
171
190
pub min_onchain_payment_confirmations : Option < u16 > ,
172
191
/// The minimum fee rate for the on-chain payment in case the client wants the payment to be
173
192
/// confirmed without a confirmation.
174
193
#[ serde( with = "u32_fee_rate" ) ]
175
194
pub min_fee_for_0conf : FeeRate ,
176
- /// Details regarding a detected on-chain payment.
177
- pub onchain_payment : Option < OnchainPayment > ,
178
195
}
179
196
180
- /// The state of an [`PaymentInfo`] .
197
+ /// The state of a BOLT 11 payment .
181
198
#[ derive( Clone , Debug , PartialEq , Eq , Deserialize , Serialize ) ]
182
199
#[ serde( rename_all = "SCREAMING_SNAKE_CASE" ) ]
183
- pub enum PaymentState {
200
+ pub enum Bolt11PaymentState {
184
201
/// A payment is expected.
185
202
ExpectPayment ,
186
203
/// A Lighting payment has arrived, but the preimage has not been released yet.
@@ -189,6 +206,20 @@ pub enum PaymentState {
189
206
Paid ,
190
207
/// The payment has been refunded.
191
208
Refunded ,
209
+ /// The payment has been cancelled.
210
+ Cancelled ,
211
+ }
212
+
213
+ /// The state of an onchain payment.
214
+ #[ derive( Clone , Debug , PartialEq , Eq , Deserialize , Serialize ) ]
215
+ #[ serde( rename_all = "SCREAMING_SNAKE_CASE" ) ]
216
+ pub enum OnchainPaymentState {
217
+ /// A payment is expected.
218
+ ExpectPayment ,
219
+ /// A sufficient payment has been received.
220
+ Paid ,
221
+ /// The payment has been refunded.
222
+ Refunded ,
192
223
}
193
224
194
225
/// Details regarding a detected on-chain payment.
@@ -288,9 +319,7 @@ mod tests {
288
319
fn options_supported_serialization ( ) {
289
320
let min_required_channel_confirmations = 0 ;
290
321
let min_funding_confirms_within_blocks = 6 ;
291
- let min_onchain_payment_confirmations = Some ( 6 ) ;
292
322
let supports_zero_channel_reserve = true ;
293
- let min_onchain_payment_size_sat = Some ( 100_000 ) ;
294
323
let max_channel_expiry_blocks = 144 ;
295
324
let min_initial_client_balance_sat = 10_000_000 ;
296
325
let max_initial_client_balance_sat = 100_000_000 ;
@@ -302,9 +331,7 @@ mod tests {
302
331
let options_supported = OptionsSupported {
303
332
min_required_channel_confirmations,
304
333
min_funding_confirms_within_blocks,
305
- min_onchain_payment_confirmations,
306
334
supports_zero_channel_reserve,
307
- min_onchain_payment_size_sat,
308
335
max_channel_expiry_blocks,
309
336
min_initial_client_balance_sat,
310
337
max_initial_client_balance_sat,
@@ -314,7 +341,7 @@ mod tests {
314
341
max_channel_balance_sat,
315
342
} ;
316
343
317
- let json_str = r#"{"max_channel_balance_sat":"100000000","max_channel_expiry_blocks":144,"max_initial_client_balance_sat":"100000000","max_initial_lsp_balance_sat":"100000000","min_channel_balance_sat":"100000","min_funding_confirms_within_blocks":6,"min_initial_client_balance_sat":"10000000","min_initial_lsp_balance_sat":"100000","min_onchain_payment_confirmations":6,"min_onchain_payment_size_sat":"100000"," min_required_channel_confirmations":0,"supports_zero_channel_reserve":true}"# ;
344
+ let json_str = r#"{"max_channel_balance_sat":"100000000","max_channel_expiry_blocks":144,"max_initial_client_balance_sat":"100000000","max_initial_lsp_balance_sat":"100000000","min_channel_balance_sat":"100000","min_funding_confirms_within_blocks":6,"min_initial_client_balance_sat":"10000000","min_initial_lsp_balance_sat":"100000","min_required_channel_confirmations":0,"supports_zero_channel_reserve":true}"# ;
318
345
319
346
assert_eq ! ( json_str, serde_json:: json!( options_supported) . to_string( ) ) ;
320
347
assert_eq ! ( options_supported, serde_json:: from_str( json_str) . unwrap( ) ) ;
@@ -327,20 +354,16 @@ mod tests {
327
354
let _get_info_request: GetInfoRequest = serde_json:: from_str ( json_str) . unwrap ( ) ;
328
355
329
356
let json_str = r#"{
330
- "options": {
331
- "min_required_channel_confirmations": 0,
332
- "min_funding_confirms_within_blocks" : 6,
333
- "min_onchain_payment_confirmations": null,
334
- "supports_zero_channel_reserve": true,
335
- "min_onchain_payment_size_sat": null,
336
- "max_channel_expiry_blocks": 20160,
337
- "min_initial_client_balance_sat": "20000",
338
- "max_initial_client_balance_sat": "100000000",
339
- "min_initial_lsp_balance_sat": "0",
340
- "max_initial_lsp_balance_sat": "100000000",
341
- "min_channel_balance_sat": "50000",
342
- "max_channel_balance_sat": "100000000"
343
- }
357
+ "min_required_channel_confirmations": 0,
358
+ "min_funding_confirms_within_blocks" : 6,
359
+ "supports_zero_channel_reserve": true,
360
+ "max_channel_expiry_blocks": 20160,
361
+ "min_initial_client_balance_sat": "20000",
362
+ "max_initial_client_balance_sat": "100000000",
363
+ "min_initial_lsp_balance_sat": "0",
364
+ "max_initial_lsp_balance_sat": "100000000",
365
+ "min_channel_balance_sat": "50000",
366
+ "max_channel_balance_sat": "100000000"
344
367
}"# ;
345
368
let _get_info_response: GetInfoResponse = serde_json:: from_str ( json_str) . unwrap ( ) ;
346
369
@@ -356,6 +379,46 @@ mod tests {
356
379
}"# ;
357
380
let _create_order_request: CreateOrderRequest = serde_json:: from_str ( json_str) . unwrap ( ) ;
358
381
382
+ let json_str = r#"{
383
+ "state" : "EXPECT_PAYMENT",
384
+ "expires_at": "2025-01-01T00:00:00Z",
385
+ "fee_total_sat": "8888",
386
+ "order_total_sat": "200888",
387
+ "invoice": "lnbc252u1p3aht9ysp580g4633gd2x9lc5al0wd8wx0mpn9748jeyz46kqjrpxn52uhfpjqpp5qgf67tcqmuqehzgjm8mzya90h73deafvr4m5705l5u5l4r05l8cqdpud3h8ymm4w3jhytnpwpczqmt0de6xsmre2pkxzm3qydmkzdjrdev9s7zhgfaqxqyjw5qcqpjrzjqt6xptnd85lpqnu2lefq4cx070v5cdwzh2xlvmdgnu7gqp4zvkus5zapryqqx9qqqyqqqqqqqqqqqcsq9q9qyysgqen77vu8xqjelum24hgjpgfdgfgx4q0nehhalcmuggt32japhjuksq9jv6eksjfnppm4hrzsgyxt8y8xacxut9qv3fpyetz8t7tsymygq8yzn05"
388
+ }"# ;
389
+ let _bolt11_payment: Bolt11PaymentInfo = serde_json:: from_str ( json_str) . unwrap ( ) ;
390
+
391
+ let json_str = r#"{
392
+ "state": "EXPECT_PAYMENT",
393
+ "expires_at": "2025-01-01T00:00:00Z",
394
+ "fee_total_sat": "9999",
395
+ "order_total_sat": "200999",
396
+ "address": "bc1p5uvtaxzkjwvey2tfy49k5vtqfpjmrgm09cvs88ezyy8h2zv7jhas9tu4yr",
397
+ "min_onchain_payment_confirmations": 1,
398
+ "min_fee_for_0conf": 253
399
+ }"# ;
400
+ let _onchain_payment: OnchainPaymentInfo = serde_json:: from_str ( json_str) . unwrap ( ) ;
401
+
402
+ let json_str = r#"{
403
+ "bolt11": {
404
+ "state" : "EXPECT_PAYMENT",
405
+ "expires_at": "2025-01-01T00:00:00Z",
406
+ "fee_total_sat": "8888",
407
+ "order_total_sat": "200888",
408
+ "invoice": "lnbc252u1p3aht9ysp580g4633gd2x9lc5al0wd8wx0mpn9748jeyz46kqjrpxn52uhfpjqpp5qgf67tcqmuqehzgjm8mzya90h73deafvr4m5705l5u5l4r05l8cqdpud3h8ymm4w3jhytnpwpczqmt0de6xsmre2pkxzm3qydmkzdjrdev9s7zhgfaqxqyjw5qcqpjrzjqt6xptnd85lpqnu2lefq4cx070v5cdwzh2xlvmdgnu7gqp4zvkus5zapryqqx9qqqyqqqqqqqqqqqcsq9q9qyysgqen77vu8xqjelum24hgjpgfdgfgx4q0nehhalcmuggt32japhjuksq9jv6eksjfnppm4hrzsgyxt8y8xacxut9qv3fpyetz8t7tsymygq8yzn05"
409
+ },
410
+ "onchain": {
411
+ "state": "EXPECT_PAYMENT",
412
+ "expires_at": "2025-01-01T00:00:00Z",
413
+ "fee_total_sat": "9999",
414
+ "order_total_sat": "200999",
415
+ "address": "bc1p5uvtaxzkjwvey2tfy49k5vtqfpjmrgm09cvs88ezyy8h2zv7jhas9tu4yr",
416
+ "min_onchain_payment_confirmations": 1,
417
+ "min_fee_for_0conf": 253
418
+ }
419
+ }"# ;
420
+ let _payment: PaymentInfo = serde_json:: from_str ( json_str) . unwrap ( ) ;
421
+
359
422
let json_str = r#"{
360
423
"order_id": "bb4b5d0a-8334-49d8-9463-90a6d413af7c",
361
424
"lsp_balance_sat": "5000000",
@@ -365,18 +428,25 @@ mod tests {
365
428
"channel_expiry_blocks": 12,
366
429
"token": "",
367
430
"created_at": "2012-04-23T18:25:43.511Z",
368
- "expires_at": "2015-01-25T19:29:44.612Z",
369
431
"announce_channel": true,
370
432
"order_state": "CREATED",
371
433
"payment": {
372
- "state": "EXPECT_PAYMENT",
373
- "fee_total_sat": "8888",
374
- "order_total_sat": "2008888",
375
- "bolt11_invoice": "lnbc252u1p3aht9ysp580g4633gd2x9lc5al0wd8wx0mpn9748jeyz46kqjrpxn52uhfpjqpp5qgf67tcqmuqehzgjm8mzya90h73deafvr4m5705l5u5l4r05l8cqdpud3h8ymm4w3jhytnpwpczqmt0de6xsmre2pkxzm3qydmkzdjrdev9s7zhgfaqxqyjw5qcqpjrzjqt6xptnd85lpqnu2lefq4cx070v5cdwzh2xlvmdgnu7gqp4zvkus5zapryqqx9qqqyqqqqqqqqqqqcsq9q9qyysgqen77vu8xqjelum24hgjpgfdgfgx4q0nehhalcmuggt32japhjuksq9jv6eksjfnppm4hrzsgyxt8y8xacxut9qv3fpyetz8t7tsymygq8yzn05",
376
- "onchain_address": "bc1p5uvtaxzkjwvey2tfy49k5vtqfpjmrgm09cvs88ezyy8h2zv7jhas9tu4yr",
377
- "min_onchain_payment_confirmations": 0,
378
- "min_fee_for_0conf": 253,
379
- "onchain_payment": null
434
+ "bolt11": {
435
+ "state": "EXPECT_PAYMENT",
436
+ "expires_at": "2015-01-25T19:29:44.612Z",
437
+ "fee_total_sat": "8888",
438
+ "order_total_sat": "2008888",
439
+ "invoice" : "lnbc252u1p3aht9ysp580g4633gd2x9lc5al0wd8wx0mpn9748jeyz46kqjrpxn52uhfpjqpp5qgf67tcqmuqehzgjm8mzya90h73deafvr4m5705l5u5l4r05l8cqdpud3h8ymm4w3jhytnpwpczqmt0de6xsmre2pkxzm3qydmkzdjrdev9s7zhgfaqxqyjw5qcqpjrzjqt6xptnd85lpqnu2lefq4cx070v5cdwzh2xlvmdgnu7gqp4zvkus5zapryqqx9qqqyqqqqqqqqqqqcsq9q9qyysgqen77vu8xqjelum24hgjpgfdgfgx4q0nehhalcmuggt32japhjuksq9jv6eksjfnppm4hrzsgyxt8y8xacxut9qv3fpyetz8t7tsymygq8yzn05"
440
+ },
441
+ "onchain": {
442
+ "state": "EXPECT_PAYMENT",
443
+ "expires_at": "2015-01-25T19:29:44.612Z",
444
+ "fee_total_sat": "9999",
445
+ "order_total_sat": "2009999",
446
+ "address": "bc1qvmsy0f3yyes6z9jvddk8xqwznndmdwapvrc0xrmhd3vqj5rhdrrq6hz49h",
447
+ "min_fee_for_0conf": 253,
448
+ "min_onchain_payment_confirmations": 0
449
+ }
380
450
},
381
451
"channel": null
382
452
}"# ;
@@ -387,22 +457,6 @@ mod tests {
387
457
}"# ;
388
458
let _get_order_request: GetOrderRequest = serde_json:: from_str ( json_str) . unwrap ( ) ;
389
459
390
- let json_str = r#"{
391
- "state": "EXPECT_PAYMENT",
392
- "fee_total_sat": "8888",
393
- "order_total_sat": "2008888",
394
- "bolt11_invoice": "lnbc252u1p3aht9ysp580g4633gd2x9lc5al0wd8wx0mpn9748jeyz46kqjrpxn52uhfpjqpp5qgf67tcqmuqehzgjm8mzya90h73deafvr4m5705l5u5l4r05l8cqdpud3h8ymm4w3jhytnpwpczqmt0de6xsmre2pkxzm3qydmkzdjrdev9s7zhgfaqxqyjw5qcqpjrzjqt6xptnd85lpqnu2lefq4cx070v5cdwzh2xlvmdgnu7gqp4zvkus5zapryqqx9qqqyqqqqqqqqqqqcsq9q9qyysgqen77vu8xqjelum24hgjpgfdgfgx4q0nehhalcmuggt32japhjuksq9jv6eksjfnppm4hrzsgyxt8y8xacxut9qv3fpyetz8t7tsymygq8yzn05",
395
- "onchain_address": "bc1p5uvtaxzkjwvey2tfy49k5vtqfpjmrgm09cvs88ezyy8h2zv7jhas9tu4yr",
396
- "min_onchain_payment_confirmations": 1,
397
- "min_fee_for_0conf": 253,
398
- "onchain_payment": {
399
- "outpoint": "0301e0480b374b32851a9462db29dc19fe830a7f7d7a88b81612b9d42099c0ae:1",
400
- "sat": "1200",
401
- "confirmed": false
402
- }
403
- }"# ;
404
- let _payment: PaymentInfo = serde_json:: from_str ( json_str) . unwrap ( ) ;
405
-
406
460
let json_str = r#"{
407
461
"funded_at": "2012-04-23T18:25:43.511Z",
408
462
"funding_outpoint": "0301e0480b374b32851a9462db29dc19fe830a7f7d7a88b81612b9d42099c0ae:0",
0 commit comments