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