Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Commit 64cf801

Browse files
get_info unsupported_version error
1 parent e2be22b commit 64cf801

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/jit_channel/channel_manager.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ use crate::jit_channel::msgs::{
4141
LSPS2_BUY_REQUEST_INVALID_VERSION_ERROR_CODE,
4242
LSPS2_BUY_REQUEST_PAYMENT_SIZE_TOO_LARGE_ERROR_CODE,
4343
LSPS2_BUY_REQUEST_PAYMENT_SIZE_TOO_SMALL_ERROR_CODE,
44+
LSPS2_GET_INFO_REQUEST_INVALID_VERSION_ERROR_CODE,
4445
};
4546

4647
const SUPPORTED_SPEC_VERSIONS: [u16; 1] = [1];
@@ -905,6 +906,22 @@ where
905906
fn handle_get_info_request(
906907
&self, request_id: RequestId, counterparty_node_id: &PublicKey, params: GetInfoRequest,
907908
) -> Result<(), LightningError> {
909+
if !SUPPORTED_SPEC_VERSIONS.contains(&params.version) {
910+
self.enqueue_response(
911+
*counterparty_node_id,
912+
request_id,
913+
LSPS2Response::GetInfoError(ResponseError {
914+
code: LSPS2_GET_INFO_REQUEST_INVALID_VERSION_ERROR_CODE,
915+
message: format!("version {} is not supported", params.version),
916+
data: Some(format!("Supported versions are {:?}", SUPPORTED_SPEC_VERSIONS)),
917+
}),
918+
);
919+
return Err(LightningError {
920+
err: format!("client requested unsupported version {}", params.version),
921+
action: ErrorAction::IgnoreAndLog(Level::Info),
922+
});
923+
}
924+
908925
let mut outer_state_lock = self.per_peer_state.write().unwrap();
909926
let inner_state_lock: &mut Mutex<PeerState> = outer_state_lock
910927
.entry(*counterparty_node_id)

src/jit_channel/msgs.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ pub(crate) const LSPS2_GET_VERSIONS_METHOD_NAME: &str = "lsps2.get_versions";
1313
pub(crate) const LSPS2_GET_INFO_METHOD_NAME: &str = "lsps2.get_info";
1414
pub(crate) const LSPS2_BUY_METHOD_NAME: &str = "lsps2.buy";
1515

16+
pub(crate) const LSPS2_GET_INFO_REQUEST_INVALID_VERSION_ERROR_CODE: i32 = 1;
17+
1618
pub(crate) const LSPS2_BUY_REQUEST_INVALID_VERSION_ERROR_CODE: i32 = 1;
1719
pub(crate) const LSPS2_BUY_REQUEST_INVALID_OPENING_FEE_PARAMS_ERROR_CODE: i32 = 2;
1820
pub(crate) const LSPS2_BUY_REQUEST_PAYMENT_SIZE_TOO_SMALL_ERROR_CODE: i32 = 3;

0 commit comments

Comments
 (0)