fix budget race condition

This commit is contained in:
daywalker90 2026-04-23 11:00:51 +02:00
parent ce0e1fe585
commit 7ec1e68d6c
5 changed files with 12 additions and 7 deletions

View file

@ -1,5 +1,10 @@
# Changelog
## [0.1.9] 2026-04-23
### Fixed
- ``nip47-budget``: race condition where new budget settings would sometimes be ignored
## [0.1.8] 2026-04-03
### Changed

2
Cargo.lock generated
View file

@ -272,7 +272,7 @@ dependencies = [
[[package]]
name = "cln-nip47"
version = "0.1.8"
version = "0.1.9"
dependencies = [
"anyhow",
"cln-plugin",

View file

@ -1,6 +1,6 @@
[package]
name = "cln-nip47"
version = "0.1.8"
version = "0.1.9"
edition = "2024"
rust-version = "1.85.0"

View file

@ -1,6 +1,6 @@
plugin:
name: cln-nip47
version: 0.1.8
version: 0.1.9
lang: rust
install: |
cargo build --release && cp target/release/cln-nip47 . && cargo clean

View file

@ -6,15 +6,15 @@ use cln_rpc::model::requests::{
DeldatastoreRequest,
ListdatastoreRequest,
};
use nostr_sdk::{nips::nip47::NostrWalletConnectURI, Keys, SecretKey, Timestamp};
use nostr_sdk::{Keys, SecretKey, Timestamp, nips::nip47::NostrWalletConnectURI};
use serde_json::json;
use crate::{
PLUGIN_NAME,
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,
};
pub async fn nwc_create(
@ -140,12 +140,12 @@ pub async fn nwc_budget(
let is_new_nwc_read_only = is_read_only_nwc(&nwc_store);
update_nwc_store(&mut rpc, &label, nwc_store.clone()).await?;
if nwc_store.interval_config.is_some() {
start_nwc_budget_job(&plugin, label.clone());
}
update_nwc_store(&mut rpc, &label, nwc_store.clone()).await?;
if is_old_nwc_read_only != is_new_nwc_read_only {
let wallet_keys = Keys::new(SecretKey::from_hex(&nwc_store.walletkey)?);
let (method_capabilities, _) = build_capabilities(is_new_nwc_read_only, &plugin);