mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-22 08:34:20 +01:00
cln-plugin: Add support for synchronous RPC methods
Changelog-Experimental: cln-plugin: Added support for non-async RPC method passthrough (async support coming soon)
This commit is contained in:
committed by
Rusty Russell
parent
22618a2f94
commit
8c6af21169
@@ -1,9 +1,10 @@
|
||||
//! This is a test plugin used to verify that we can compile and run
|
||||
//! plugins using the Rust API against c-lightning.
|
||||
|
||||
use cln_plugin::{options, Builder};
|
||||
#[macro_use]
|
||||
extern crate serde_json;
|
||||
use cln_plugin::{options, Builder, Error, Plugin};
|
||||
use std::pin::Pin;
|
||||
use tokio;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), anyhow::Error> {
|
||||
let plugin = Builder::new((), tokio::io::stdin(), tokio::io::stdout())
|
||||
@@ -12,7 +13,12 @@ async fn main() -> Result<(), anyhow::Error> {
|
||||
options::Value::Integer(42),
|
||||
"a test-option with default 42",
|
||||
))
|
||||
.rpcmethod("testmethod", "This is a test", Box::new(testmethod))
|
||||
.start()
|
||||
.await?;
|
||||
plugin.join().await
|
||||
}
|
||||
|
||||
fn testmethod(_p: Plugin<()>, _v: &serde_json::Value) -> Result<serde_json::Value, Error> {
|
||||
Ok(json!("Hello"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user