plugins: lsps: add router compatible lsps2 service handler

This commit copys and adapts the lsps2 service handlers to match the
slim router handlers

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
This commit is contained in:
Peter Neuroth
2025-12-05 00:23:26 +01:00
committed by madelinevibes
parent ffc05ddcf0
commit 461065aff7
4 changed files with 1587 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,2 @@
pub mod handler;
pub mod service;

View File

@@ -0,0 +1,39 @@
use crate::{
core::{router::JsonRpcRouterBuilder, server::LspsProtocol},
proto::{
jsonrpc::RpcError,
lsps2::{Lsps2BuyRequest, Lsps2BuyResponse, Lsps2GetInfoRequest, Lsps2GetInfoResponse},
},
register_handler,
};
use async_trait::async_trait;
use bitcoin::secp256k1::PublicKey;
use std::sync::Arc;
#[async_trait]
pub trait Lsps2Handler: Send + Sync + 'static {
async fn handle_get_info(
&self,
request: Lsps2GetInfoRequest,
) -> std::result::Result<Lsps2GetInfoResponse, RpcError>;
async fn handle_buy(
&self,
peer_id: PublicKey,
request: Lsps2BuyRequest,
) -> Result<Lsps2BuyResponse, RpcError>;
}
impl<H> LspsProtocol for Arc<H>
where
H: Lsps2Handler + Send + Sync + 'static,
{
fn register_handler(&self, router: &mut JsonRpcRouterBuilder) {
register_handler!(router, self, "lsps2.get_info", handle_get_info);
register_handler!(router, self, "lsps2.buy", handle_buy, with_peer);
}
fn protocol(&self) -> u8 {
2
}
}

View File

@@ -1,4 +1,5 @@
pub mod client;
pub mod lsps2;
pub mod router;
pub mod server;
pub mod transport;