| 10 | |
| 11 | #[tokio::main] |
| 12 | async fn main() -> Result<(), Error> { |
| 13 | let (tx, _) = broadcast::channel(4); |
| 14 | let state = State { tx }; |
| 15 | |
| 16 | if let Some(plugin) = Builder::new(tokio::io::stdin(), tokio::io::stdout()) |
| 17 | .hook("htlc_accepted", htlc_accepted_handler) |
| 18 | .rpcmethod("release", "Release all HTLCs we currently hold", release) |
| 19 | .start(state) |
| 20 | .await? |
| 21 | { |
| 22 | plugin.join().await?; |
| 23 | Ok(()) |
| 24 | } else { |
| 25 | Ok(()) |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | /// Release all waiting HTLCs |
| 30 | async fn release(p: Plugin<State>, _v: serde_json::Value) -> Result<serde_json::Value, Error> { |