You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 6, 2025. It is now read-only.
/// Indicates how many satoshi the LSP will provide on their side.
93
+
#[serde(with = "string_amount")]
84
94
publsp_balance_sat:u64,
85
95
/// Indicates how many satoshi the client will provide on their side.
86
96
///
87
97
/// The client sends these funds to the LSP, who will push them back to the client upon opening
88
98
/// the channel.
99
+
#[serde(with = "string_amount")]
89
100
pubclient_balance_sat:u64,
90
101
/// The number of blocks the client wants to wait maximally for the channel to be confirmed.
91
102
pubconfirms_within_blocks:u32,
@@ -135,8 +146,10 @@ pub struct OrderPayment {
135
146
/// Indicates the current state of the payment.
136
147
pubstate:PaymentState,
137
148
/// The total fee the LSP will charge to open this channel in satoshi.
149
+
#[serde(with = "string_amount")]
138
150
pubfee_total_sat:u64,
139
151
/// What the client needs to pay in total to open the requested channel.
152
+
#[serde(with = "string_amount")]
140
153
puborder_total_sat:u64,
141
154
/// A BOLT11 invoice the client can pay to have to channel opened.
142
155
pubbolt11_invoice:String,
@@ -172,6 +185,7 @@ pub struct OnchainPayment {
172
185
/// The outpoint of the payment.
173
186
puboutpoint:String,
174
187
/// The amount of satoshi paid.
188
+
#[serde(with = "string_amount")]
175
189
pubsat:u64,
176
190
/// Indicates if the LSP regards the transaction as sufficiently confirmed.
177
191
pubconfirmed:bool,
@@ -287,3 +301,42 @@ impl From<LSPS1Message> for LSPSMessage {
287
301
LSPSMessage::LSPS1(message)
288
302
}
289
303
}
304
+
305
+
#[cfg(test)]
306
+
mod tests {
307
+
usesuper::*;
308
+
usecrate::alloc::string::ToString;
309
+
310
+
#[test]
311
+
fnoptions_supported_serialization(){
312
+
let min_channel_confirmations = 6;
313
+
let min_onchain_payment_confirmations = Some(6);
314
+
let supports_zero_channel_reserve = true;
315
+
let min_onchain_payment_size_sat = Some(100_000);
316
+
let max_channel_expiry_blocks = 144;
317
+
let min_initial_client_balance_sat = 10_000_000;
318
+
let max_initial_client_balance_sat = 100_000_000;
319
+
let min_initial_lsp_balance_sat = 100_000;
320
+
let max_initial_lsp_balance_sat = 100_000_000;
321
+
let min_channel_balance_sat = 100_000;
322
+
let max_channel_balance_sat = 100_000_000;
323
+
324
+
let options_supported = OptionsSupported{
325
+
min_channel_confirmations,
326
+
min_onchain_payment_confirmations,
327
+
supports_zero_channel_reserve,
328
+
min_onchain_payment_size_sat,
329
+
max_channel_expiry_blocks,
330
+
min_initial_client_balance_sat,
331
+
max_initial_client_balance_sat,
332
+
min_initial_lsp_balance_sat,
333
+
max_initial_lsp_balance_sat,
334
+
min_channel_balance_sat,
335
+
max_channel_balance_sat,
336
+
};
337
+
338
+
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_channel_confirmations":6,"min_initial_client_balance_sat":"10000000","min_initial_lsp_balance_sat":"100000","min_onchain_payment_confirmations":6,"min_onchain_payment_size_sat":"100000","supports_zero_channel_reserve":true}"#;
let valid_until = chrono::DateTime::parse_from_rfc3339("2023-05-20T08:30:45Z").unwrap();
346
+
let min_lifetime = 144;
347
+
let max_client_to_self_delay = 128;
348
+
let min_payment_size_msat = 1;
349
+
let max_payment_size_msat = 100_000_000;
350
+
351
+
let raw = RawOpeningFeeParams{
352
+
min_fee_msat,
353
+
proportional,
354
+
valid_until: valid_until.into(),
355
+
min_lifetime,
356
+
max_client_to_self_delay,
357
+
min_payment_size_msat,
358
+
max_payment_size_msat,
359
+
};
360
+
361
+
let promise_secret = [1u8;32];
362
+
363
+
let opening_fee_params = raw.into_opening_fee_params(&promise_secret);
364
+
let json_str = r#"{"max_client_to_self_delay":128,"max_payment_size_msat":"100000000","min_fee_msat":"100","min_lifetime":144,"min_payment_size_msat":"1","promise":"1134a5c51e3ba2e8f4259610d5e12c1bf4c50ddcd3f8af563e0a00d1fff41dea","proportional":21,"valid_until":"2023-05-20T08:30:45Z"}"#;
let json_str = r#"{"opening_fee_params":{"max_client_to_self_delay":128,"max_payment_size_msat":"100000000","min_fee_msat":"100","min_lifetime":144,"min_payment_size_msat":"1","promise":"1134a5c51e3ba2e8f4259610d5e12c1bf4c50ddcd3f8af563e0a00d1fff41dea","proportional":21,"valid_until":"2023-05-20T08:30:45Z"},"payment_size_msat":"1234"}"#;
let buy_request_variable = BuyRequest{ opening_fee_params, payment_size_msat };
377
+
378
+
// Check we skip serialization if payment_size_msat is None.
379
+
let json_str = r#"{"opening_fee_params":{"max_client_to_self_delay":128,"max_payment_size_msat":"100000000","min_fee_msat":"100","min_lifetime":144,"min_payment_size_msat":"1","promise":"1134a5c51e3ba2e8f4259610d5e12c1bf4c50ddcd3f8af563e0a00d1fff41dea","proportional":21,"valid_until":"2023-05-20T08:30:45Z"}}"#;
// Check we still deserialize correctly if payment_size_msat is 'null'.
384
+
let json_str = r#"{"opening_fee_params":{"max_client_to_self_delay":128,"max_payment_size_msat":"100000000","min_fee_msat":"100","min_lifetime":144,"min_payment_size_msat":"1","promise":"1134a5c51e3ba2e8f4259610d5e12c1bf4c50ddcd3f8af563e0a00d1fff41dea","proportional":21,"valid_until":"2023-05-20T08:30:45Z"},"payment_size_msat":null}"#;
0 commit comments