[ci] Fix clippy warnings, enable clippy checks

This commit is contained in:
Steve Myers
2020-10-07 14:18:50 -07:00
parent 6402fd07c2
commit aea9abff8a
15 changed files with 69 additions and 68 deletions

View File

@@ -605,9 +605,7 @@ where
available_utxos,
use_all_utxos,
new_feerate,
fee_difference
.checked_sub(removed_change_output.value)
.unwrap_or(0),
fee_difference.saturating_sub(removed_change_output.value),
input_witness_weight,
0.0,
)?;
@@ -620,7 +618,7 @@ where
// copy the n_sequence from the inputs that were already in the transaction
txin.iter_mut()
.for_each(|i| i.sequence = tx.input[0].sequence);
tx.input.extend_from_slice(&mut txin);
tx.input.extend_from_slice(&txin);
details.sent += selected_amount;
selected_amount
@@ -666,7 +664,7 @@ where
.iter()
.map(|txin| {
Ok((
txin.previous_output.clone(),
txin.previous_output,
self.database
.borrow()
.get_previous_output(&txin.previous_output)?,
@@ -765,7 +763,7 @@ where
.database
.borrow()
.get_tx(&input.previous_output.txid, false)?
.and_then(|tx| Some(tx.height.unwrap_or(std::u32::MAX)));
.map(|tx| tx.height.unwrap_or(std::u32::MAX));
let current_height = assume_height.or(self.current_height);
debug!(
@@ -833,15 +831,13 @@ where
&self,
script_type: ScriptType,
) -> (&ExtendedDescriptor, ScriptType) {
let desc = match script_type {
match script_type {
ScriptType::Internal if self.change_descriptor.is_some() => (
self.change_descriptor.as_ref().unwrap(),
ScriptType::Internal,
),
_ => (&self.descriptor, ScriptType::External),
};
desc
}
}
fn get_descriptor_for_txout(&self, txout: &TxOut) -> Result<Option<ExtendedDescriptor>, Error> {
@@ -941,7 +937,7 @@ where
) -> Result<(Vec<UTXO>, bool), Error> {
let unspendable_set = match unspendable {
None => HashSet::new(),
Some(vec) => vec.into_iter().collect(),
Some(vec) => vec.iter().collect(),
};
match utxo {
@@ -1131,10 +1127,7 @@ where
if self
.database
.borrow()
.get_script_pubkey_from_path(
ScriptType::Internal,
max_address.checked_sub(1).unwrap_or(0),
)?
.get_script_pubkey_from_path(ScriptType::Internal, max_address.saturating_sub(1))?
.is_none()
{
run_setup = true;

View File

@@ -205,7 +205,7 @@ impl Signer for DescriptorXKey<ExtendedPrivKey> {
.hd_keypaths
.iter()
.filter_map(|(pk, &(fingerprint, ref path))| {
if self.matches(fingerprint.clone(), &path).is_some() {
if self.matches(fingerprint, &path).is_some() {
Some((pk, path))
} else {
None
@@ -284,7 +284,7 @@ impl Signer for PrivateKey {
}
fn descriptor_secret_key(&self) -> Option<DescriptorSecretKey> {
Some(DescriptorSecretKey::PrivKey(self.clone()))
Some(DescriptorSecretKey::PrivKey(*self))
}
}
@@ -407,7 +407,7 @@ impl<Pk: MiniscriptKey> SignersContainer<Pk> {
Included(&(id, SignerOrdering(usize::MAX)).into()),
))
.map(|(_, v)| v)
.nth(0)
.next()
}
}
@@ -431,9 +431,9 @@ impl ComputeSighash for Legacy {
let tx_input = &psbt.global.unsigned_tx.input[input_index];
let sighash = psbt_input.sighash_type.ok_or(SignerError::MissingSighash)?;
let script = match &psbt_input.redeem_script {
&Some(ref redeem_script) => redeem_script.clone(),
&None => {
let script = match psbt_input.redeem_script {
Some(ref redeem_script) => redeem_script.clone(),
None => {
let non_witness_utxo = psbt_input
.non_witness_utxo
.as_ref()
@@ -485,9 +485,9 @@ impl ComputeSighash for Segwitv0 {
.ok_or(SignerError::MissingNonWitnessUtxo)?;
let value = witness_utxo.value;
let script = match &psbt_input.witness_script {
&Some(ref witness_script) => witness_script.clone(),
&None => {
let script = match psbt_input.witness_script {
Some(ref witness_script) => witness_script.clone(),
None => {
if witness_utxo.script_pubkey.is_v0_p2wpkh() {
p2wpkh_script_code(&witness_utxo.script_pubkey)
} else if psbt_input