Merge #1153: clippyfy
376621abdfc15e7ee00286338c932298a980517c clippyfy (pythcoiner) Pull request description: Clippy was yelling on Win10 & macOS:   ACKs for top commit: edouardparis: ACK 376621abdfc15e7ee00286338c932298a980517c Tree-SHA512: 2f447176a1260fdcc11afcd1c3c7b444fb148bafc417e3244c3c8f3283ec272b90af5f997c66a226ccb7703a7f0ec70ee02a30801a35854aab97579028a0c478
This commit is contained in:
commit
326064b107
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@ -9,7 +9,7 @@ jobs:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: 1.78.0
|
||||
toolchain: 1.82.0
|
||||
components: rustfmt, clippy
|
||||
override: true
|
||||
- name: rustfmt
|
||||
|
||||
@ -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(
|
||||
|
||||
@ -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, ..
|
||||
@ -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, ..
|
||||
@ -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."
|
||||
@ -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,
|
||||
),
|
||||
|
||||
@ -22,6 +22,8 @@
|
||||
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;
|
||||
@ -29,13 +31,17 @@ 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>,
|
||||
}
|
||||
@ -56,6 +62,7 @@ impl JsonRPCClient {
|
||||
/// Creates a new client
|
||||
pub fn new<P: AsRef<Path>>(sockpath: P) -> JsonRPCClient {
|
||||
JsonRPCClient {
|
||||
#[cfg(not(windows))]
|
||||
sockpath: sockpath.as_ref().to_path_buf(),
|
||||
timeout: None,
|
||||
}
|
||||
@ -70,8 +77,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)
|
||||
}
|
||||
|
||||
@ -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(
|
||||
|
||||
@ -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, ..
|
||||
@ -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, ..
|
||||
|
||||
@ -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
|
||||
),
|
||||
@ -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 {
|
||||
@ -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
|
||||
))
|
||||
|
||||
@ -77,7 +77,7 @@ impl BackendClient {
|
||||
let response = request(
|
||||
&http,
|
||||
Method::GET,
|
||||
&format!("{}/v1/me", url),
|
||||
format!("{}/v1/me", url),
|
||||
&credentials.access_token,
|
||||
)
|
||||
.send()
|
||||
|
||||
@ -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};
|
||||
|
||||
@ -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
|
||||
|
||||
@ -135,6 +135,7 @@ impl TryFrom<&rusqlite::Row<'_>> for DbTip {
|
||||
/// A row in the "wallets" table.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct DbWallet {
|
||||
#[allow(dead_code)]
|
||||
pub id: i64,
|
||||
pub timestamp: u32,
|
||||
pub main_descriptor: LianaDescriptor,
|
||||
|
||||
@ -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.
|
||||
@ -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)?;
|
||||
|
||||
@ -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!(
|
||||
@ -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,
|
||||
@ -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(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user