plugins: lsps: move errors into proto module
What changed, and why it matters
This commit is a routine code reorganization in Core Lightning's experimental LSPS plugin. It moves standard JSON-RPC error code constants from one internal Rust module to another and adds a new client-rejected error type. There is no security-relevant behavior change, no bug fix, and no vulnerability patch.
No security action needed; treat as normal refactoring review.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff refactors the lsps-plugin crate: constants PARSE_ERROR, INVALID_REQUEST, METHOD_NOT_FOUND, INVALID_PARAMS, and INTERNAL_ERROR are relocated from plugins/lsps-plugin/src/jsonrpc/mod.rs to plugins/lsps-plugin/src/proto/lsps0.rs and re-exported for use. A new LSPS0-specific Error enum with a ClientRejected variant and helper constructor is added. No logic, parsing, validation, or trust boundary handling is altered.
Changed components
plugins/lsps-plugin/src/jsonrpc/mod.rsplugins/lsps-plugin/src/proto/lsps0.rsInspect captured patch +24 / −7
diff --git a/plugins/lsps-plugin/src/jsonrpc/mod.rs b/plugins/lsps-plugin/src/jsonrpc/mod.rs
index b7c871ee..9eff412f 100644
--- a/plugins/lsps-plugin/src/jsonrpc/mod.rs
+++ b/plugins/lsps-plugin/src/jsonrpc/mod.rs
@@ -6,12 +6,9 @@ pub mod server;
use std::fmt;
use thiserror::Error;
-// Constants for JSON-RPC error codes
-const PARSE_ERROR: i64 = -32700;
-const INVALID_REQUEST: i64 = -32600;
-const METHOD_NOT_FOUND: i64 = -32601;
-const INVALID_PARAMS: i64 = -32602;
-const INTERNAL_ERROR: i64 = -32603;
+use crate::proto::lsps0::{
+ INTERNAL_ERROR, INVALID_PARAMS, INVALID_REQUEST, METHOD_NOT_FOUND, PARSE_ERROR,
+};
/// Error type for JSON-RPC related operations.
///
diff --git a/plugins/lsps-plugin/src/proto/lsps0.rs b/plugins/lsps-plugin/src/proto/lsps0.rs
index 0327120e..dfff989d 100644
--- a/plugins/lsps-plugin/src/proto/lsps0.rs
+++ b/plugins/lsps-plugin/src/proto/lsps0.rs
@@ -1,6 +1,26 @@
+use crate::jsonrpc::JsonRpcRequest;
use serde::{Deserialize, Serialize};
-use crate::jsonrpc::JsonRpcRequest;
+
+// Constants for JSON-RPC error codes.
+pub const PARSE_ERROR: i64 = -32700;
+pub const INVALID_REQUEST: i64 = -32600;
+pub const METHOD_NOT_FOUND: i64 = -32601;
+pub const INVALID_PARAMS: i64 = -32602;
+pub const INTERNAL_ERROR: i64 = -32603;
+
+// Lsps0 error definitions. Are in the range 00000 to 00099.
+pub const CLIENT_REJECTED: i64 = 1;
+
+pub enum Error {
+ ClientRejected(String),
+}
+
+impl Error {
+ pub fn client_rejected(msg: String) -> Error {
+ Self::ClientRejected(msg)
+ }
+}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct Lsps0listProtocolsRequest {}
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.