diff --git a/mutiny-core/src/blindauth.rs b/mutiny-core/src/blindauth.rs index b2d38c12f..efaf1842b 100644 --- a/mutiny-core/src/blindauth.rs +++ b/mutiny-core/src/blindauth.rs @@ -357,7 +357,7 @@ fn create_blind_auth_secret( ) -> Result { let context = Secp256k1::new(); - let shared_key = create_root_child_key(&context, xprivkey, ChildKey::BlindAuthChildKey)?; + let shared_key = create_root_child_key(&context, xprivkey, ChildKey::BlindAuth)?; let xpriv = shared_key.derive_priv( &context, &DerivationPath::from(vec![ChildNumber::from_hardened_idx( diff --git a/mutiny-core/src/federation.rs b/mutiny-core/src/federation.rs index 7b011a965..64a7cd786 100644 --- a/mutiny-core/src/federation.rs +++ b/mutiny-core/src/federation.rs @@ -709,7 +709,7 @@ fn create_federation_secret( ) -> Result { let context = Secp256k1::new(); - let shared_key = create_root_child_key(&context, xprivkey, ChildKey::FederationChildKey)?; + let shared_key = create_root_child_key(&context, xprivkey, ChildKey::Federation)?; let xpriv = shared_key.derive_priv( &context, &DerivationPath::from(vec![ChildNumber::from_hardened_idx( @@ -1086,7 +1086,7 @@ fn fedimint_mnemonic_generation() { let root_mnemonic = Mnemonic::from_str(mnemonic_str).expect("could not generate"); let xpriv = ExtendedPrivKey::new_master(Network::Regtest, &root_mnemonic.to_seed("")).unwrap(); let context = Secp256k1::new(); - let child_key = create_root_child_key(&context, xpriv, ChildKey::FederationChildKey).unwrap(); + let child_key = create_root_child_key(&context, xpriv, ChildKey::Federation).unwrap(); let child_mnemonic = mnemonic_from_xpriv(child_key).unwrap(); assert_ne!(mnemonic_str, child_mnemonic.to_string()); @@ -1100,8 +1100,7 @@ fn fedimint_mnemonic_generation() { let xpriv2 = ExtendedPrivKey::new_master(Network::Regtest, &root_mnemonic2.to_seed("")).unwrap(); let context2 = Secp256k1::new(); - let child_key2 = - create_root_child_key(&context2, xpriv2, ChildKey::FederationChildKey).unwrap(); + let child_key2 = create_root_child_key(&context2, xpriv2, ChildKey::Federation).unwrap(); let child_mnemonic2 = mnemonic_from_xpriv(child_key2).unwrap(); assert_ne!(mnemonic_str2, child_mnemonic2.to_string()); diff --git a/mutiny-core/src/hermes.rs b/mutiny-core/src/hermes.rs index 24b9b47ac..d9750ef03 100644 --- a/mutiny-core/src/hermes.rs +++ b/mutiny-core/src/hermes.rs @@ -14,7 +14,7 @@ use lightning::util::logger::Logger; use lightning::{log_error, log_warn}; use nostr::{nips::nip04::decrypt, Keys}; use nostr::{Filter, Kind, Timestamp}; -use nostr_sdk::{Client, NostrSigner, RelayPoolNotification}; +use nostr_sdk::{Client, RelayPoolNotification}; use reqwest::Method; use serde::{Deserialize, Serialize}; use tbs::unblind_signature; @@ -31,6 +31,7 @@ use crate::{ }; const HERMES_SERVICE_ID: u32 = 1; +#[allow(dead_code)] const HERMES_FREE_PLAN_ID: u32 = 1; const HERMES_PAID_PLAN_ID: u32 = 2; @@ -115,7 +116,7 @@ impl HermesClient { let logger = self.logger.clone(); let stop = self.stop.clone(); let client = self.client.clone(); - let public_key = self.public_key.clone(); + let public_key = self.public_key; let storage = self.storage.clone(); let primary_key = self.primary_key.clone(); @@ -252,7 +253,7 @@ impl HermesClient { } fn find_hermes_token( - tokens: &Vec, + tokens: &[SignedToken], service_id: u32, plan_id: u32, ) -> Option<&SignedToken> { diff --git a/mutiny-core/src/key.rs b/mutiny-core/src/key.rs index fd1273b59..55f93bbd0 100644 --- a/mutiny-core/src/key.rs +++ b/mutiny-core/src/key.rs @@ -6,17 +6,17 @@ use bitcoin::{ use crate::error::MutinyError; pub(crate) enum ChildKey { - NodeChildKey, - FederationChildKey, - BlindAuthChildKey, + Node, + Federation, + BlindAuth, } impl ChildKey { pub(crate) fn to_child_number(&self) -> u32 { match self { - ChildKey::NodeChildKey => 0, - ChildKey::FederationChildKey => 1, - ChildKey::BlindAuthChildKey => 2, + ChildKey::Node => 0, + ChildKey::Federation => 1, + ChildKey::BlindAuth => 2, } } } @@ -41,11 +41,11 @@ fn run_key_generation_tests() { let mnemonic = Mnemonic::from_str("abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about").expect("could not generate"); let xpriv = ExtendedPrivKey::new_master(Network::Testnet, &mnemonic.to_seed("")).unwrap(); - let first_root_key = create_root_child_key(&context, xpriv, ChildKey::NodeChildKey); - let copy_root_key = create_root_child_key(&context, xpriv, ChildKey::NodeChildKey); + let first_root_key = create_root_child_key(&context, xpriv, ChildKey::Node); + let copy_root_key = create_root_child_key(&context, xpriv, ChildKey::Node); assert_eq!(first_root_key, copy_root_key); - let federation_root_key = create_root_child_key(&context, xpriv, ChildKey::FederationChildKey); + let federation_root_key = create_root_child_key(&context, xpriv, ChildKey::Federation); assert_ne!(first_root_key, federation_root_key); } diff --git a/mutiny-core/src/keymanager.rs b/mutiny-core/src/keymanager.rs index 61c307135..5be633ec6 100644 --- a/mutiny-core/src/keymanager.rs +++ b/mutiny-core/src/keymanager.rs @@ -233,7 +233,7 @@ pub(crate) fn create_keys_manager( ) -> Result, MutinyError> { let context = Secp256k1::new(); - let shared_key = create_root_child_key(&context, xprivkey, ChildKey::NodeChildKey)?; + let shared_key = create_root_child_key(&context, xprivkey, ChildKey::Node)?; let xpriv = shared_key.derive_priv( &context, diff --git a/mutiny-core/src/lib.rs b/mutiny-core/src/lib.rs index 82ac2066f..889794f66 100644 --- a/mutiny-core/src/lib.rs +++ b/mutiny-core/src/lib.rs @@ -891,7 +891,7 @@ impl MutinyWalletBuilder { let blind_auth_client = if let Some(auth_client) = self.auth_client.clone() { if let Some(blind_auth_url) = self.blind_auth_url { let s = Arc::new(BlindAuthClient::new( - self.xprivkey.clone(), + self.xprivkey, auth_client, network, blind_auth_url, @@ -911,7 +911,7 @@ impl MutinyWalletBuilder { if let Some(hermes_url) = self.hermes_url { let s = Arc::new( HermesClient::new( - self.xprivkey.clone(), + self.xprivkey, hermes_url, federations.clone(), blind_auth_client, diff --git a/mutiny-core/src/nostr/mod.rs b/mutiny-core/src/nostr/mod.rs index e342381e3..8fcac9af0 100644 --- a/mutiny-core/src/nostr/mod.rs +++ b/mutiny-core/src/nostr/mod.rs @@ -20,7 +20,6 @@ use lightning::util::logger::Logger; use lightning::{log_debug, log_error, log_info, log_warn}; use lightning_invoice::Bolt11Invoice; use lnurl::lnurl::LnUrl; -use nostr::key::SecretKey; use nostr::nips::nip04::{decrypt, encrypt}; use nostr::nips::nip47::*; use nostr::{Event, EventBuilder, EventId, Filter, JsonUtil, Keys, Kind, Metadata, Tag, Timestamp};