Skip to content

Commit

Permalink
Add archiving nwc profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed Aug 3, 2023
1 parent af589f6 commit 9955a23
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions mutiny-core/src/nostr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ impl<S: MutinyStorage> NostrManager<S> {
.read()
.unwrap()
.iter()
.filter(|x| !x.profile.archived)
.map(|x| x.nwc_profile())
.collect()
}
Expand Down Expand Up @@ -169,6 +170,7 @@ impl<S: MutinyStorage> NostrManager<S> {
index,
relay: "wss://nostr.mutinywallet.com".to_string(),
enabled: true,
archived: false,
spending_conditions,
};
let nwc = NostrWalletConnect::new(&Secp256k1::new(), self.xprivkey, profile)?;
Expand Down
8 changes: 8 additions & 0 deletions mutiny-core/src/nostr/nwc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ pub(crate) struct Profile {
pub index: u32,
pub relay: String,
pub enabled: bool,
/// Archived profiles will not be displayed
#[serde(default)]
pub archived: bool,
/// Require approval before sending a payment
#[serde(default)]
pub spending_conditions: SpendingConditions,
Expand Down Expand Up @@ -217,6 +220,7 @@ impl NostrWalletConnect {
self.profile.spending_conditions =
SpendingConditions::SingleUse(single_use);
self.profile.enabled = false;
self.profile.archived = true;
needs_save = true;
resp
}
Expand Down Expand Up @@ -292,6 +296,7 @@ impl NostrWalletConnect {
index: self.profile.index,
relay: self.profile.relay.clone(),
enabled: self.profile.enabled,
archived: self.profile.archived,
nwc_uri: self.get_nwc_uri().expect("failed to get nwc uri"),
spending_conditions: self.profile.spending_conditions.clone(),
}
Expand All @@ -305,6 +310,8 @@ pub struct NwcProfile {
pub index: u32,
pub relay: String,
pub enabled: bool,
#[serde(default)]
pub archived: bool,
pub nwc_uri: String,
#[serde(default)]
pub spending_conditions: SpendingConditions,
Expand All @@ -316,6 +323,7 @@ impl NwcProfile {
name: self.name.clone(),
index: self.index,
relay: self.relay.clone(),
archived: self.archived,
enabled: self.enabled,
spending_conditions: self.spending_conditions.clone(),
}
Expand Down

0 comments on commit 9955a23

Please sign in to comment.