add rustfmt.toml and apply it

This commit is contained in:
daywalker90 2025-11-10 15:36:56 +01:00
parent c609f22331
commit bd5fa21e6f
No known key found for this signature in database
11 changed files with 98 additions and 80 deletions

4
.rustfmt.toml Normal file
View file

@ -0,0 +1,4 @@
imports_granularity = "Crate"
group_imports = "StdExternalCrate"
imports_layout = "HorizontalVertical"
unstable_features = true

View file

@ -3,10 +3,10 @@ use std::{path::Path, time::Duration};
use anyhow::anyhow;
use cln_plugin::{
options::{ConfigOption, DefaultBooleanConfigOption, StringArrayConfigOption},
Builder, Plugin,
Builder,
Plugin,
};
use cln_rpc::{model::requests::ListdatastoreRequest, ClnRpc};
use nostr_sdk::nips::nip47;
use nwc::run_nwc;
use nwc_notifications::{payment_received_handler, payment_sent_handler};

View file

@ -1,44 +1,45 @@
use std::borrow::Cow;
use std::time::Duration;
use std::{borrow::Cow, time::Duration};
use crate::nwc_balance::get_balance_response;
use crate::nwc_hold::{
cancel_hold_invoice_response, make_hold_invoice_response, settle_hold_invoice_response,
};
use crate::nwc_info::get_info_response;
use crate::nwc_invoice::make_invoice_response;
use crate::nwc_keysend::{multi_pay_keysend, pay_keysend_response};
use crate::nwc_lookups::{list_transactions_response, lookup_invoice_response};
use crate::nwc_pay::{multi_pay_invoice, pay_invoice_response};
use crate::structs::{NwcStore, PluginState};
use crate::tasks::budget_task;
use crate::util::{build_capabilities, build_notifications_vec, is_read_only_nwc};
use crate::OPT_NOTIFICATIONS;
use anyhow::anyhow;
use cln_plugin::Plugin;
use nostr_sdk::client;
use nostr_sdk::nips::nip04;
use nostr_sdk::nips::nip44;
use nostr_sdk::nips::nip47;
use nostr_sdk::nostr::Filter;
use nostr_sdk::nostr::Kind;
use nostr_sdk::nostr::Tag;
use nostr_sdk::Alphabet;
use nostr_sdk::Client;
use nostr_sdk::Event;
use nostr_sdk::EventBuilder;
use nostr_sdk::EventId;
use nostr_sdk::Keys;
use nostr_sdk::PublicKey;
use nostr_sdk::RelayPoolNotification;
use nostr_sdk::RelayStatus;
use nostr_sdk::SecretKey;
use nostr_sdk::SignerError;
use nostr_sdk::SingleLetterTag;
use nostr_sdk::TagKind;
use nostr_sdk::Timestamp;
use tokio::sync::oneshot;
use tokio::time;
use nostr_sdk::{
client,
nips::{nip04, nip44, nip47},
nostr::{Filter, Kind, Tag},
Alphabet,
Client,
Event,
EventBuilder,
EventId,
Keys,
PublicKey,
RelayPoolNotification,
RelayStatus,
SecretKey,
SignerError,
SingleLetterTag,
TagKind,
Timestamp,
};
use tokio::{sync::oneshot, time};
use crate::{
nwc_balance::get_balance_response,
nwc_hold::{
cancel_hold_invoice_response,
make_hold_invoice_response,
settle_hold_invoice_response,
},
nwc_info::get_info_response,
nwc_invoice::make_invoice_response,
nwc_keysend::{multi_pay_keysend, pay_keysend_response},
nwc_lookups::{list_transactions_response, lookup_invoice_response},
nwc_pay::{multi_pay_invoice, pay_invoice_response},
structs::{NwcStore, PluginState},
tasks::budget_task,
util::{build_capabilities, build_notifications_vec, is_read_only_nwc},
OPT_NOTIFICATIONS,
};
pub async fn run_nwc(
plugin: Plugin<PluginState>,

View file

@ -1,7 +1,7 @@
use cln_plugin::Plugin;
use nostr_sdk::nips::nip47;
use crate::structs::PluginState;
use nostr_sdk::nips::nip47;
pub async fn make_hold_invoice_response(
_plugin: Plugin<PluginState>,

View file

@ -1,10 +1,12 @@
use cln_plugin::Plugin;
use cln_rpc::model::requests::GetinfoRequest;
use crate::structs::PluginState;
use crate::util::{build_methods_vec, build_notifications_vec, is_read_only_nwc, load_nwc_store};
use nostr_sdk::nips::nip47;
use crate::{
structs::PluginState,
util::{build_methods_vec, build_notifications_vec, is_read_only_nwc, load_nwc_store},
};
pub async fn get_info_response(
plugin: Plugin<PluginState>,
label: &str,

View file

@ -5,14 +5,16 @@ use cln_rpc::{
model::{
requests::{DecodeRequest, ListinvoicesRequest, ListpaysRequest},
responses::{
ListinvoicesInvoices, ListinvoicesInvoicesStatus, ListpaysPays, ListpaysPaysStatus,
ListinvoicesInvoices,
ListinvoicesInvoicesStatus,
ListpaysPays,
ListpaysPaysStatus,
},
},
primitives::Sha256,
ClnRpc,
};
use nostr_sdk::nips::nip47;
use nostr_sdk::Timestamp;
use nostr_sdk::{nips::nip47, Timestamp};
use crate::structs::{PluginState, NOT_INV_ERR};

View file

@ -2,23 +2,31 @@ use std::str::FromStr;
use anyhow::anyhow;
use cln_plugin::Plugin;
use cln_rpc::model::requests::{DecodeRequest, ListinvoicesRequest, ListpaysRequest};
use cln_rpc::model::responses::{
DecodeResponse, ListinvoicesInvoices, ListinvoicesInvoicesStatus, ListpaysPays,
use cln_rpc::{
model::{
requests::{DecodeRequest, ListinvoicesRequest, ListpaysRequest},
responses::{
DecodeResponse,
ListinvoicesInvoices,
ListinvoicesInvoicesStatus,
ListpaysPays,
ListpaysPaysStatus,
},
},
primitives::Sha256,
ClnRpc,
};
use nostr_sdk::{
nips::nip47,
nostr::{key::PublicKey, EventBuilder, Kind, Tag},
Client,
Timestamp,
};
use cln_rpc::primitives::Sha256;
use cln_rpc::ClnRpc;
use crate::structs::{PluginState, NOT_INV_ERR};
use crate::OPT_NOTIFICATIONS;
use nostr_sdk::nips::nip47;
use nostr_sdk::nostr::key::PublicKey;
use nostr_sdk::nostr::EventBuilder;
use nostr_sdk::nostr::Kind;
use nostr_sdk::nostr::Tag;
use nostr_sdk::{Client, Timestamp};
use crate::{
structs::{PluginState, NOT_INV_ERR},
OPT_NOTIFICATIONS,
};
pub async fn payment_received_handler(
plugin: Plugin<PluginState>,

View file

@ -7,7 +7,8 @@ use cln_rpc::{
responses::DecodeResponse,
},
primitives::{Amount, Secret},
ClnRpc, RpcError,
ClnRpc,
RpcError,
};
use nostr_sdk::nips::nip47;
use tokio::time;

View file

@ -1,22 +1,21 @@
use anyhow::anyhow;
use cln_plugin::Plugin;
use cln_rpc::model::requests::{
DatastoreMode, DatastoreRequest, DeldatastoreRequest, ListdatastoreRequest,
DatastoreMode,
DatastoreRequest,
DeldatastoreRequest,
ListdatastoreRequest,
};
use nostr_sdk::nips::nip47::NostrWalletConnectURI;
use nostr_sdk::Keys;
use nostr_sdk::SecretKey;
use nostr_sdk::Timestamp;
use nostr_sdk::{nips::nip47::NostrWalletConnectURI, Keys, SecretKey, Timestamp};
use serde_json::json;
use crate::nwc::{
run_nwc, send_nwc_info_event, start_nwc_budget_job, stop_nwc, stop_nwc_budget_job,
use crate::{
nwc::{run_nwc, send_nwc_info_event, start_nwc_budget_job, stop_nwc, stop_nwc_budget_job},
parse::parse_time_period,
structs::{BudgetIntervalConfig, NwcStore, PluginState},
util::{build_capabilities, is_read_only_nwc, load_nwc_store, update_nwc_store},
PLUGIN_NAME,
};
use crate::parse::parse_time_period;
use crate::structs::{BudgetIntervalConfig, NwcStore, PluginState};
use crate::util::build_capabilities;
use crate::util::{is_read_only_nwc, load_nwc_store, update_nwc_store};
use crate::PLUGIN_NAME;
pub async fn nwc_create(
plugin: Plugin<PluginState>,

View file

@ -1,9 +1,7 @@
use std::{collections::HashMap, path::PathBuf, str::FromStr, sync::Arc};
use cln_rpc::ClnRpc;
use nostr_sdk::client;
use nostr_sdk::nips::nip47;
use nostr_sdk::nostr;
use nostr_sdk::{client, nips::nip47, nostr};
use parking_lot::Mutex;
use serde::{Deserialize, Serialize};
use tokio::sync::oneshot;

View file

@ -4,12 +4,15 @@ use cln_rpc::{
model::requests::{DatastoreMode, DatastoreRequest, ListdatastoreRequest},
ClnRpc,
};
use nostr_sdk::nips::nip47;
use crate::{
structs::{NwcStore, PluginState},
OPT_NOTIFICATIONS, PLUGIN_NAME, WALLET_NOTIFICATIONS, WALLET_PAY_METHODS, WALLET_READ_METHODS,
OPT_NOTIFICATIONS,
PLUGIN_NAME,
WALLET_NOTIFICATIONS,
WALLET_PAY_METHODS,
WALLET_READ_METHODS,
};
pub fn budget_amount_check(