Skip to content

Commit

Permalink
clippyfy
Browse files Browse the repository at this point in the history
  • Loading branch information
pythcoiner committed Nov 18, 2024
1 parent 327f0ea commit 768f48a
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 58 deletions.
11 changes: 6 additions & 5 deletions liana-gui/src/app/state/settings/bitcoind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,11 +336,12 @@ impl BitcoindSettings {
let rpc_auth = match self.selected_auth_type {
RpcAuthType::CookieFile => {
let new_path = PathBuf::from_str(&self.rpc_auth_vals.cookie_path.value);
if let Ok(path) = new_path {
self.rpc_auth_vals.cookie_path.valid = true;
Some(BitcoindRpcAuth::CookieFile(path))
} else {
None
match new_path {
Ok(path) => {
self.rpc_auth_vals.cookie_path.valid = true;
Some(BitcoindRpcAuth::CookieFile(path))
}
Err(_) => None,
}
}
RpcAuthType::UserPass => Some(BitcoindRpcAuth::UserPass(
Expand Down
26 changes: 13 additions & 13 deletions liana-gui/src/app/view/hw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ pub fn hw_list_view(
..
} => match reason {
UnsupportedReason::NotPartOfWallet(fg) => {
hw::unrelated_hardware_wallet(&kind.to_string(), version.as_ref(), fg)
hw::unrelated_hardware_wallet(kind.to_string(), version.as_ref(), fg)
}
UnsupportedReason::WrongNetwork => {
hw::wrong_network_hardware_wallet(&kind.to_string(), version.as_ref())
hw::wrong_network_hardware_wallet(kind.to_string(), version.as_ref())
}
UnsupportedReason::Version {
minimal_supported_version,
} => hw::unsupported_version_hardware_wallet(
&kind.to_string(),
kind.to_string(),
version.as_ref(),
minimal_supported_version,
),
_ => hw::unsupported_hardware_wallet(&kind.to_string(), version.as_ref()),
_ => hw::unsupported_hardware_wallet(kind.to_string(), version.as_ref()),
},
HardwareWallet::Locked {
kind, pairing_code, ..
Expand Down Expand Up @@ -119,19 +119,19 @@ pub fn hw_list_view_for_registration(
..
} => match reason {
UnsupportedReason::NotPartOfWallet(fg) => {
hw::unrelated_hardware_wallet(&kind.to_string(), version.as_ref(), fg)
hw::unrelated_hardware_wallet(kind.to_string(), version.as_ref(), fg)
}
UnsupportedReason::WrongNetwork => {
hw::wrong_network_hardware_wallet(&kind.to_string(), version.as_ref())
hw::wrong_network_hardware_wallet(kind.to_string(), version.as_ref())
}
UnsupportedReason::Version {
minimal_supported_version,
} => hw::unsupported_version_hardware_wallet(
&kind.to_string(),
kind.to_string(),
version.as_ref(),
minimal_supported_version,
),
_ => hw::unsupported_hardware_wallet(&kind.to_string(), version.as_ref()),
_ => hw::unsupported_hardware_wallet(kind.to_string(), version.as_ref()),
},
HardwareWallet::Locked {
kind, pairing_code, ..
Expand Down Expand Up @@ -175,7 +175,7 @@ pub fn hw_list_view_verify_address(
match kind {
DeviceKind::Specter | DeviceKind::SpecterSimulator => {
(hw::unimplemented_method_hardware_wallet(
&kind.to_string(),
kind.to_string(),
version.as_ref(),
fingerprint,
"Liana cannot request the device to display the address. \n The verification must be done manually with the device control."
Expand All @@ -198,19 +198,19 @@ pub fn hw_list_view_verify_address(
} => (
match reason {
UnsupportedReason::NotPartOfWallet(fg) => {
hw::unrelated_hardware_wallet(&kind.to_string(), version.as_ref(), fg)
hw::unrelated_hardware_wallet(kind.to_string(), version.as_ref(), fg)
}
UnsupportedReason::WrongNetwork => {
hw::wrong_network_hardware_wallet(&kind.to_string(), version.as_ref())
hw::wrong_network_hardware_wallet(kind.to_string(), version.as_ref())
}
UnsupportedReason::Version {
minimal_supported_version,
} => hw::unsupported_version_hardware_wallet(
&kind.to_string(),
kind.to_string(),
version.as_ref(),
minimal_supported_version,
),
_ => hw::unsupported_hardware_wallet(&kind.to_string(), version.as_ref()),
_ => hw::unsupported_hardware_wallet(kind.to_string(), version.as_ref()),
},
false,
),
Expand Down
10 changes: 8 additions & 2 deletions liana-gui/src/daemon/client/jsonrpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,26 @@
use std::os::unix::net::UnixStream;

use std::fmt::Debug;

#[cfg(not(windows))]
use std::io::Write;
use std::path::{Path, PathBuf};
use std::time::Duration;
use std::{error, fmt, io};

use serde::de::DeserializeOwned;
use serde::{Deserialize, Serialize};

#[cfg(not(windows))]
use serde_json::Deserializer;

#[cfg(not(windows))]
use tracing::debug;

/// A handle to a remote JSONRPC server
#[derive(Debug, Clone)]
pub struct JsonRPCClient {
#[cfg(not(windows))]
sockpath: PathBuf,
timeout: Option<Duration>,
}
Expand Down Expand Up @@ -70,8 +76,8 @@ impl JsonRPCClient {
#[cfg(windows)]
pub fn send_request<S: Serialize + Debug, D: DeserializeOwned + Debug>(
&self,
method: &str,
params: Option<S>,
_method: &str,
_params: Option<S>,
) -> Result<Response<D>, Error> {
Err(Error::NotSupported)
}
Expand Down
11 changes: 6 additions & 5 deletions liana-gui/src/installer/step/node/bitcoind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,11 +452,12 @@ impl DefineBitcoind {
let addr = std::net::SocketAddr::from_str(&self.address.value);
let rpc_auth = match self.selected_auth_type {
RpcAuthType::CookieFile => {
if let Ok(path) = PathBuf::from_str(&self.rpc_auth_vals.cookie_path.value) {
Some(BitcoindRpcAuth::CookieFile(path))
} else {
self.rpc_auth_vals.cookie_path.valid = false;
None
match PathBuf::from_str(&self.rpc_auth_vals.cookie_path.value) {
Ok(path) => Some(BitcoindRpcAuth::CookieFile(path)),
Err(_) => {
self.rpc_auth_vals.cookie_path.valid = false;
None
}
}
}
RpcAuthType::UserPass => Some(BitcoindRpcAuth::UserPass(
Expand Down
16 changes: 8 additions & 8 deletions liana-gui/src/installer/view/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,19 +430,19 @@ pub fn hardware_wallet_xpubs<'a>(
..
} => match reason {
UnsupportedReason::NotPartOfWallet(fg) => {
hw::unrelated_hardware_wallet(&kind.to_string(), version.as_ref(), fg)
hw::unrelated_hardware_wallet(kind.to_string(), version.as_ref(), fg)
}
UnsupportedReason::WrongNetwork => {
hw::wrong_network_hardware_wallet(&kind.to_string(), version.as_ref())
hw::wrong_network_hardware_wallet(kind.to_string(), version.as_ref())
}
UnsupportedReason::Version {
minimal_supported_version,
} => hw::unsupported_version_hardware_wallet(
&kind.to_string(),
kind.to_string(),
version.as_ref(),
minimal_supported_version,
),
_ => hw::unsupported_hardware_wallet(&kind.to_string(), version.as_ref()),
_ => hw::unsupported_hardware_wallet(kind.to_string(), version.as_ref()),
},
HardwareWallet::Locked {
kind, pairing_code, ..
Expand Down Expand Up @@ -1596,19 +1596,19 @@ pub fn hw_list_view(
..
} => match reason {
UnsupportedReason::NotPartOfWallet(fg) => {
hw::unrelated_hardware_wallet(&kind.to_string(), version.as_ref(), fg)
hw::unrelated_hardware_wallet(kind.to_string(), version.as_ref(), fg)
}
UnsupportedReason::WrongNetwork => {
hw::wrong_network_hardware_wallet(&kind.to_string(), version.as_ref())
hw::wrong_network_hardware_wallet(kind.to_string(), version.as_ref())
}
UnsupportedReason::Version {
minimal_supported_version,
} => hw::unsupported_version_hardware_wallet(
&kind.to_string(),
kind.to_string(),
version.as_ref(),
minimal_supported_version,
),
_ => hw::unsupported_hardware_wallet(&kind.to_string(), version.as_ref()),
_ => hw::unsupported_hardware_wallet(kind.to_string(), version.as_ref()),
},
HardwareWallet::Locked {
kind, pairing_code, ..
Expand Down
6 changes: 3 additions & 3 deletions liana-gui/src/lianalite/client/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl AuthClient {
let response: Response = self
.request(
Method::POST,
&format!(
format!(
"{}/auth/v1/otp?redirect_to=https://desktop.lianalite.com",
self.url
),
Expand Down Expand Up @@ -128,7 +128,7 @@ impl AuthClient {
pub async fn verify_otp(&self, token: &str) -> Result<AccessTokenResponse, AuthError> {
let response: Response = self
.http
.post(&format!("{}/auth/v1/verify", self.url))
.post(format!("{}/auth/v1/verify", self.url))
.header("apikey", &self.api_public_key)
.header("Content-Type", "application/json")
.json(&VerifyOtp {
Expand All @@ -154,7 +154,7 @@ impl AuthClient {
) -> Result<AccessTokenResponse, AuthError> {
let response: Response = self
.http
.post(&format!(
.post(format!(
"{}/auth/v1/token?grant_type=refresh_token",
self.url
))
Expand Down
2 changes: 1 addition & 1 deletion liana-gui/src/lianalite/client/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl BackendClient {
let response = request(
&http,
Method::GET,
&format!("{}/v1/me", url),
format!("{}/v1/me", url),
&credentials.access_token,
)
.send()
Expand Down
3 changes: 2 additions & 1 deletion liana-gui/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ use std::{
collections::HashMap, error::Error, io::Write, path::PathBuf, process, str::FromStr, sync::Arc,
};

#[cfg(target_os = "linux")]
use iced::window::settings::PlatformSpecific;
use iced::{
event::{self, Event},
executor, keyboard,
widget::{focus_next, focus_previous},
window::settings::PlatformSpecific,
Application, Command, Settings, Size, Subscription,
};
use tracing::{error, info};
Expand Down
8 changes: 4 additions & 4 deletions liana/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -745,11 +745,11 @@ impl DaemonControl {
/// transaction will be used in the replacement.
/// In both cases:
/// - if the previous transaction includes a change output to one of our own change addresses,
/// this same address will be used for change in the RBF transaction, if required. If the previous
/// transaction pays to more than one of our change addresses, then the one receiving the highest
/// value will be used as a change address and the others will be treated as non-change outputs.
/// this same address will be used for change in the RBF transaction, if required. If the previous
/// transaction pays to more than one of our change addresses, then the one receiving the highest
/// value will be used as a change address and the others will be treated as non-change outputs.
/// - the RBF transaction may include additional confirmed coins as inputs if required
/// in order to pay the higher fee (this applies also when replacing a self-send).
/// in order to pay the higher fee (this applies also when replacing a self-send).
///
/// `feerate_vb` is the target feerate for the RBF transaction (in sat/vb). If `None`, it will be set
/// to 1 sat/vb larger than the feerate of the previous transaction, which is the minimum value allowed
Expand Down
6 changes: 3 additions & 3 deletions liana/src/descriptors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ impl LianaDescriptor {
/// This analysis assumes that:
/// - The PSBT only contains input that spends Liana coins. Otherwise the analysis will be off.
/// - The PSBT is consistent across inputs (the sequence is the same across inputs, the
/// signatures are either absent or present for all inputs, ..)
/// signatures are either absent or present for all inputs, ..)
/// - The provided signatures are valid for this script.
pub fn partial_spend_info(&self, psbt: &Psbt) -> Result<PartialSpendInfo, LianaDescError> {
// Check the PSBT isn't empty or malformed.
Expand Down Expand Up @@ -524,9 +524,9 @@ impl LianaDescriptor {
/// Prune the BIP32 derivations in all the PSBT inputs for all the spending paths but the
/// latest available one. For instance:
/// - If there is two recovery paths, and the PSBT's first input nSequence isn't set to unlock
/// any of them, prune all but the primary path's bip32 derivations.
/// any of them, prune all but the primary path's bip32 derivations.
/// - If there is two recovery paths, and the PSBT's first input nSequence is set to unlock the
/// first one, prune all but the first recovery path's bip32 derivations.
/// first one, prune all but the first recovery path's bip32 derivations.
/// - Etc..
pub fn prune_bip32_derivs_last_avail(&self, psbt: Psbt) -> Result<Psbt, LianaDescError> {
let spend_info = self.partial_spend_info(&psbt)?;
Expand Down
26 changes: 13 additions & 13 deletions liana/src/spend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ fn select_coins_for_spend(
i if i >= 100 => 10_000,
_ => 100_000,
};
#[cfg(debug)]
#[cfg(debug_assertions)]
let bnb_rounds = bnb_rounds / 1_000;
if let Err(e) = selector.run_bnb(lowest_fee_change_cond, bnb_rounds) {
log::debug!(
Expand Down Expand Up @@ -508,9 +508,9 @@ fn derived_desc(
///
/// The approach follows that taken by Bitcoin Core:
/// - most of the time, the value returned will be the current
/// block height, but will randomly be up to 100 blocks earlier.
/// block height, but will randomly be up to 100 blocks earlier.
/// - if the current tip is more than [`MAX_ANTI_FEE_SNIPING_TIP_AGE_SECS`]
/// seconds old, a locktime value of 0 will be returned.
/// seconds old, a locktime value of 0 will be returned.
pub fn anti_fee_sniping_locktime(
now: Duration,
tip_height: u32,
Expand Down Expand Up @@ -613,22 +613,22 @@ pub struct CreateSpendRes {
///
/// More about the parameters:
/// * `main_descriptor`: the multipath Liana descriptor, used to derive the addresses of the
/// candidate coins.
/// candidate coins.
/// * `secp`: necessary to derive data from the descriptor.
/// * `tx_getter`: an interface to get the wallet transaction for the prevouts of the transaction.
/// Wouldn't be necessary if we only spent Taproot coins.
/// Wouldn't be necessary if we only spent Taproot coins.
/// * `destinations`: a list of addresses and amounts, one per recipient i.e. per output in the
/// transaction created. If empty all the `candidate_coins` get spent and a single change output
/// is created to the provided `change_addr`. Can be used to sweep all, or some, coins from the
/// wallet.
/// transaction created. If empty all the `candidate_coins` get spent and a single change output
/// is created to the provided `change_addr`. Can be used to sweep all, or some, coins from the
/// wallet.
/// * `candidate_coins`: a list of coins to consider including as input of the transaction. If
/// `destinations` is empty, they will all be included as inputs of the transaction. Otherwise, a
/// coin selection algorithm will be run to spend the most efficient subset of them to meet the
/// `destinations` requirements.
/// `destinations` is empty, they will all be included as inputs of the transaction. Otherwise, a
/// coin selection algorithm will be run to spend the most efficient subset of them to meet the
/// `destinations` requirements.
/// * `fees`: the target feerate (in sats/vb) and, if necessary, minimum absolute fee for this tx.
/// * `change_addr`: the address to use for a change output if we need to create one. Can be set to
/// an external address (if combined with an empty list of `destinations` it's useful to sweep some
/// or all coins of a wallet to an external address).
/// an external address (if combined with an empty list of `destinations` it's useful to sweep some
/// or all coins of a wallet to an external address).
/// * `locktime`: the locktime to use for the transaction.
#[allow(clippy::too_many_arguments)]
pub fn create_spend(
Expand Down

0 comments on commit 768f48a

Please sign in to comment.