Skip to content

Commit 67ef22e

Browse files
WIP
1 parent 3971d83 commit 67ef22e

File tree

7 files changed

+40
-36
lines changed

7 files changed

+40
-36
lines changed

lightning-background-processor/src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ impl<
230230
G,
231231
&'a (dyn UtxoLookup + Send + Sync),
232232
L,
233-
> where
233+
>
234+
where
234235
L::Target: Logger,
235236
{
236237
/// Initializes a new [`GossipSync::Rapid`] variant.
@@ -247,7 +248,8 @@ impl<'a, L: Deref>
247248
&'a NetworkGraph<L>,
248249
&'a (dyn UtxoLookup + Send + Sync),
249250
L,
250-
> where
251+
>
252+
where
251253
L::Target: Logger,
252254
{
253255
/// Initializes a new [`GossipSync::None`] variant.
@@ -1683,7 +1685,6 @@ mod tests {
16831685
None,
16841686
None,
16851687
None,
1686-
None,
16871688
));
16881689
let node = Node {
16891690
node: manager,

lightning-liquidity/src/lsps0/ser.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,6 @@ impl<'de, 'a> Visitor<'de> for LSPSMessageVisitor<'a> {
592592
.map_err(de::Error::custom)?;
593593
Ok(LSPSMessage::LSPS2(LSPS2Message::Request(id, LSPS2Request::Buy(request))))
594594
},
595-
// Add LSPS5 methods
596595
LSPSMethod::LSPS5SetWebhook => {
597596
let request = serde_json::from_value(params.unwrap_or(json!({})))
598597
.map_err(de::Error::custom)?;

lightning-liquidity/src/lsps5/client.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ use crate::utils::generate_request_id;
2525
use super::msgs::{LSPS5AppName, LSPS5Error, LSPS5WebhookUrl};
2626
use super::service::TimeProvider;
2727

28-
use alloc::collections::VecDeque;
29-
use alloc::string::String;
30-
3128
use bitcoin::secp256k1::PublicKey;
3229

3330
use lightning::ln::msgs::{ErrorAction, LightningError};
3431
use lightning::sign::EntropySource;
3532
use lightning::util::logger::Level;
3633
use lightning::util::message_signing;
3734

35+
use alloc::collections::VecDeque;
36+
use alloc::string::String;
37+
3838
use core::ops::Deref;
3939
use core::time::Duration;
4040

@@ -85,9 +85,9 @@ impl Default for LSPS5ClientConfig {
8585

8686
struct PeerState {
8787
pending_set_webhook_requests:
88-
HashMap<LSPSRequestId, (LSPS5AppName, LSPS5WebhookUrl, LSPSDateTime)>, // RequestId -> (app_name, webhook_url, timestamp)
89-
pending_list_webhooks_requests: HashMap<LSPSRequestId, LSPSDateTime>, // RequestId -> timestamp
90-
pending_remove_webhook_requests: HashMap<LSPSRequestId, (LSPS5AppName, LSPSDateTime)>, // RequestId -> (app_name, timestamp)
88+
HashMap<LSPSRequestId, (LSPS5AppName, LSPS5WebhookUrl, LSPSDateTime)>,
89+
pending_list_webhooks_requests: HashMap<LSPSRequestId, LSPSDateTime>,
90+
pending_remove_webhook_requests: HashMap<LSPSRequestId, (LSPS5AppName, LSPSDateTime)>,
9191
last_cleanup: Option<LSPSDateTime>,
9292
max_age_secs: Duration,
9393
time_provider: Arc<dyn TimeProvider>,
@@ -455,8 +455,8 @@ where
455455
let now =
456456
LSPSDateTime::new_from_duration_since_epoch(self.time_provider.duration_since_epoch());
457457
let diff = signature_timestamp.abs_diff(now);
458-
459-
if diff > 600 {
458+
let ten_minutes = 600;
459+
if diff > ten_minutes {
460460
return Err(LSPS5Error::InvalidTimestamp(signature_timestamp.to_rfc3339()));
461461
}
462462

lightning-liquidity/src/lsps5/event.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// You may not use this file except in accordance with one or both of these
88
// licenses.
99

10-
//! Events generated by the LSPS5 service and client
10+
//! Contains bLIP-55 / LSPS5 event types
1111
1212
use crate::lsps0::ser::LSPSDateTime;
1313
use crate::lsps0::ser::LSPSRequestId;

lightning-liquidity/src/lsps5/msgs.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,27 @@
99

1010
//! LSPS5 message formats for webhook registration
1111
12-
use core::fmt;
13-
use core::fmt::Display;
14-
use core::ops::Deref;
15-
1612
use crate::alloc::string::ToString;
1713
use crate::lsps0::ser::LSPSMessage;
1814
use crate::lsps0::ser::LSPSRequestId;
1915
use crate::lsps0::ser::LSPSResponseError;
20-
use alloc::string::String;
21-
use alloc::vec::Vec;
16+
17+
use super::url_utils::LSPSUrl;
18+
2219
use lightning_types::string::UntrustedString;
20+
2321
use serde::de::{self, Deserializer, MapAccess, Visitor};
2422
use serde::ser::SerializeMap;
2523
use serde::ser::SerializeStruct;
2624
use serde::Serializer;
2725
use serde::{Deserialize, Serialize};
2826

29-
use super::url_utils::LSPSUrl;
27+
use alloc::string::String;
28+
use alloc::vec::Vec;
29+
30+
use core::fmt;
31+
use core::fmt::Display;
32+
use core::ops::Deref;
3033

3134
/// Maximum allowed length for an `app_name` (in bytes).
3235
pub const MAX_APP_NAME_LENGTH: usize = 64;

lightning-liquidity/src/lsps5/service.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
//! Service implementation for LSPS5 webhook registration.
1111
12+
use crate::alloc::string::ToString;
1213
use crate::events::EventQueue;
1314
use crate::lsps0::ser::{LSPSDateTime, LSPSProtocolMessageHandler, LSPSRequestId};
1415
use crate::lsps5::msgs::{
@@ -17,17 +18,18 @@ use crate::lsps5::msgs::{
1718
};
1819
use crate::message_queue::MessageQueue;
1920
use crate::prelude::*;
20-
use core::ops::Deref;
21-
use core::time::Duration;
21+
use crate::sync::{Arc, Mutex};
2222

2323
use bitcoin::secp256k1::{PublicKey, SecretKey};
24+
2425
use lightning::ln::channelmanager::AChannelManager;
2526
use lightning::ln::msgs::{ErrorAction, LightningError};
2627
use lightning::util::logger::Level;
2728
use lightning::util::message_signing;
2829

29-
use crate::alloc::string::ToString;
30-
use crate::sync::{Arc, Mutex};
30+
use core::ops::Deref;
31+
use core::time::Duration;
32+
3133
use alloc::string::String;
3234
use alloc::vec::Vec;
3335

@@ -100,7 +102,7 @@ pub struct LSPS5ServiceConfig {
100102
/// - `lsps5.remove_webhook` → delete a named webhook or return [`app_name_not_found`]
101103
/// error, emitting [`LSPS5ServiceEvent::WebhookRemoved`].
102104
/// - Prune stale webhooks after a client has no open channels and no activity for at least
103-
/// [`MIN_WEBHOOK_RETENTION_DAYS`].
105+
/// [`MIN_WEBHOOK_RETENTION_DAYS`].
104106
/// - Rate-limit repeat notifications of the same method to a client by
105107
/// [`notification_cooldown_hours`].
106108
/// - Sign and enqueue outgoing webhook notifications:
@@ -518,11 +520,7 @@ where
518520
self.handle_set_webhook(*counterparty_node_id, request_id.clone(), params)
519521
},
520522
LSPS5Request::ListWebhooks(params) => {
521-
self.handle_list_webhooks(
522-
*counterparty_node_id,
523-
request_id.clone(),
524-
params
525-
)
523+
self.handle_list_webhooks(*counterparty_node_id, request_id.clone(), params)
526524
},
527525
LSPS5Request::RemoveWebhook(params) => self.handle_remove_webhook(
528526
*counterparty_node_id,
@@ -537,8 +535,11 @@ where
537535
false,
538536
"Service handler received LSPS5 response message. This should never happen."
539537
);
540-
let err = format!("Service handler received LSPS5 response message from node {:?}.
541-
This should never happen.", counterparty_node_id);
538+
let err = format!(
539+
"Service handler received LSPS5 response message from node {:?}.
540+
This should never happen.",
541+
counterparty_node_id
542+
);
542543
Err(LightningError { err, action: ErrorAction::IgnoreAndLog(Level::Info) })
543544
},
544545
}

lightning-liquidity/src/manager.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ use crate::lsps0::ser::{
1212
use crate::lsps0::service::LSPS0ServiceHandler;
1313
use crate::lsps5::client::{LSPS5ClientConfig, LSPS5ClientHandler};
1414
use crate::lsps5::msgs::LSPS5Message;
15-
use crate::lsps5::service::{
16-
DefaultTimeProvider, LSPS5ServiceConfig, LSPS5ServiceHandler, TimeProvider,
17-
};
15+
#[cfg(feature = "time")]
16+
use crate::lsps5::service::DefaultTimeProvider;
17+
use crate::lsps5::service::{LSPS5ServiceConfig, LSPS5ServiceHandler, TimeProvider};
1818
use crate::message_queue::MessageQueue;
1919

2020
use crate::lsps1::client::{LSPS1ClientConfig, LSPS1ClientHandler};
@@ -208,7 +208,7 @@ where {
208208
let mut supported_protocols = Vec::new();
209209

210210
let lsps2_client_handler = client_config.as_ref().and_then(|config| {
211-
config.lsps2_client_config.as_ref().map(|config| {
211+
config.lsps2_client_config.map(|config| {
212212
LSPS2ClientHandler::new(
213213
entropy_source.clone(),
214214
Arc::clone(&pending_messages),

0 commit comments

Comments
 (0)