Skip to content
This repository has been archived by the owner on Feb 3, 2025. It is now read-only.

Commit

Permalink
Clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyGiorgio committed Mar 21, 2024
1 parent 27e1532 commit aee12fe
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 21 deletions.
2 changes: 1 addition & 1 deletion mutiny-core/src/blindauth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ fn create_blind_auth_secret(
) -> Result<DerivableSecret, MutinyError> {
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(
Expand Down
7 changes: 3 additions & 4 deletions mutiny-core/src/federation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ fn create_federation_secret(
) -> Result<DerivableSecret, MutinyError> {
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(
Expand Down Expand Up @@ -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());
Expand All @@ -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());
Expand Down
7 changes: 4 additions & 3 deletions mutiny-core/src/hermes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -115,7 +116,7 @@ impl<S: MutinyStorage> HermesClient<S> {
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();

Expand Down Expand Up @@ -252,7 +253,7 @@ impl<S: MutinyStorage> HermesClient<S> {
}

fn find_hermes_token(
tokens: &Vec<SignedToken>,
tokens: &[SignedToken],
service_id: u32,
plan_id: u32,
) -> Option<&SignedToken> {
Expand Down
18 changes: 9 additions & 9 deletions mutiny-core/src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
}
Expand All @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion mutiny-core/src/keymanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ pub(crate) fn create_keys_manager<S: MutinyStorage>(
) -> Result<PhantomKeysManager<S>, 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,
Expand Down
4 changes: 2 additions & 2 deletions mutiny-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ impl<S: MutinyStorage> MutinyWalletBuilder<S> {
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,
Expand All @@ -911,7 +911,7 @@ impl<S: MutinyStorage> MutinyWalletBuilder<S> {
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,
Expand Down
1 change: 0 additions & 1 deletion mutiny-core/src/nostr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down

0 comments on commit aee12fe

Please sign in to comment.