crates: formatting with new 2024 edition rules
What changed, and why it matters
This commit is purely a code-formatting cleanup. It runs `cargo fmt --all` to apply the Rust 2024 edition style rules across many Rust source files. The changes only reorder imports, re-wrap long lines, add trailing commas, and adjust indentation. No program logic, security checks, or behavior were changed.
No security action needed. This is a style-only formatting commit and can be treated as routine maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff shows only automated formatting changes produced by cargo fmt --all for the Rust 2024 edition. Examples include reordering use statements alphabetically, wrapping long function calls and struct literals across multiple lines, adding trailing commas, and minor whitespace/semicolon adjustments. No functional code, cryptographic operations, network handling, or authorization logic was modified. The commit message explicitly states ‘Changelog-None’ and identifies this as formatting only.
Changed components
Inspect captured patch +204 / −160
diff --git a/cln-rpc/examples/getinfo.rs b/cln-rpc/examples/getinfo.rs
index 35e32c2c..fd7d1933 100644
--- a/cln-rpc/examples/getinfo.rs
+++ b/cln-rpc/examples/getinfo.rs
@@ -1,5 +1,5 @@
-use anyhow::{anyhow, Context};
-use cln_rpc::{model::requests::GetinfoRequest, ClnRpc, Request};
+use anyhow::{Context, anyhow};
+use cln_rpc::{ClnRpc, Request, model::requests::GetinfoRequest};
use std::env::args;
use std::path::Path;
use tokio;
diff --git a/cln-rpc/src/jsonrpc.rs b/cln-rpc/src/jsonrpc.rs
index a3930d9c..8466385c 100644
--- a/cln-rpc/src/jsonrpc.rs
+++ b/cln-rpc/src/jsonrpc.rs
@@ -1,8 +1,8 @@
//! Common structs to handle JSON-RPC decoding and encoding. They are
//! generic over the Notification and Request types.
-use serde::ser::{SerializeStruct, Serializer};
use serde::de::{self, Deserializer};
+use serde::ser::{SerializeStruct, Serializer};
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::fmt::Debug;
diff --git a/cln-rpc/src/lib.rs b/cln-rpc/src/lib.rs
index 31c54622..39ad3a0d 100644
--- a/cln-rpc/src/lib.rs
+++ b/cln-rpc/src/lib.rs
@@ -79,15 +79,15 @@ use crate::codec::JsonCodec;
pub use anyhow::Error;
use anyhow::Result;
use core::fmt::Debug;
-use futures_util::sink::SinkExt;
use futures_util::StreamExt;
+use futures_util::sink::SinkExt;
use log::{debug, trace};
-use serde::{de::DeserializeOwned, Serialize};
+use serde::{Serialize, de::DeserializeOwned};
use std::path::Path;
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering;
-use tokio::net::unix::{OwnedReadHalf, OwnedWriteHalf};
use tokio::net::UnixStream;
+use tokio::net::unix::{OwnedReadHalf, OwnedWriteHalf};
use tokio_util::codec::{FramedRead, FramedWrite};
pub mod codec;
@@ -559,8 +559,11 @@ mod test {
#[test]
fn serialize_custom_msg_notification() {
let msg = CustomMsgNotification {
- peer_id : PublicKey::from_str("0364aeb75519be29d1af7b8cc6232dbda9fdabb79b66e4e1f6a223750954db210b").unwrap(),
- payload : String::from("941746573749")
+ peer_id: PublicKey::from_str(
+ "0364aeb75519be29d1af7b8cc6232dbda9fdabb79b66e4e1f6a223750954db210b",
+ )
+ .unwrap(),
+ payload: String::from("941746573749"),
};
let notification = Notification::CustomMsg(msg);
@@ -576,14 +579,16 @@ mod test {
}
)
);
-
}
#[test]
fn serialize_block_added_notification() {
let block_added = BlockAddedNotification {
- hash : crate::primitives::Sha256::from_str("000000000000000000000acab8abe0c67a52ed7e5a90a19c64930ff11fa84eca").unwrap(),
- height : 830702
+ hash: crate::primitives::Sha256::from_str(
+ "000000000000000000000acab8abe0c67a52ed7e5a90a19c64930ff11fa84eca",
+ )
+ .unwrap(),
+ height: 830702,
};
let notification = Notification::BlockAdded(block_added);
@@ -613,6 +618,6 @@ mod test {
}
});
- let _ : Notification = serde_json::from_value(connect_json).unwrap();
+ let _: Notification = serde_json::from_value(connect_json).unwrap();
}
}
diff --git a/cln-rpc/src/primitives.rs b/cln-rpc/src/primitives.rs
index c99c94d7..25f56103 100644
--- a/cln-rpc/src/primitives.rs
+++ b/cln-rpc/src/primitives.rs
@@ -1,6 +1,6 @@
//! Primitive types representing [`Amount`]s, [`PublicKey`]s, ...
use anyhow::Context;
-use anyhow::{anyhow, Error, Result};
+use anyhow::{Error, Result, anyhow};
use bitcoin::hashes::Hash as BitcoinHash;
use serde::{Deserialize, Serialize};
use serde::{Deserializer, Serializer};
diff --git a/plugins/bip353-plugin/src/config.rs b/plugins/bip353-plugin/src/config.rs
index cd433a01..dbffe3d3 100644
--- a/plugins/bip353-plugin/src/config.rs
+++ b/plugins/bip353-plugin/src/config.rs
@@ -1,4 +1,4 @@
-use cln_plugin::{messages::ProxyInfo, Plugin};
+use cln_plugin::{Plugin, messages::ProxyInfo};
pub fn get_proxy(plugin: Plugin<()>) -> Option<ProxyInfo> {
match plugin.configuration().always_use_proxy {
diff --git a/plugins/bip353-plugin/src/main.rs b/plugins/bip353-plugin/src/main.rs
index 138981fb..651ebe0a 100644
--- a/plugins/bip353-plugin/src/main.rs
+++ b/plugins/bip353-plugin/src/main.rs
@@ -3,8 +3,8 @@ use std::time::Duration;
use anyhow::anyhow;
use bitcoin::hex::DisplayHex;
use bitcoin_payment_instructions::{
- hrn_resolution::HumanReadableName, http_resolver::HTTPHrnResolver, PaymentInstructions,
- PaymentMethod, PossiblyResolvedPaymentMethod,
+ PaymentInstructions, PaymentMethod, PossiblyResolvedPaymentMethod,
+ hrn_resolution::HumanReadableName, http_resolver::HTTPHrnResolver,
};
use cln_plugin::{Builder, Plugin, RpcMethodBuilder};
use serde::Serialize;
diff --git a/plugins/currencyrate-plugin/src/main.rs b/plugins/currencyrate-plugin/src/main.rs
index 0b74d63c..e03d0bbd 100644
--- a/plugins/currencyrate-plugin/src/main.rs
+++ b/plugins/currencyrate-plugin/src/main.rs
@@ -2,7 +2,7 @@ use anyhow::anyhow;
use cln_plugin::options::StringArrayConfigOption;
use cln_plugin::{Builder, ConfiguredPlugin, Plugin, RpcMethodBuilder};
use cln_rpc::ClnRpc;
-use serde_json::{json, Value};
+use serde_json::{Value, json};
use std::net::{IpAddr, SocketAddr};
use std::path::Path;
use std::str::FromStr;
@@ -190,7 +190,10 @@ async fn currencyrate(plugin: Plugin<PluginState>, args: Value) -> Result<Value,
}
}
-async fn listcurrencyrates(plugin: Plugin<PluginState>, args: Value) -> Result<Value, anyhow::Error> {
+async fn listcurrencyrates(
+ plugin: Plugin<PluginState>,
+ args: Value,
+) -> Result<Value, anyhow::Error> {
let currency = match args {
Value::Array(values) => {
let currency = values
diff --git a/plugins/examples/cln-plugin-startup.rs b/plugins/examples/cln-plugin-startup.rs
index 12578fe4..c2889559 100644
--- a/plugins/examples/cln-plugin-startup.rs
+++ b/plugins/examples/cln-plugin-startup.rs
@@ -7,7 +7,7 @@ use cln_plugin::options::{
DefaultStringArrayConfigOption, IntegerArrayConfigOption, IntegerConfigOption,
StringArrayConfigOption,
};
-use cln_plugin::{messages, Builder, Error, HookBuilder, Plugin};
+use cln_plugin::{Builder, Error, HookBuilder, Plugin, messages};
const TEST_NOTIF_TAG: &str = "test_custom_notification";
diff --git a/plugins/examples/cln-subscribe-wildcard.rs b/plugins/examples/cln-subscribe-wildcard.rs
index 4942f353..c403e3ee 100644
--- a/plugins/examples/cln-subscribe-wildcard.rs
+++ b/plugins/examples/cln-subscribe-wildcard.rs
@@ -1,6 +1,5 @@
/// This plug-in subscribes to the wildcard-notifications
/// and creates a corresponding log-entry
-
use anyhow::Result;
use cln_plugin::{Builder, Plugin};
@@ -14,21 +13,15 @@ async fn main() -> Result<()> {
.await?;
match configured {
- Some(p) => p.join().await?,
- None => return Ok(()) // cln was started with --help
+ Some(p) => p.join().await?,
+ None => return Ok(()), // cln was started with --help
};
Ok(())
}
-async fn handle_wildcard_notification(_plugin: Plugin<()>, value : serde_json::Value) -> Result<()> {
- let notification_type : String = value
- .as_object()
- .unwrap()
- .keys()
- .next()
- .unwrap()
- .into();
+async fn handle_wildcard_notification(_plugin: Plugin<()>, value: serde_json::Value) -> Result<()> {
+ let notification_type: String = value.as_object().unwrap().keys().next().unwrap().into();
log::info!("Received notification {}", notification_type);
Ok(())
diff --git a/plugins/grpc-plugin/src/main.rs b/plugins/grpc-plugin/src/main.rs
index 7da254bb..7be70ce1 100644
--- a/plugins/grpc-plugin/src/main.rs
+++ b/plugins/grpc-plugin/src/main.rs
@@ -1,6 +1,6 @@
use anyhow::{Context, Result};
use cln_grpc::pb::node_server::NodeServer;
-use cln_plugin::{options, Builder, Plugin};
+use cln_plugin::{Builder, Plugin, options};
use cln_rpc::notifications::Notification;
use std::net::SocketAddr;
use std::path::PathBuf;
@@ -30,10 +30,12 @@ const OPTION_GRPC_HOST: options::DefaultStringConfigOption =
"Which host should the grpc listen for incomming connections?",
);
-const OPTION_GRPC_MSG_BUFFER_SIZE : options::DefaultIntegerConfigOption = options::ConfigOption::new_i64_with_default(
- "grpc-msg-buffer-size",
- 1024,
- "Number of notifications which can be stored in the grpc message buffer. Notifications can be skipped if this buffer is full");
+const OPTION_GRPC_MSG_BUFFER_SIZE: options::DefaultIntegerConfigOption =
+ options::ConfigOption::new_i64_with_default(
+ "grpc-msg-buffer-size",
+ 1024,
+ "Number of notifications which can be stored in the grpc message buffer. Notifications can be skipped if this buffer is full",
+ );
#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<()> {
diff --git a/plugins/lsps-plugin/src/client.rs b/plugins/lsps-plugin/src/client.rs
index bdf3475f..c73d9ed5 100644
--- a/plugins/lsps-plugin/src/client.rs
+++ b/plugins/lsps-plugin/src/client.rs
@@ -1,5 +1,5 @@
-use anyhow::{anyhow, bail, Context};
-use bitcoin::hashes::{hex::FromHex, sha256, Hash};
+use anyhow::{Context, anyhow, bail};
+use bitcoin::hashes::{Hash, hex::FromHex, sha256};
use chrono::{Duration, Utc};
use cln_lsps::{
cln_adapters::{
@@ -13,16 +13,17 @@ use cln_lsps::{
core::{
client::LspsClient,
features::is_feature_bit_set_reversed,
- tlv::{encode_tu64, TLV_FORWARD_AMT, TLV_PAYMENT_SECRET},
+ tlv::{TLV_FORWARD_AMT, TLV_PAYMENT_SECRET, encode_tu64},
transport::{MultiplexedTransport, PendingRequests},
},
proto::{
- lsps0::{Msat, LSPS0_MESSAGE_TYPE, LSP_FEATURE_BIT},
- lsps2::{compute_opening_fee, Lsps2BuyResponse, Lsps2GetInfoResponse, OpeningFeeParams},
+ lsps0::{LSP_FEATURE_BIT, LSPS0_MESSAGE_TYPE, Msat},
+ lsps2::{Lsps2BuyResponse, Lsps2GetInfoResponse, OpeningFeeParams, compute_opening_fee},
},
};
-use cln_plugin::{options, HookBuilder, HookFilter};
+use cln_plugin::{HookBuilder, HookFilter, options};
use cln_rpc::{
+ ClnRpc,
model::{
requests::{
DatastoreMode, DatastoreRequest, DeldatastoreRequest, DelinvoiceRequest,
@@ -31,7 +32,6 @@ use cln_rpc::{
responses::InvoiceResponse,
},
primitives::{Amount, AmountOrAny, PublicKey, ShortChannelId},
- ClnRpc,
};
use log::{debug, info, warn};
use rand::{CryptoRng, Rng};
@@ -522,16 +522,20 @@ async fn on_invoice_payment(
// Delete DS-entries.
let dir = p.configuration().lightning_dir;
let rpc_path = Path::new(&dir).join(&p.configuration().rpc_file);
- let mut cln_client = ok_or_continue!(cln_rpc::ClnRpc::new(rpc_path.clone())
- .await
- .context("failed to connect to core-lightning"));
- ok_or_continue!(cln_client
- .call_typed(&DeldatastoreRequest {
- key: vec!["lsps".to_string(), "invoice".to_string(), hash.to_string()],
- generation: None,
- })
- .await
- .context("failed to delete datastore record"));
+ let mut cln_client = ok_or_continue!(
+ cln_rpc::ClnRpc::new(rpc_path.clone())
+ .await
+ .context("failed to connect to core-lightning")
+ );
+ ok_or_continue!(
+ cln_client
+ .call_typed(&DeldatastoreRequest {
+ key: vec!["lsps".to_string(), "invoice".to_string(), hash.to_string()],
+ generation: None,
+ })
+ .await
+ .context("failed to delete datastore record")
+ );
Ok(serde_json::json!({"result": "continue"}))
}
@@ -558,20 +562,24 @@ async fn on_htlc_accepted(
// Check that the htlc belongs to a jit-channel request.
let dir = p.configuration().lightning_dir;
let rpc_path = Path::new(&dir).join(&p.configuration().rpc_file);
- let mut cln_client = ok_or_continue!(cln_rpc::ClnRpc::new(rpc_path.clone())
- .await
- .context("failed to connect to core-lightning"));
+ let mut cln_client = ok_or_continue!(
+ cln_rpc::ClnRpc::new(rpc_path.clone())
+ .await
+ .context("failed to connect to core-lightning")
+ );
- let lsp_data = ok_or_continue!(cln_client
- .call_typed(&ListdatastoreRequest {
- key: Some(vec![
- "lsps".to_string(),
- "invoice".to_string(),
- hex::encode(&req.htlc.payment_hash),
- ]),
- })
- .await
- .context("failed to fetch datastore record"));
+ let lsp_data = ok_or_continue!(
+ cln_client
+ .call_typed(&ListdatastoreRequest {
+ key: Some(vec![
+ "lsps".to_string(),
+ "invoice".to_string(),
+ hex::encode(&req.htlc.payment_hash),
+ ]),
+ })
+ .await
+ .context("failed to fetch datastore record")
+ );
// If we don't know about this payment it's not an LSP payment, continue.
some_or_continue!(lsp_data.datastore.first());
@@ -601,18 +609,20 @@ async fn on_htlc_accepted(
// FIXME: If we are strict, we should reject the htlc here.
}
- let inv_res = ok_or_continue!(cln_client
- .call_typed(&ListinvoicesRequest {
- index: None,
- invstring: None,
- label: None,
- limit: None,
- offer_id: None,
- payment_hash: Some(hex::encode(&req.htlc.payment_hash)),
- start: None,
- })
- .await
- .context("failed to get invoice"));
+ let inv_res = ok_or_continue!(
+ cln_client
+ .call_typed(&ListinvoicesRequest {
+ index: None,
+ invstring: None,
+ label: None,
+ limit: None,
+ offer_id: None,
+ payment_hash: Some(hex::encode(&req.htlc.payment_hash)),
+ start: None,
+ })
+ .await
+ .context("failed to get invoice")
+ );
let invoice = some_or_continue!(
inv_res.invoices.first(),
@@ -629,9 +639,11 @@ async fn on_htlc_accepted(
ps.extend_from_slice(&payment_data[0..32]);
ps.extend(encode_tu64(total_amt));
payload.insert(TLV_PAYMENT_SECRET, ps);
- let payload_bytes = ok_or_continue!(payload
- .to_bytes()
- .context("failed to encode payload as bytes"));
+ let payload_bytes = ok_or_continue!(
+ payload
+ .to_bytes()
+ .context("failed to encode payload as bytes")
+ );
info!(
"Amended onion payload with forward_amt={} and total_msat={}",
@@ -659,9 +671,11 @@ async fn on_openchannel(
let dir = p.configuration().lightning_dir;
let rpc_path = Path::new(&dir).join(&p.configuration().rpc_file);
- let mut cln_client = ok_or_continue!(cln_rpc::ClnRpc::new(rpc_path.clone())
- .await
- .context("failed to connect to core-lightning"));
+ let mut cln_client = ok_or_continue!(
+ cln_rpc::ClnRpc::new(rpc_path.clone())
+ .await
+ .context("failed to connect to core-lightning")
+ );
let ds_req = ListdatastoreRequest {
key: Some(vec![
@@ -670,10 +684,12 @@ async fn on_openchannel(
req.openchannel.id.clone(),
]),
};
- let ds_res = ok_or_continue!(cln_client
- .call_typed(&ds_req)
- .await
- .context("failed to get datastore record"));
+ let ds_res = ok_or_continue!(
+ cln_client
+ .call_typed(&ds_req)
+ .await
+ .context("failed to get datastore record")
+ );
if let Some(_rec) = ds_res.datastore.iter().next() {
info!(
@@ -766,7 +782,7 @@ async fn check_peer_lsp_status(
return Ok(PeerLspStatus {
connected: false,
has_lsp_feature: false,
- })
+ });
}
Some(p) => p,
};
diff --git a/plugins/lsps-plugin/src/cln_adapters/rpc.rs b/plugins/lsps-plugin/src/cln_adapters/rpc.rs
index 3471d583..01d846da 100644
--- a/plugins/lsps-plugin/src/cln_adapters/rpc.rs
+++ b/plugins/lsps-plugin/src/cln_adapters/rpc.rs
@@ -15,6 +15,7 @@ use anyhow::{Context, Result};
use async_trait::async_trait;
use bitcoin::secp256k1::PublicKey;
use cln_rpc::{
+ ClnRpc,
model::{
requests::{
DatastoreMode, DatastoreRequest, DeldatastoreRequest, FundchannelRequest,
@@ -23,7 +24,6 @@ use cln_rpc::{
responses::ListdatastoreResponse,
},
primitives::{Amount, AmountOrAll, ChannelState, Sha256, ShortChannelId},
- ClnRpc,
};
use core::fmt;
use serde::Serialize;
diff --git a/plugins/lsps-plugin/src/cln_adapters/sender.rs b/plugins/lsps-plugin/src/cln_adapters/sender.rs
index 39a73acd..b5c76ae4 100644
--- a/plugins/lsps-plugin/src/cln_adapters/sender.rs
+++ b/plugins/lsps-plugin/src/cln_adapters/sender.rs
@@ -4,7 +4,7 @@ use crate::{
};
use async_trait::async_trait;
use bitcoin::secp256k1::PublicKey;
-use cln_rpc::{model::requests::SendcustommsgRequest, ClnRpc};
+use cln_rpc::{ClnRpc, model::requests::SendcustommsgRequest};
use std::path::PathBuf;
#[derive(Clone)]
diff --git a/plugins/lsps-plugin/src/core/lsps2/htlc.rs b/plugins/lsps-plugin/src/core/lsps2/htlc.rs
index 6e39cc07..5fa341ac 100644
--- a/plugins/lsps-plugin/src/core/lsps2/htlc.rs
+++ b/plugins/lsps-plugin/src/core/lsps2/htlc.rs
@@ -1,14 +1,13 @@
use crate::{
core::{
lsps2::provider::{DatastoreProvider, LightningProvider, Lsps2OfferProvider},
- tlv::{TlvStream, TLV_FORWARD_AMT},
+ tlv::{TLV_FORWARD_AMT, TlvStream},
},
proto::{
lsps0::{Msat, ShortChannelId},
lsps2::{
- compute_opening_fee,
+ Lsps2PolicyGetChannelCapacityRequest, compute_opening_fee,
failure_codes::{TEMPORARY_CHANNEL_FAILURE, UNKNOWN_NEXT_PEER},
- Lsps2PolicyGetChannelCapacityRequest,
},
},
};
@@ -160,12 +159,12 @@ impl<A: DatastoreProvider + Lsps2OfferProvider + LightningProvider> HtlcAccepted
reason: RejectReason::InsufficientForFee {
fee: Msat::from_msat(fee),
},
- })
+ });
}
None => {
return Ok(HtlcDecision::Reject {
reason: RejectReason::FeeOverflow,
- })
+ });
}
};
@@ -186,7 +185,7 @@ impl<A: DatastoreProvider + Lsps2OfferProvider + LightningProvider> HtlcAccepted
None => {
return Ok(HtlcDecision::Reject {
reason: RejectReason::PolicyDenied,
- })
+ });
}
};
@@ -243,9 +242,9 @@ mod tests {
DatastoreEntry, Lsps2PolicyGetChannelCapacityResponse, Lsps2PolicyGetInfoRequest,
Lsps2PolicyGetInfoResponse, OpeningFeeParams, Promise,
};
- use anyhow::{anyhow, Result as AnyResult};
+ use anyhow::{Result as AnyResult, anyhow};
use async_trait::async_trait;
- use bitcoin::hashes::{sha256::Hash as Sha256, Hash};
+ use bitcoin::hashes::{Hash, sha256::Hash as Sha256};
use bitcoin::secp256k1::PublicKey;
use chrono::{TimeZone, Utc};
use std::sync::atomic::{AtomicUsize, Ordering};
diff --git a/plugins/lsps-plugin/src/core/lsps2/service.rs b/plugins/lsps-plugin/src/core/lsps2/service.rs
index a3ab3240..4963e51a 100644
--- a/plugins/lsps-plugin/src/core/lsps2/service.rs
+++ b/plugins/lsps-plugin/src/core/lsps2/service.rs
@@ -146,7 +146,7 @@ mod tests {
Lsps2PolicyGetChannelCapacityResponse, Lsps2PolicyGetInfoResponse, OpeningFeeParams,
PolicyOpeningFeeParams, Promise,
};
- use anyhow::{anyhow, Result as AnyResult};
+ use anyhow::{Result as AnyResult, anyhow};
use chrono::{TimeZone, Utc};
use std::sync::{Arc, Mutex};
diff --git a/plugins/lsps-plugin/src/core/router.rs b/plugins/lsps-plugin/src/core/router.rs
index 63b84b68..51130ff9 100644
--- a/plugins/lsps-plugin/src/core/router.rs
+++ b/plugins/lsps-plugin/src/core/router.rs
@@ -1,6 +1,6 @@
use crate::proto::jsonrpc::{RpcError, RpcErrorExt};
use bitcoin::secp256k1::PublicKey;
-use serde::{de::DeserializeOwned, Deserialize, Serialize};
+use serde::{Deserialize, Serialize, de::DeserializeOwned};
use serde_json::value::RawValue;
use std::{collections::HashMap, future::Future, pin::Pin};
@@ -124,7 +124,7 @@ impl JsonRpcRouter {
return Some(error_response(
None,
RpcError::parse_error("failed to parse request"),
- ))
+ ));
}
};
diff --git a/plugins/lsps-plugin/src/core/tlv.rs b/plugins/lsps-plugin/src/core/tlv.rs
index 7bf74442..8023e2c4 100644
--- a/plugins/lsps-plugin/src/core/tlv.rs
+++ b/plugins/lsps-plugin/src/core/tlv.rs
@@ -1,4 +1,4 @@
-use serde::{de::Error as DeError, Deserialize, Deserializer, Serialize, Serializer};
+use serde::{Deserialize, Deserializer, Serialize, Serializer, de::Error as DeError};
use std::{convert::TryFrom, fmt};
use thiserror::Error;
@@ -411,7 +411,7 @@ mod tests {
]);
let bytes = stream.to_bytes()?; // just ensure it encodes
- // Decode back to confirm roundtrip/canonical encodings accepted
+ // Decode back to confirm roundtrip/canonical encodings accepted
let back = TlvStream::from_bytes(&bytes)?;
assert_eq!(back.0[0].type_, 0x00fc);
assert_eq!(back.0[1].type_, 0x00fd);
diff --git a/plugins/lsps-plugin/src/core/transport.rs b/plugins/lsps-plugin/src/core/transport.rs
index e66d1652..297fa67d 100644
--- a/plugins/lsps-plugin/src/core/transport.rs
+++ b/plugins/lsps-plugin/src/core/transport.rs
@@ -2,10 +2,10 @@ use crate::proto::jsonrpc::{JsonRpcResponse, RequestObject};
use async_trait::async_trait;
use bitcoin::secp256k1::PublicKey;
use core::fmt::Debug;
-use serde::{de::DeserializeOwned, Serialize};
+use serde::{Serialize, de::DeserializeOwned};
use std::{collections::HashMap, sync::Arc, time::Duration};
use thiserror::Error;
-use tokio::sync::{oneshot, Mutex};
+use tokio::sync::{Mutex, oneshot};
/// Transport-specific errors that may occur when sending or receiving JSON-RPC
/// messages.
diff --git a/plugins/lsps-plugin/src/proto/jsonrpc.rs b/plugins/lsps-plugin/src/proto/jsonrpc.rs
index 24b30713..52eb07a8 100644
--- a/plugins/lsps-plugin/src/proto/jsonrpc.rs
+++ b/plugins/lsps-plugin/src/proto/jsonrpc.rs
@@ -1,5 +1,5 @@
-use rand::{rngs::OsRng, TryRngCore as _};
-use serde::{de::DeserializeOwned, Deserialize, Serialize};
+use rand::{TryRngCore as _, rngs::OsRng};
+use serde::{Deserialize, Serialize, de::DeserializeOwned};
use serde_json::{self, Value};
use std::fmt;
@@ -225,12 +225,12 @@ impl<'de, R: DeserializeOwned> Deserialize<'de> for JsonRpcResponse<R> {
(Some(_), Some(_)) => {
return Err(serde::de::Error::custom(
"Response cannot have both result and error",
- ))
+ ));
}
(None, None) => {
return Err(serde::de::Error::custom(
"Response must have either result or error",
- ))
+ ));
}
};
@@ -420,9 +420,11 @@ mod test_message_serialization {
const METHOD: &'static str = "say_hello";
}
let rpc_request = SayHelloRequest.into_request();
- assert!(!serde_json::to_string(&rpc_request)
- .expect("could not convert to json")
- .contains("\"params\""));
+ assert!(
+ !serde_json::to_string(&rpc_request)
+ .expect("could not convert to json")
+ .contains("\"params\"")
+ );
}
#[test]
diff --git a/plugins/lsps-plugin/src/proto/lsps0.rs b/plugins/lsps-plugin/src/proto/lsps0.rs
index 2cb72812..433d1063 100644
--- a/plugins/lsps-plugin/src/proto/lsps0.rs
+++ b/plugins/lsps-plugin/src/proto/lsps0.rs
@@ -1,6 +1,6 @@
use crate::proto::jsonrpc::{JsonRpcRequest, RpcError};
use core::fmt;
-use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
+use serde::{Deserialize, Deserializer, Serialize, Serializer, de};
use thiserror::Error;
const MSAT_PER_SAT: u64 = 1_000;
diff --git a/plugins/lsps-plugin/src/proto/lsps2.rs b/plugins/lsps-plugin/src/proto/lsps2.rs
index 82767a27..32988da3 100644
--- a/plugins/lsps-plugin/src/proto/lsps2.rs
+++ b/plugins/lsps-plugin/src/proto/lsps2.rs
@@ -2,7 +2,7 @@ use crate::proto::{
jsonrpc::{JsonRpcRequest, RpcError},
lsps0::{DateTime, Msat, Ppm, ShortChannelId},
};
-use bitcoin::hashes::{sha256, Hash, HashEngine, Hmac, HmacEngine};
+use bitcoin::hashes::{Hash, HashEngine, Hmac, HmacEngine, sha256};
use chrono::Utc;
use log::debug;
use serde::{Deserialize, Serialize};
@@ -66,7 +66,7 @@ pub trait ShortChannelIdJITExt {
impl ShortChannelIdJITExt for ShortChannelId {
fn generate_jit(blockheight: u32, distance: u32) -> Self {
- use rand::{rng, Rng as _};
+ use rand::{Rng as _, rng};
let mut rng = rng();
let block = blockheight + distance;
@@ -428,10 +428,12 @@ mod tests {
let result = serde_json::from_str::<TestData>(&json);
assert!(result.is_err());
// Check the error message relates to our PromiseError
- assert!(result
- .unwrap_err()
- .to_string()
- .contains("promise string is too long"));
+ assert!(
+ result
+ .unwrap_err()
+ .to_string()
+ .contains("promise string is too long")
+ );
}
#[test]
@@ -442,10 +444,12 @@ mod tests {
assert!(result.is_err());
// This error occurs when Serde tries to deserialize 123 as the String
// required by `try_from = "String"`.
- assert!(result
- .unwrap_err()
- .to_string()
- .contains("invalid type: integer"));
+ assert!(
+ result
+ .unwrap_err()
+ .to_string()
+ .contains("invalid type: integer")
+ );
}
#[test]
diff --git a/plugins/lsps-plugin/src/service.rs b/plugins/lsps-plugin/src/service.rs
index 2e9ae10c..2e58d57b 100644
--- a/plugins/lsps-plugin/src/service.rs
+++ b/plugins/lsps-plugin/src/service.rs
@@ -12,9 +12,9 @@ use cln_lsps::{
},
server::LspsService,
},
- proto::lsps0::{Msat, LSPS0_MESSAGE_TYPE},
+ proto::lsps0::{LSPS0_MESSAGE_TYPE, Msat},
};
-use cln_plugin::{options, HookBuilder, HookFilter, Plugin};
+use cln_plugin::{HookBuilder, HookFilter, Plugin, options};
use log::{debug, error, trace};
use std::path::{Path, PathBuf};
use std::sync::Arc;
diff --git a/plugins/rest-plugin/src/certs.rs b/plugins/rest-plugin/src/certs.rs
index e6ab6134..540ba054 100644
--- a/plugins/rest-plugin/src/certs.rs
+++ b/plugins/rest-plugin/src/certs.rs
@@ -12,7 +12,9 @@ pub fn generate_certificates(certs_path: &PathBuf, rest_host: &str) -> Result<()
"localhost".to_string(),
])?;
ca_params.is_ca = rcgen::IsCa::Ca(rcgen::BasicConstraints::Unconstrained);
- ca_params.key_usages.push(rcgen::KeyUsagePurpose::KeyCertSign);
+ ca_params
+ .key_usages
+ .push(rcgen::KeyUsagePurpose::KeyCertSign);
ca_params.use_authority_key_identifier_extension = true;
let ca_key = KeyPair::generate()?;
let ca_cert = ca_params.self_signed(&ca_key)?;
@@ -32,9 +34,15 @@ pub fn generate_certificates(certs_path: &PathBuf, rest_host: &str) -> Result<()
"localhost".to_string(),
])?;
server_params.is_ca = rcgen::IsCa::NoCa;
- server_params.key_usages.push(rcgen::KeyUsagePurpose::DigitalSignature);
- server_params.key_usages.push(rcgen::KeyUsagePurpose::KeyEncipherment);
- server_params.key_usages.push(rcgen::KeyUsagePurpose::KeyAgreement);
+ server_params
+ .key_usages
+ .push(rcgen::KeyUsagePurpose::DigitalSignature);
+ server_params
+ .key_usages
+ .push(rcgen::KeyUsagePurpose::KeyEncipherment);
+ server_params
+ .key_usages
+ .push(rcgen::KeyUsagePurpose::KeyAgreement);
server_params.use_authority_key_identifier_extension = true;
server_params.distinguished_name = DistinguishedName::new();
server_params
diff --git a/plugins/rest-plugin/src/handlers.rs b/plugins/rest-plugin/src/handlers.rs
index e79c25e6..77bb6375 100644
--- a/plugins/rest-plugin/src/handlers.rs
+++ b/plugins/rest-plugin/src/handlers.rs
@@ -2,7 +2,7 @@ use std::{collections::HashMap, process};
use anyhow::anyhow;
use axum::{
- body::{to_bytes, Body},
+ body::{Body, to_bytes},
extract::{Extension, Json, Path},
http::{self, Request, StatusCode},
middleware::Next,
@@ -10,17 +10,17 @@ use axum::{
};
use cln_plugin::Plugin;
use cln_rpc::{
- model::{requests::HelpRequest, responses::HelpResponse},
RpcError,
+ model::{requests::HelpRequest, responses::HelpResponse},
};
use serde_json::json;
use socketioxide::extract::{Data, SocketRef};
use std::fmt::Write;
use crate::{
+ SWAGGER_FALLBACK,
shared::{call_rpc, filter_json, path_to_rest_map_and_params, verify_rune},
structs::{AppError, CheckRuneParams, ClnrestMap, PluginState},
- SWAGGER_FALLBACK,
};
/* Handler for list-methods */
@@ -122,7 +122,7 @@ pub async fn call_rpc_method(
code: None,
data: None,
message: format!("Could not read request body: {}", e),
- }))
+ }));
}
};
diff --git a/plugins/rest-plugin/src/main.rs b/plugins/rest-plugin/src/main.rs
index 1a44c77b..5908b2c7 100644
--- a/plugins/rest-plugin/src/main.rs
+++ b/plugins/rest-plugin/src/main.rs
@@ -8,10 +8,10 @@ use std::{
use anyhow::anyhow;
use axum::{
+ Extension, Router,
http::{HeaderName, HeaderValue},
middleware,
routing::{any, get},
- Extension, Router,
};
use axum_server::tls_rustls::RustlsConfig;
use certs::{do_certificates_exist, generate_certificates};
@@ -22,7 +22,7 @@ use handlers::{
};
use options::*;
use serde_json::json;
-use socketioxide::{handler::ConnectHandler, SocketIo, SocketIoBuilder};
+use socketioxide::{SocketIo, SocketIoBuilder, handler::ConnectHandler};
use tokio::{
sync::mpsc::{self, Receiver},
time,
diff --git a/plugins/rest-plugin/src/options.rs b/plugins/rest-plugin/src/options.rs
index 48b27ffc..0c13d20e 100644
--- a/plugins/rest-plugin/src/options.rs
+++ b/plugins/rest-plugin/src/options.rs
@@ -7,17 +7,17 @@ use std::{
use anyhow::anyhow;
use axum::http::HeaderValue;
use cln_plugin::{
+ ConfiguredPlugin,
options::{
ConfigOption, DefaultStringArrayConfigOption, DefaultStringConfigOption,
IntegerConfigOption, StringConfigOption,
},
- ConfiguredPlugin,
};
use tower_http::cors::{Any, CorsLayer};
use crate::{
- structs::{ClnrestOptions, ClnrestProtocol},
PluginState,
+ structs::{ClnrestOptions, ClnrestProtocol},
};
pub const OPT_CLNREST_PORT: IntegerConfigOption =
@@ -94,7 +94,7 @@ pub fn parse_options(
let swagger = match plugin.option(&OPT_CLNREST_SWAGGER)? {
swag if !swag.starts_with('/') => {
- return Err(anyhow!("`clnrest-swagger-root` must start with `/`"))
+ return Err(anyhow!("`clnrest-swagger-root` must start with `/`"));
}
swag => swag,
};
diff --git a/plugins/rest-plugin/src/shared.rs b/plugins/rest-plugin/src/shared.rs
index 4568fcc5..0f4731a7 100644
--- a/plugins/rest-plugin/src/shared.rs
+++ b/plugins/rest-plugin/src/shared.rs
@@ -1,12 +1,12 @@
use axum::http;
use cln_plugin::Plugin;
use cln_rpc::{
- model::responses::{CheckruneResponse, ShowrunesResponse},
ClnRpc, RpcError,
+ model::responses::{CheckruneResponse, ShowrunesResponse},
};
use serde_json::json;
-use crate::{structs::AppError, CheckRuneParams, ClnrestMap, PluginState};
+use crate::{CheckRuneParams, ClnrestMap, PluginState, structs::AppError};
pub async fn verify_rune(
plugin: &Plugin<PluginState>,
diff --git a/plugins/rest-plugin/src/structs.rs b/plugins/rest-plugin/src/structs.rs
index a49dfd7e..0cc0ce10 100644
--- a/plugins/rest-plugin/src/structs.rs
+++ b/plugins/rest-plugin/src/structs.rs
@@ -16,11 +16,11 @@ use serde_json::json;
use tokio::sync::mpsc::Sender;
use tower_http::cors::CorsLayer;
use utoipa::{
+ Modify, OpenApi,
openapi::{
- security::{ApiKey, ApiKeyValue, SecurityScheme},
Components,
+ security::{ApiKey, ApiKeyValue, SecurityScheme},
},
- Modify, OpenApi,
};
#[derive(Debug)]
diff --git a/plugins/src/lib.rs b/plugins/src/lib.rs
index e9a3a10d..f29fc0ba 100644
--- a/plugins/src/lib.rs
+++ b/plugins/src/lib.rs
@@ -336,7 +336,7 @@ where
None => {
return Err(anyhow!(
"Lost connection to lightning expecting getmanifest"
- ))
+ ));
}
};
let (init_id, configuration) = match input.next().await {
@@ -834,10 +834,14 @@ where
trace!("Received a message: {:?}", msg);
match msg {
messages::JsonRpc::Request(_id, _p) => {
- todo!("This is unreachable until we start filling in messages:Request. Until then the custom dispatcher below is used exclusively.");
+ todo!(
+ "This is unreachable until we start filling in messages:Request. Until then the custom dispatcher below is used exclusively."
+ );
}
messages::JsonRpc::Notification(_n) => {
- todo!("As soon as we define the full structure of the messages::Notification we'll get here. Until then the custom dispatcher below is used.")
+ todo!(
+ "As soon as we define the full structure of the messages::Notification we'll get here. Until then the custom dispatcher below is used."
+ )
}
messages::JsonRpc::CustomRequest(id, request) => {
trace!("Dispatching custom method {:?}", request);
diff --git a/plugins/src/logging.rs b/plugins/src/logging.rs
index 1d4e2c1b..02e5df44 100644
--- a/plugins/src/logging.rs
+++ b/plugins/src/logging.rs
@@ -4,8 +4,8 @@ use futures::SinkExt;
use serde::Serialize;
use std::sync::Arc;
use tokio::io::AsyncWrite;
-use tokio::sync::mpsc;
use tokio::sync::Mutex;
+use tokio::sync::mpsc;
use tokio_util::codec::FramedWrite;
#[derive(Clone, Debug, Serialize)]
@@ -74,8 +74,8 @@ where
mod trace {
use super::*;
use tracing::Level;
- use tracing_subscriber::prelude::*;
use tracing_subscriber::Layer;
+ use tracing_subscriber::prelude::*;
/// Initialize the logger starting a flusher to the passed in sink.
pub fn init<O>(out: Arc<Mutex<FramedWrite<O, JsonCodec>>>) -> Result<(), log::SetLoggerError>
diff --git a/plugins/src/messages.rs b/plugins/src/messages.rs
index 4ed65c27..30d4d22e 100644
--- a/plugins/src/messages.rs
+++ b/plugins/src/messages.rs
@@ -1,5 +1,5 @@
-use crate::options::UntypedConfigOption;
use crate::HookFilter;
+use crate::options::UntypedConfigOption;
use serde::de::{self, Deserializer};
use serde::{Deserialize, Serialize};
use serde_json::Value;
diff --git a/plugins/src/options.rs b/plugins/src/options.rs
index 6ede6f81..cfe8d12f 100644
--- a/plugins/src/options.rs
+++ b/plugins/src/options.rs
@@ -132,8 +132,8 @@
//! Ok(())
//! }
//! ```
-use serde::ser::{SerializeSeq, Serializer};
use serde::Serialize;
+use serde::ser::{SerializeSeq, Serializer};
pub mod config_type {
#[derive(Clone, Debug)]
diff --git a/plugins/wss-proxy-plugin/src/certs.rs b/plugins/wss-proxy-plugin/src/certs.rs
index b08b7d3e..e4aa48ef 100644
--- a/plugins/wss-proxy-plugin/src/certs.rs
+++ b/plugins/wss-proxy-plugin/src/certs.rs
@@ -1,8 +1,8 @@
-use anyhow::{anyhow, Error};
+use anyhow::{Error, anyhow};
use rcgen::{CertificateParams, DistinguishedName, Ia5String, KeyPair};
+use rustls::ServerConfig;
use rustls::pki_types::pem::PemObject;
use rustls::pki_types::{CertificateDer, PrivateKeyDer};
-use rustls::ServerConfig;
use std::fs;
use std::net::IpAddr;
use std::path::{Path, PathBuf};
@@ -18,7 +18,9 @@ pub fn generate_certificates(certs_path: &PathBuf, wss_host: &[String]) -> Resul
"localhost".to_string(),
])?;
ca_params.is_ca = rcgen::IsCa::Ca(rcgen::BasicConstraints::Unconstrained);
- ca_params.key_usages.push(rcgen::KeyUsagePurpose::KeyCertSign);
+ ca_params
+ .key_usages
+ .push(rcgen::KeyUsagePurpose::KeyCertSign);
ca_params.use_authority_key_identifier_extension = true;
let ca_key = KeyPair::generate()?;
let ca_cert = ca_params.self_signed(&ca_key)?;
@@ -38,9 +40,15 @@ pub fn generate_certificates(certs_path: &PathBuf, wss_host: &[String]) -> Resul
"localhost".to_string(),
])?;
server_params.is_ca = rcgen::IsCa::NoCa;
- server_params.key_usages.push(rcgen::KeyUsagePurpose::DigitalSignature);
- server_params.key_usages.push(rcgen::KeyUsagePurpose::KeyEncipherment);
- server_params.key_usages.push(rcgen::KeyUsagePurpose::KeyAgreement);
+ server_params
+ .key_usages
+ .push(rcgen::KeyUsagePurpose::DigitalSignature);
+ server_params
+ .key_usages
+ .push(rcgen::KeyUsagePurpose::KeyEncipherment);
+ server_params
+ .key_usages
+ .push(rcgen::KeyUsagePurpose::KeyAgreement);
server_params.use_authority_key_identifier_extension = true;
server_params.distinguished_name = DistinguishedName::new();
server_params
diff --git a/plugins/wss-proxy-plugin/src/main.rs b/plugins/wss-proxy-plugin/src/main.rs
index 3439c076..c058b6c3 100644
--- a/plugins/wss-proxy-plugin/src/main.rs
+++ b/plugins/wss-proxy-plugin/src/main.rs
@@ -2,14 +2,14 @@ use std::{net::SocketAddr, process, sync::Arc};
use anyhow::anyhow;
use certs::get_tls_config;
-use cln_plugin::{options::ConfigOption, Builder};
+use cln_plugin::{Builder, options::ConfigOption};
use futures_util::{SinkExt, StreamExt};
-use options::{parse_options, WssproxyOptions, OPT_WSS_BIND_ADDR, OPT_WSS_CERTS_DIR};
+use options::{OPT_WSS_BIND_ADDR, OPT_WSS_CERTS_DIR, WssproxyOptions, parse_options};
use rustls::ServerConfig;
use tokio::net::{TcpListener, TcpStream};
-use tokio_rustls::{server::TlsStream, TlsAcceptor};
-use tokio_tungstenite::{accept_async, WebSocketStream};
+use tokio_rustls::{TlsAcceptor, server::TlsStream};
+use tokio_tungstenite::{WebSocketStream, accept_async};
mod certs;
mod options;
diff --git a/plugins/wss-proxy-plugin/src/options.rs b/plugins/wss-proxy-plugin/src/options.rs
index 70f4fa88..03b366d7 100644
--- a/plugins/wss-proxy-plugin/src/options.rs
+++ b/plugins/wss-proxy-plugin/src/options.rs
@@ -5,7 +5,7 @@ use std::{
use anyhow::anyhow;
use cln_plugin::ConfiguredPlugin;
-use cln_rpc::{model::requests::ListconfigsRequest, ClnRpc};
+use cln_rpc::{ClnRpc, model::requests::ListconfigsRequest};
pub const OPT_WSS_BIND_ADDR: &str = "wss-bind-addr";
pub const OPT_WSS_CERTS_DIR: &str = "wss-certs";
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.