mirror of
https://github.com/daywalker90/cln-nip47.git
synced 2026-08-13 12:33:43 +02:00
add rustfmt.toml and apply it
This commit is contained in:
parent
c609f22331
commit
bd5fa21e6f
11 changed files with 98 additions and 80 deletions
4
.rustfmt.toml
Normal file
4
.rustfmt.toml
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
imports_granularity = "Crate"
|
||||||
|
group_imports = "StdExternalCrate"
|
||||||
|
imports_layout = "HorizontalVertical"
|
||||||
|
unstable_features = true
|
||||||
|
|
@ -3,10 +3,10 @@ use std::{path::Path, time::Duration};
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use cln_plugin::{
|
use cln_plugin::{
|
||||||
options::{ConfigOption, DefaultBooleanConfigOption, StringArrayConfigOption},
|
options::{ConfigOption, DefaultBooleanConfigOption, StringArrayConfigOption},
|
||||||
Builder, Plugin,
|
Builder,
|
||||||
|
Plugin,
|
||||||
};
|
};
|
||||||
use cln_rpc::{model::requests::ListdatastoreRequest, ClnRpc};
|
use cln_rpc::{model::requests::ListdatastoreRequest, ClnRpc};
|
||||||
|
|
||||||
use nostr_sdk::nips::nip47;
|
use nostr_sdk::nips::nip47;
|
||||||
use nwc::run_nwc;
|
use nwc::run_nwc;
|
||||||
use nwc_notifications::{payment_received_handler, payment_sent_handler};
|
use nwc_notifications::{payment_received_handler, payment_sent_handler};
|
||||||
|
|
|
||||||
77
src/nwc.rs
77
src/nwc.rs
|
|
@ -1,44 +1,45 @@
|
||||||
use std::borrow::Cow;
|
use std::{borrow::Cow, time::Duration};
|
||||||
use std::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 anyhow::anyhow;
|
||||||
use cln_plugin::Plugin;
|
use cln_plugin::Plugin;
|
||||||
use nostr_sdk::client;
|
use nostr_sdk::{
|
||||||
use nostr_sdk::nips::nip04;
|
client,
|
||||||
use nostr_sdk::nips::nip44;
|
nips::{nip04, nip44, nip47},
|
||||||
use nostr_sdk::nips::nip47;
|
nostr::{Filter, Kind, Tag},
|
||||||
use nostr_sdk::nostr::Filter;
|
Alphabet,
|
||||||
use nostr_sdk::nostr::Kind;
|
Client,
|
||||||
use nostr_sdk::nostr::Tag;
|
Event,
|
||||||
use nostr_sdk::Alphabet;
|
EventBuilder,
|
||||||
use nostr_sdk::Client;
|
EventId,
|
||||||
use nostr_sdk::Event;
|
Keys,
|
||||||
use nostr_sdk::EventBuilder;
|
PublicKey,
|
||||||
use nostr_sdk::EventId;
|
RelayPoolNotification,
|
||||||
use nostr_sdk::Keys;
|
RelayStatus,
|
||||||
use nostr_sdk::PublicKey;
|
SecretKey,
|
||||||
use nostr_sdk::RelayPoolNotification;
|
SignerError,
|
||||||
use nostr_sdk::RelayStatus;
|
SingleLetterTag,
|
||||||
use nostr_sdk::SecretKey;
|
TagKind,
|
||||||
use nostr_sdk::SignerError;
|
Timestamp,
|
||||||
use nostr_sdk::SingleLetterTag;
|
};
|
||||||
use nostr_sdk::TagKind;
|
use tokio::{sync::oneshot, time};
|
||||||
use nostr_sdk::Timestamp;
|
|
||||||
use tokio::sync::oneshot;
|
use crate::{
|
||||||
use tokio::time;
|
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(
|
pub async fn run_nwc(
|
||||||
plugin: Plugin<PluginState>,
|
plugin: Plugin<PluginState>,
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use cln_plugin::Plugin;
|
use cln_plugin::Plugin;
|
||||||
|
use nostr_sdk::nips::nip47;
|
||||||
|
|
||||||
use crate::structs::PluginState;
|
use crate::structs::PluginState;
|
||||||
use nostr_sdk::nips::nip47;
|
|
||||||
|
|
||||||
pub async fn make_hold_invoice_response(
|
pub async fn make_hold_invoice_response(
|
||||||
_plugin: Plugin<PluginState>,
|
_plugin: Plugin<PluginState>,
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
use cln_plugin::Plugin;
|
use cln_plugin::Plugin;
|
||||||
use cln_rpc::model::requests::GetinfoRequest;
|
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 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(
|
pub async fn get_info_response(
|
||||||
plugin: Plugin<PluginState>,
|
plugin: Plugin<PluginState>,
|
||||||
label: &str,
|
label: &str,
|
||||||
|
|
|
||||||
|
|
@ -5,14 +5,16 @@ use cln_rpc::{
|
||||||
model::{
|
model::{
|
||||||
requests::{DecodeRequest, ListinvoicesRequest, ListpaysRequest},
|
requests::{DecodeRequest, ListinvoicesRequest, ListpaysRequest},
|
||||||
responses::{
|
responses::{
|
||||||
ListinvoicesInvoices, ListinvoicesInvoicesStatus, ListpaysPays, ListpaysPaysStatus,
|
ListinvoicesInvoices,
|
||||||
|
ListinvoicesInvoicesStatus,
|
||||||
|
ListpaysPays,
|
||||||
|
ListpaysPaysStatus,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
primitives::Sha256,
|
primitives::Sha256,
|
||||||
ClnRpc,
|
ClnRpc,
|
||||||
};
|
};
|
||||||
use nostr_sdk::nips::nip47;
|
use nostr_sdk::{nips::nip47, Timestamp};
|
||||||
use nostr_sdk::Timestamp;
|
|
||||||
|
|
||||||
use crate::structs::{PluginState, NOT_INV_ERR};
|
use crate::structs::{PluginState, NOT_INV_ERR};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,23 +2,31 @@ use std::str::FromStr;
|
||||||
|
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use cln_plugin::Plugin;
|
use cln_plugin::Plugin;
|
||||||
use cln_rpc::model::requests::{DecodeRequest, ListinvoicesRequest, ListpaysRequest};
|
use cln_rpc::{
|
||||||
use cln_rpc::model::responses::{
|
model::{
|
||||||
DecodeResponse, ListinvoicesInvoices, ListinvoicesInvoicesStatus, ListpaysPays,
|
requests::{DecodeRequest, ListinvoicesRequest, ListpaysRequest},
|
||||||
ListpaysPaysStatus,
|
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::{
|
||||||
use crate::OPT_NOTIFICATIONS;
|
structs::{PluginState, NOT_INV_ERR},
|
||||||
|
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};
|
|
||||||
|
|
||||||
pub async fn payment_received_handler(
|
pub async fn payment_received_handler(
|
||||||
plugin: Plugin<PluginState>,
|
plugin: Plugin<PluginState>,
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,8 @@ use cln_rpc::{
|
||||||
responses::DecodeResponse,
|
responses::DecodeResponse,
|
||||||
},
|
},
|
||||||
primitives::{Amount, Secret},
|
primitives::{Amount, Secret},
|
||||||
ClnRpc, RpcError,
|
ClnRpc,
|
||||||
|
RpcError,
|
||||||
};
|
};
|
||||||
use nostr_sdk::nips::nip47;
|
use nostr_sdk::nips::nip47;
|
||||||
use tokio::time;
|
use tokio::time;
|
||||||
|
|
|
||||||
23
src/rpc.rs
23
src/rpc.rs
|
|
@ -1,22 +1,21 @@
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use cln_plugin::Plugin;
|
use cln_plugin::Plugin;
|
||||||
use cln_rpc::model::requests::{
|
use cln_rpc::model::requests::{
|
||||||
DatastoreMode, DatastoreRequest, DeldatastoreRequest, ListdatastoreRequest,
|
DatastoreMode,
|
||||||
|
DatastoreRequest,
|
||||||
|
DeldatastoreRequest,
|
||||||
|
ListdatastoreRequest,
|
||||||
};
|
};
|
||||||
use nostr_sdk::nips::nip47::NostrWalletConnectURI;
|
use nostr_sdk::{nips::nip47::NostrWalletConnectURI, Keys, SecretKey, Timestamp};
|
||||||
use nostr_sdk::Keys;
|
|
||||||
use nostr_sdk::SecretKey;
|
|
||||||
use nostr_sdk::Timestamp;
|
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
|
|
||||||
use crate::nwc::{
|
use crate::{
|
||||||
run_nwc, send_nwc_info_event, start_nwc_budget_job, stop_nwc, stop_nwc_budget_job,
|
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(
|
pub async fn nwc_create(
|
||||||
plugin: Plugin<PluginState>,
|
plugin: Plugin<PluginState>,
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
use std::{collections::HashMap, path::PathBuf, str::FromStr, sync::Arc};
|
use std::{collections::HashMap, path::PathBuf, str::FromStr, sync::Arc};
|
||||||
|
|
||||||
use cln_rpc::ClnRpc;
|
use cln_rpc::ClnRpc;
|
||||||
use nostr_sdk::client;
|
use nostr_sdk::{client, nips::nip47, nostr};
|
||||||
use nostr_sdk::nips::nip47;
|
|
||||||
use nostr_sdk::nostr;
|
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use tokio::sync::oneshot;
|
use tokio::sync::oneshot;
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,15 @@ use cln_rpc::{
|
||||||
model::requests::{DatastoreMode, DatastoreRequest, ListdatastoreRequest},
|
model::requests::{DatastoreMode, DatastoreRequest, ListdatastoreRequest},
|
||||||
ClnRpc,
|
ClnRpc,
|
||||||
};
|
};
|
||||||
|
|
||||||
use nostr_sdk::nips::nip47;
|
use nostr_sdk::nips::nip47;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
structs::{NwcStore, PluginState},
|
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(
|
pub fn budget_amount_check(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue