plugins: lsps: move feature types into proto module
What changed, and why it matters
This is a routine code reorganization. Two numeric constants used by the Lightning Service Provider (LSP) plugin are moved from one Rust source file to another so that third-party plugin code can import them more cleanly. The actual values (feature bit 729 and message type 37913) and how they are used do not change.
No security action required. Treat as normal refactoring code review.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors the cln_lsps crate by moving LSP_FEATURE_BIT (usize = 729) from lib.rs to proto/lsps0.rs, and LSPS0_MESSAGE_TYPE (u16 = 37913) from lsps0/transport.rs to proto/lsps0.rs. Call sites in client.rs, service.rs, and lsps0/transport.rs are updated to import the constants from their new location. No logic, values, or behavior are modified.
Changed components
plugins/lsps-plugin/src/lib.rsplugins/lsps-plugin/src/proto/lsps0.rsplugins/lsps-plugin/src/lsps0/transport.rsplugins/lsps-plugin/src/client.rsplugins/lsps-plugin/src/service.rsInspect captured patch +15 / −9
diff --git a/plugins/lsps-plugin/src/client.rs b/plugins/lsps-plugin/src/client.rs
index 6f949a51..e27bb1bf 100644
--- a/plugins/lsps-plugin/src/client.rs
+++ b/plugins/lsps-plugin/src/client.rs
@@ -14,10 +14,11 @@ use cln_lsps::lsps2::model::{
compute_opening_fee, Lsps2BuyRequest, Lsps2BuyResponse, Lsps2GetInfoRequest,
Lsps2GetInfoResponse, OpeningFeeParams,
};
-use cln_lsps::proto::lsps0::{Lsps0listProtocolsRequest, Lsps0listProtocolsResponse};
+use cln_lsps::proto::lsps0::{
+ Lsps0listProtocolsRequest, Lsps0listProtocolsResponse, LSP_FEATURE_BIT,
+};
use cln_lsps::proto::primitives::Msat;
use cln_lsps::util;
-use cln_lsps::LSP_FEATURE_BIT;
use cln_plugin::options;
use cln_rpc::model::requests::{
DatastoreMode, DatastoreRequest, DeldatastoreRequest, DelinvoiceRequest, DelinvoiceStatus,
diff --git a/plugins/lsps-plugin/src/lib.rs b/plugins/lsps-plugin/src/lib.rs
index d4ef4ae7..3c37daa9 100644
--- a/plugins/lsps-plugin/src/lib.rs
+++ b/plugins/lsps-plugin/src/lib.rs
@@ -3,5 +3,3 @@ pub mod lsps0;
pub mod lsps2;
pub mod proto;
pub mod util;
-
-pub const LSP_FEATURE_BIT: usize = 729;
diff --git a/plugins/lsps-plugin/src/lsps0/transport.rs b/plugins/lsps-plugin/src/lsps0/transport.rs
index b19974e7..b1a1f1c4 100644
--- a/plugins/lsps-plugin/src/lsps0/transport.rs
+++ b/plugins/lsps-plugin/src/lsps0/transport.rs
@@ -1,4 +1,7 @@
-use crate::jsonrpc::{client::Transport, Error, TransportError};
+use crate::{
+ jsonrpc::{client::Transport, Error, TransportError},
+ proto::lsps0::LSPS0_MESSAGE_TYPE,
+};
use async_trait::async_trait;
use cln_plugin::Plugin;
use cln_rpc::{primitives::PublicKey, ClnRpc};
@@ -15,7 +18,6 @@ use tokio::{
time::Duration,
};
-pub const LSPS0_MESSAGE_TYPE: u16 = 37913;
const DEFAULT_TIMEOUT: Duration = Duration::from_secs(60);
/// Trait that must be implemented by plugin state to access the custom message hook manager.
diff --git a/plugins/lsps-plugin/src/proto/lsps0.rs b/plugins/lsps-plugin/src/proto/lsps0.rs
index dfff989d..19173b2a 100644
--- a/plugins/lsps-plugin/src/proto/lsps0.rs
+++ b/plugins/lsps-plugin/src/proto/lsps0.rs
@@ -1,6 +1,11 @@
use crate::jsonrpc::JsonRpcRequest;
use serde::{Deserialize, Serialize};
+// Optional feature bet to set according to LSPS0.
+pub const LSP_FEATURE_BIT: usize = 729;
+
+// Required message type for BOLT8 transport.
+pub const LSPS0_MESSAGE_TYPE: u16 = 37913;
// Constants for JSON-RPC error codes.
pub const PARSE_ERROR: i64 = -32700;
diff --git a/plugins/lsps-plugin/src/service.rs b/plugins/lsps-plugin/src/service.rs
index 12567f30..d7285385 100644
--- a/plugins/lsps-plugin/src/service.rs
+++ b/plugins/lsps-plugin/src/service.rs
@@ -5,12 +5,12 @@ use cln_lsps::jsonrpc::TransportError;
use cln_lsps::jsonrpc::{server::JsonRpcServer, JsonRpcRequest};
use cln_lsps::lsps0::handler::Lsps0ListProtocolsHandler;
use cln_lsps::lsps0::transport::{self, CustomMsg};
+use cln_lsps::lsps2;
use cln_lsps::lsps2::cln::{HtlcAcceptedRequest, HtlcAcceptedResponse};
use cln_lsps::lsps2::handler::{ClnApiRpc, HtlcAcceptedHookHandler};
use cln_lsps::lsps2::model::{Lsps2BuyRequest, Lsps2GetInfoRequest};
-use cln_lsps::proto::lsps0::Lsps0listProtocolsRequest;
+use cln_lsps::proto::lsps0::{Lsps0listProtocolsRequest, LSPS0_MESSAGE_TYPE};
use cln_lsps::util::wrap_payload_with_peer_id;
-use cln_lsps::{lsps0, lsps2};
use cln_plugin::Plugin;
use cln_rpc::notifications::CustomMsgNotification;
use cln_rpc::primitives::PublicKey;
@@ -151,7 +151,7 @@ async fn on_custommsg(
serde_json::from_value(v).map_err(|e| anyhow!("invalid custommsg: {e}"))?;
let req = CustomMsg::from_str(&msg.payload).map_err(|e| anyhow!("invalid payload {e}"))?;
- if req.message_type != lsps0::transport::LSPS0_MESSAGE_TYPE {
+ if req.message_type != LSPS0_MESSAGE_TYPE {
// We don't care if this is not for us!
return continue_response;
}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.