Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions plugins/lsps-plugin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,29 @@ edition = "2021"
[[bin]]
name = "cln-lsps-client"
path = "src/client.rs"
required-features = ["cln"]

[[bin]]
name = "cln-lsps-service"
path = "src/service.rs"
required-features = ["cln"]

[features]
default = ["cln"]
cln = ["cln-plugin", "cln-rpc"]

[dependencies]
anyhow = "1.0"
async-trait = "0.1"
bitcoin = "0.31"
bitcoin = { version = "0.31", features = ["serde"] }
chrono = { version= "0.4.42", features = ["serde"] }
cln-plugin = { workspace = true }
cln-rpc = { workspace = true }
cln-plugin = { workspace = true, optional = true }
cln-rpc = { workspace = true, optional = true }
hex = "0.4"
log = "0.4"
paste = "1.0.15"
rand = "0.9"
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0", features = ["raw_value"] }
thiserror = "2.0"
tokio = { version = "1.44", features = ["full"] }
tokio = { version = "1.44", features = ["full", "test-util"] }
12 changes: 5 additions & 7 deletions plugins/lsps-plugin/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ use cln_lsps::{
transport::{MultiplexedTransport, PendingRequests},
},
proto::{
lsps0::{Msat, LSPS0_MESSAGE_TYPE, LSP_FEATURE_BIT},
lsps0::{Msat, LSP_FEATURE_BIT},
lsps2::{compute_opening_fee, Lsps2BuyResponse, Lsps2GetInfoResponse, OpeningFeeParams},
},
};
use cln_plugin::{options, HookBuilder, HookFilter};
use cln_plugin::options;
use cln_rpc::{
model::{
requests::{
Expand Down Expand Up @@ -82,10 +82,7 @@ impl ClientState for State {
#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
if let Some(plugin) = cln_plugin::Builder::new(tokio::io::stdin(), tokio::io::stdout())
.hook_from_builder(
HookBuilder::new("custommsg", hooks::client_custommsg_hook)
.filters(vec![HookFilter::Int(i64::from(LSPS0_MESSAGE_TYPE))]),
)
.hook("custommsg", hooks::client_custommsg_hook)
.option(OPTION_ENABLED)
.rpcmethod(
"lsps-listprotocols",
Expand Down Expand Up @@ -485,7 +482,7 @@ async fn on_lsps_lsps2_invoice(
// 5. Approve jit_channel_scid for a jit channel opening.
let appr_req = ClnRpcLsps2Approve {
lsp_id: req.lsp_id,
jit_channel_scid: buy_res.jit_channel_scid,
jit_channel_scid: buy_res.jit_channel_scid.into(),
payment_hash: public_inv.payment_hash.to_string(),
client_trusts_lsp: Some(buy_res.client_trusts_lsp),
};
Expand Down Expand Up @@ -698,6 +695,7 @@ async fn on_openchannel(
return Ok(serde_json::json!({
"result": "continue",
"mindepth": 0,
"reserve": 0,
}));
} else {
// Not a requested JIT-channel opening, continue.
Expand Down
5 changes: 5 additions & 0 deletions plugins/lsps-plugin/src/cln_adapters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@ pub mod rpc;
pub mod sender;
pub mod state;
pub mod types;

pub use rpc::{
ClnActionExecutor, ClnDatastore, ClnPolicyProvider, ClnRecoveryProvider,
ClnRpcClient,
};
Loading