Skip to content

Commit cf94e4f

Browse files
fixup: Use NodeSigner to sign notification instead of custom signing key
1 parent ec2d4f0 commit cf94e4f

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

lightning-liquidity/src/lsps5/service.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ use crate::prelude::hash_map::Entry;
2121
use crate::prelude::*;
2222
use crate::sync::{Arc, Mutex};
2323

24-
use bitcoin::secp256k1::{PublicKey, SecretKey};
24+
use bitcoin::secp256k1::PublicKey;
2525

2626
use lightning::ln::channelmanager::AChannelManager;
2727
use lightning::ln::msgs::{ErrorAction, LightningError};
28+
use lightning::sign::NodeSigner;
2829
use lightning::util::logger::Level;
29-
use lightning::util::message_signing;
3030

3131
use core::ops::Deref;
3232
use core::time::Duration;
@@ -81,8 +81,6 @@ impl TimeProvider for DefaultTimeProvider {
8181
pub struct LSPS5ServiceConfig {
8282
/// Maximum number of webhooks allowed per client.
8383
pub max_webhooks_per_client: u32,
84-
/// Signing key for LSP notifications.
85-
pub signing_key: SecretKey,
8684
/// Minimum time between sending the same notification type in hours (default: 24)
8785
pub notification_cooldown_hours: Duration,
8886
}
@@ -122,9 +120,10 @@ pub struct LSPS5ServiceConfig {
122120
/// [`LSPS5ServiceEvent::SendWebhookNotification`]: super::event::LSPS5ServiceEvent::SendWebhookNotification
123121
/// [`app_name`]: super::msgs::LSPS5AppName
124122
/// [`lsps5.webhook_registered`]: super::msgs::WebhookNotificationMethod::LSPS5WebhookRegistered
125-
pub struct LSPS5ServiceHandler<CM: Deref, TP: Deref>
123+
pub struct LSPS5ServiceHandler<CM: Deref, NS: Deref, TP: Deref>
126124
where
127125
CM::Target: AChannelManager,
126+
NS::Target: NodeSigner,
128127
TP::Target: TimeProvider,
129128
{
130129
config: LSPS5ServiceConfig,
@@ -133,18 +132,20 @@ where
133132
pending_messages: Arc<MessageQueue>,
134133
time_provider: TP,
135134
channel_manager: CM,
135+
node_signer: NS,
136136
last_pruning: Mutex<Option<LSPSDateTime>>,
137137
}
138138

139-
impl<CM: Deref, TP: Deref> LSPS5ServiceHandler<CM, TP>
139+
impl<CM: Deref, NS: Deref, TP: Deref> LSPS5ServiceHandler<CM, NS, TP>
140140
where
141141
CM::Target: AChannelManager,
142+
NS::Target: NodeSigner,
142143
TP::Target: TimeProvider,
143144
{
144145
/// Constructs a `LSPS5ServiceHandler` using the given time provider.
145146
pub(crate) fn new_with_time_provider(
146147
event_queue: Arc<EventQueue>, pending_messages: Arc<MessageQueue>, channel_manager: CM,
147-
config: LSPS5ServiceConfig, time_provider: TP,
148+
node_signer: NS, config: LSPS5ServiceConfig, time_provider: TP,
148149
) -> Self {
149150
assert!(config.max_webhooks_per_client > 0, "`max_webhooks_per_client` must be > 0");
150151
Self {
@@ -154,6 +155,7 @@ where
154155
pending_messages,
155156
time_provider,
156157
channel_manager,
158+
node_signer,
157159
last_pruning: Mutex::new(None),
158160
}
159161
}
@@ -468,7 +470,9 @@ where
468470
notification_json
469471
);
470472

471-
message_signing::sign(message.as_bytes(), &self.config.signing_key)
473+
self.node_signer
474+
.sign_message(message.as_bytes())
475+
.map_err(|_| LSPS5ProtocolError::UnknownError)
472476
}
473477

474478
fn prune_stale_webhooks(&self) {
@@ -500,9 +504,10 @@ where
500504
}
501505
}
502506

503-
impl<CM: Deref, TP: Deref> LSPSProtocolMessageHandler for LSPS5ServiceHandler<CM, TP>
507+
impl<CM: Deref, NS: Deref, TP: Deref> LSPSProtocolMessageHandler for LSPS5ServiceHandler<CM, NS, TP>
504508
where
505509
CM::Target: AChannelManager,
510+
NS::Target: NodeSigner,
506511
TP::Target: TimeProvider,
507512
{
508513
type ProtocolMessage = LSPS5Message;

0 commit comments

Comments
 (0)