mirror of
https://github.com/daywalker90/cln-nip47.git
synced 2026-08-13 12:33:43 +02:00
refactor read to receive in code to match docs
This commit is contained in:
parent
e6763bd9be
commit
8076e8a36c
2 changed files with 13 additions and 8 deletions
|
|
@ -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,
|
||||
|
|
|
|||
19
src/util.rs
19
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<PluginState>) -> (String, String) {
|
||||
pub fn build_capabilities(is_receive_only: bool, plugin: &Plugin<PluginState>) -> (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<PluginState>) -> (
|
|||
(methods, notifications)
|
||||
}
|
||||
|
||||
pub fn build_methods_vec(is_read_only: bool, plugin: &Plugin<PluginState>) -> Vec<nip47::Method> {
|
||||
pub fn build_methods_vec(
|
||||
is_receive_only: bool,
|
||||
plugin: &Plugin<PluginState>,
|
||||
) -> Vec<nip47::Method> {
|
||||
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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue