diff --git a/src/main.rs b/src/main.rs index effac61..1c3323a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -63,7 +63,7 @@ const OPT_NOTIFICATIONS: DefaultBooleanConfigOption = ConfigOption::new_bool_wit "Enable/disable nip47-notifications. Default is `true`", ); pub const PLUGIN_NAME: &str = "cln-nip47"; -pub const WALLET_READ_METHODS: [nip47::Method; 5] = [ +pub const WALLET_READ_OR_RECEIVE_METHODS: [nip47::Method; 5] = [ nip47::Method::MakeInvoice, nip47::Method::LookupInvoice, nip47::Method::ListTransactions, diff --git a/src/util.rs b/src/util.rs index 2467ab1..2543e55 100644 --- a/src/util.rs +++ b/src/util.rs @@ -18,7 +18,7 @@ use crate::{ WALLET_HOLD_NOTIFICATIONS, WALLET_NOTIFICATIONS, WALLET_PAY_METHODS, - WALLET_READ_METHODS, + WALLET_READ_OR_RECEIVE_METHODS, structs::{ID_STORE, NwcStore, PluginState}, }; @@ -234,11 +234,13 @@ pub async fn save_event_id( Ok(()) } -pub fn build_capabilities(is_read_only: bool, plugin: &Plugin) -> (String, String) { +pub fn build_capabilities(is_receive_only: bool, plugin: &Plugin) -> (String, String) { let holdinvoice_support = plugin.state().hold_client.lock().is_some(); - let mut methods = WALLET_READ_METHODS.map(|m| m.to_string()).join(" "); - if !is_read_only { + let mut methods = WALLET_READ_OR_RECEIVE_METHODS + .map(|m| m.to_string()) + .join(" "); + if !is_receive_only { methods.push(' '); methods.push_str(WALLET_PAY_METHODS.map(|m| m.to_string()).join(" ").as_str()); } @@ -274,10 +276,13 @@ pub fn build_capabilities(is_read_only: bool, plugin: &Plugin) -> ( (methods, notifications) } -pub fn build_methods_vec(is_read_only: bool, plugin: &Plugin) -> Vec { +pub fn build_methods_vec( + is_receive_only: bool, + plugin: &Plugin, +) -> Vec { let holdinvoice_support = plugin.state().hold_client.lock().is_some(); - let mut methods = WALLET_READ_METHODS.to_vec(); - if !is_read_only { + let mut methods = WALLET_READ_OR_RECEIVE_METHODS.to_vec(); + if !is_receive_only { methods.extend_from_slice(&WALLET_PAY_METHODS); } if holdinvoice_support {