Skip to content

Commit 524716c

Browse files
committed
Fix clippy-workspace checks
1 parent fa0d68d commit 524716c

File tree

8 files changed

+43
-22
lines changed

8 files changed

+43
-22
lines changed

dash/examples/ecdsa-psbt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ impl WatchOnly {
255255

256256
let sigs: Vec<_> = psbt.inputs[0].partial_sigs.values().collect();
257257
let mut script_witness: Witness = Witness::new();
258-
script_witness.push(&sigs[0].to_vec());
258+
script_witness.push(sigs[0].to_vec());
259259
script_witness.push(self.input_xpub.to_pub().to_bytes());
260260

261261
psbt.inputs[0].final_script_witness = Some(script_witness);

dash/examples/taproot-psbt.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,10 +398,10 @@ impl BenefactorWallet {
398398
if let ChildNumber::Normal {
399399
index,
400400
} = self.next
401+
&& index > 0
402+
&& self.current_spend_info.is_some()
401403
{
402-
if index > 0 && self.current_spend_info.is_some() {
403-
return Err("Transaction already exists, use refresh_inheritance_timelock to refresh the timelock".into());
404-
}
404+
return Err("Transaction already exists, use refresh_inheritance_timelock to refresh the timelock".into());
405405
}
406406
// We use some other derivation path in this example for our inheritance protocol. The important thing is to ensure
407407
// that we use an unhardened path so we can make use of xpubs.
@@ -473,7 +473,6 @@ impl BenefactorWallet {
473473

474474
let input = Input {
475475
witness_utxo: {
476-
let script_pubkey = script_pubkey;
477476
let amount = Amount::from_sat(value);
478477

479478
Some(TxOut {

hashes/benches/hashes.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ fn bench_siphash24(c: &mut Criterion) {
128128
for (size, label) in [(1024, "1k"), (65536, "64k"), (1048576, "1m")] {
129129
group.throughput(Throughput::Bytes(size as u64));
130130
group.bench_with_input(BenchmarkId::from_parameter(label), &size, |b, &size| {
131-
let key = [0u8; 16];
132131
let bytes = vec![1u8; size];
133132
b.iter(|| {
134133
let hash =
@@ -217,26 +216,26 @@ fn bench_slice_comparisons(c: &mut Criterion) {
217216
group.bench_function("32b_ne", |b| {
218217
let hash_a = sha256::Hash::hash(&[0; 1]);
219218
let hash_b = sha256::Hash::hash(&[1; 1]);
220-
b.iter(|| &hash_a[..] == &hash_b[..]);
219+
b.iter(|| hash_a[..] == hash_b[..]);
221220
});
222221

223222
group.bench_function("32b_eq", |b| {
224223
let hash_a = sha256::Hash::hash(&[0; 1]);
225224
let hash_b = sha256::Hash::hash(&[0; 1]);
226-
b.iter(|| &hash_a[..] == &hash_b[..]);
225+
b.iter(|| hash_a[..] == hash_b[..]);
227226
});
228227

229228
// 64-byte comparisons (SHA512)
230229
group.bench_function("64b_ne", |b| {
231230
let hash_a = sha512::Hash::hash(&[0; 1]);
232231
let hash_b = sha512::Hash::hash(&[1; 1]);
233-
b.iter(|| &hash_a[..] == &hash_b[..]);
232+
b.iter(|| hash_a[..] == hash_b[..]);
234233
});
235234

236235
group.bench_function("64b_eq", |b| {
237236
let hash_a = sha512::Hash::hash(&[0; 1]);
238237
let hash_b = sha512::Hash::hash(&[0; 1]);
239-
b.iter(|| &hash_a[..] == &hash_b[..]);
238+
b.iter(|| hash_a[..] == hash_b[..]);
240239
});
241240

242241
group.finish();

key-wallet-manager/examples/wallet_creation.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
//! - Creating wallets from mnemonics
66
//! - Managing wallet accounts and addresses
77
8-
use hex;
98
use key_wallet::account::StandardAccountType;
109
use key_wallet::wallet::initialization::WalletAccountCreationOptions;
1110
use key_wallet::wallet::managed_wallet_info::transaction_building::AccountTypePreference;

rpc-client/examples/connect_to_masternode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ fn main() {
7373
println!("\nQuorum list: \n{:?}", quorum_list);
7474

7575
let quorum_hashes = quorum_list.quorums_by_type.get(&QuorumType::LlmqTest).unwrap();
76-
let quorum_hash = quorum_hashes.get(0);
76+
let quorum_hash = quorum_hashes.first();
7777

7878
// Get Quorum info
7979
let quorum_info =
@@ -83,7 +83,7 @@ fn main() {
8383
let quorum_listextended = rpc.get_quorum_listextended(Some(quorum_info.height)).unwrap();
8484
println!("\n\nQuorum list extended \n{:?}", quorum_listextended);
8585

86-
let mn0 = quorum_info.members.get(0).unwrap();
86+
let mn0 = quorum_info.members.first().unwrap();
8787
let mn0_pro_tx_hash = mn0.to_owned().pro_tx_hash;
8888

8989
// Get Quorum DKG status

rpc-client/src/client.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,7 @@ pub trait RpcApi: Sized {
841841
self.call("getchaintips", &[])
842842
}
843843

844+
#[allow(clippy::too_many_arguments)]
844845
fn send_to_address(
845846
&self,
846847
address: &Address,
@@ -995,7 +996,7 @@ pub trait RpcApi: Sized {
995996
/// # Arguments
996997
///
997998
/// 1. `timeout`: Time in milliseconds to wait for a response. 0
998-
/// indicates no timeout.
999+
/// indicates no timeout.
9991000
fn wait_for_new_block(&self, timeout: u64) -> Result<json::BlockRef> {
10001001
self.call("waitfornewblock", &[into_json(timeout)?])
10011002
}
@@ -1007,7 +1008,7 @@ pub trait RpcApi: Sized {
10071008
///
10081009
/// 1. `blockhash`: Block hash to wait for.
10091010
/// 2. `timeout`: Time in milliseconds to wait for a response. 0
1010-
/// indicates no timeout.
1011+
/// indicates no timeout.
10111012
fn wait_for_block(
10121013
&self,
10131014
blockhash: &dashcore::BlockHash,
@@ -1452,6 +1453,7 @@ pub trait RpcApi: Sized {
14521453
}
14531454

14541455
/// Creates a ProRegTx referencing an existing collateral and and sends it to the network
1456+
#[allow(clippy::too_many_arguments)]
14551457
fn get_protx_register(
14561458
&self,
14571459
collateral_hash: &str,
@@ -1482,6 +1484,7 @@ pub trait RpcApi: Sized {
14821484
}
14831485

14841486
/// Creates and funds a ProRegTx with the 1,000 DASH necessary for a masternode and then sends it to the network
1487+
#[allow(clippy::too_many_arguments)]
14851488
fn get_protx_register_fund(
14861489
&self,
14871490
collateral_address: &str,
@@ -1510,6 +1513,7 @@ pub trait RpcApi: Sized {
15101513
}
15111514

15121515
/// Creates an unsigned ProTx and a message that must be signed externally
1516+
#[allow(clippy::too_many_arguments)]
15131517
fn get_protx_register_prepare(
15141518
&self,
15151519
collateral_hash: &str,
@@ -1730,7 +1734,6 @@ fn log_response(cmd: &str, resp: &Result<jsonrpc::Response>) {
17301734
#[cfg(test)]
17311735
mod tests {
17321736
use super::*;
1733-
use serde_json;
17341737

17351738
#[test]
17361739
fn test_raw_tx() {

rpc-integration-test/src/main.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ fn btc<F: Into<f64>>(btc: F) -> Amount {
115115
}
116116

117117
/// Quickly create a signed BTC amount.
118+
#[allow(dead_code)]
118119
fn sbtc<F: Into<f64>>(btc: F) -> SignedAmount {
119120
SignedAmount::from_btc(btc.into()).unwrap()
120121
}
@@ -422,6 +423,7 @@ fn test_dump_private_key(cl: &Client) {
422423
assert_eq!(addr.to_string(), Address::p2pkh(&sk.public_key(&SECP), *NET).to_string());
423424
}
424425

426+
#[allow(dead_code)]
425427
fn test_get_balance_generate_to_address(cl: &Client) {
426428
let initial = cl.get_balance(None, None).unwrap();
427429

@@ -464,6 +466,7 @@ fn test_get_block_hash(cl: &Client) {
464466
assert_eq!(cl.get_block_hash(h).unwrap(), cl.get_best_block_hash().unwrap());
465467
}
466468

469+
#[allow(dead_code)]
467470
fn test_get_block(cl: &Client) {
468471
let tip = cl.get_best_block_hash().unwrap();
469472
let block = cl.get_block(&tip).unwrap();
@@ -515,7 +518,7 @@ fn test_get_address_info(cl: &Client) {
515518
fn test_set_label(cl: &Client) {
516519
let addr = cl.get_new_address(Some("label")).unwrap().require_network(*NET).unwrap();
517520
let info = cl.get_address_info(&addr).unwrap();
518-
if wallet_node_version() >= 0_20_00_00 {
521+
if wallet_node_version() >= 20_00_00 {
519522
assert!(info.label.is_none());
520523
assert_eq!(info.labels[0], json::GetAddressInfoResultLabel::Simple("label".into()));
521524
} else {
@@ -531,7 +534,7 @@ fn test_set_label(cl: &Client) {
531534

532535
cl.set_label(&addr, "other").unwrap();
533536
let info = cl.get_address_info(&addr).unwrap();
534-
if wallet_node_version() >= 0_20_00_00 {
537+
if wallet_node_version() >= 20_00_00 {
535538
assert!(info.label.is_none());
536539
assert_eq!(info.labels[0], json::GetAddressInfoResultLabel::Simple("other".into()));
537540
} else {
@@ -677,6 +680,7 @@ fn test_get_tx_out(cl: &Client) {
677680
let _ = cl.get_tx_out(&txid, 0, None).unwrap();
678681
}
679682

683+
#[allow(dead_code)]
680684
fn test_get_tx_out_proof(cl: &Client) {
681685
let txid1 = cl
682686
.send_to_address(&RANDOM_ADDRESS, btc(1), None, None, None, None, None, None, None, None)
@@ -713,6 +717,7 @@ fn test_lock_unspent_unlock_unspent(cl: &Client) {
713717
assert!(cl.unlock_unspent_all().unwrap());
714718
}
715719

720+
#[allow(dead_code)]
716721
fn test_get_block_filter(cl: &Client) {
717722
let addr = &cl.get_new_address(None).unwrap().require_network(*NET).unwrap();
718723
let blocks = cl.generate_to_address(7, addr).unwrap();
@@ -1340,6 +1345,7 @@ fn test_getblocktemplate(cl: &Client) {
13401345
cl.generate_to_address(2, &RANDOM_ADDRESS).unwrap();
13411346
}
13421347

1348+
#[allow(dead_code)]
13431349
fn test_stop(cl: &Client) {
13441350
println!("Stopping: '{}'", cl.stop().unwrap());
13451351
}
@@ -1357,6 +1363,7 @@ fn test_get_masternode_list(cl: &Client) {
13571363
let _masternode_list = cl.get_masternode_list(Some("json"), None).unwrap();
13581364
}
13591365

1366+
#[allow(dead_code)]
13601367
fn test_get_masternode_outputs(cl: &Client) {
13611368
let _masternode_outputs = cl.get_masternode_outputs().unwrap();
13621369
}
@@ -1425,6 +1432,7 @@ fn test_get_quorum_sign(cl: &Client, _wallet_client: &Client) {
14251432
.unwrap();
14261433
}
14271434

1435+
#[allow(dead_code)]
14281436
fn test_get_quorum_getrecsig(cl: &Client) {
14291437
let list = cl.get_quorum_list(Some(1)).unwrap();
14301438
let quorum_type = list.quorums_by_type.keys().next().unwrap().to_owned();
@@ -1458,6 +1466,7 @@ fn test_get_quorum_isconflicting(cl: &Client) {
14581466
.unwrap();
14591467
}
14601468

1469+
#[allow(dead_code)]
14611470
fn test_get_quorum_memberof(cl: &Client) {
14621471
let pro_tx_hash =
14631472
ProTxHash::from_str("39c07d2c9c6d0ead56f52726b63c15e295cb5c3ecf7fe1fefcfb23b2e3cfed1f")
@@ -1466,6 +1475,7 @@ fn test_get_quorum_memberof(cl: &Client) {
14661475
assert!(quorum_memberof.0[0].height > 0);
14671476
}
14681477

1478+
#[allow(dead_code)]
14691479
fn test_get_quorum_rotationinfo(cl: &Client) {
14701480
let block_hash =
14711481
BlockHash::from_str("0000012197b7ca6360af3756c6a49c217dbbdf8b595fd55e0fcef7ffcd546044")
@@ -1482,6 +1492,7 @@ fn test_get_quorum_selectquorum(cl: &Client) {
14821492
.unwrap();
14831493
}
14841494

1495+
#[allow(dead_code)]
14851496
fn test_get_quorum_verify(cl: &Client) {
14861497
let _quorum_verify = cl.get_quorum_verify(
14871498
LlmqTest,
@@ -1513,6 +1524,7 @@ fn test_get_protx_diff(cl: &Client) {
15131524
let _protx_diff = cl.get_protx_diff(1000, 1000).unwrap();
15141525
}
15151526

1527+
#[allow(dead_code)]
15161528
fn test_get_protx_info(cl: &Client) {
15171529
let pro_tx_hash =
15181530
ProTxHash::from_str("000000000c9eddd5d2a707281b7e30d5aac974dac600ff10f01937e1ca36066f")
@@ -1538,6 +1550,7 @@ fn test_get_protx_list(cl: &Client) {
15381550
cl.get_protx_list(Some(ProTxListType::Valid), Some(true), Some(1000)).unwrap();
15391551
}
15401552

1553+
#[allow(dead_code)]
15411554
fn test_get_protx_register(cl: &Client) {
15421555
let _protx_register = cl.get_protx_register(
15431556
"8b2eab3413abb6e04d17d1defe2b71039ba6b6f72ea1e5dab29bb10e7b745948",
@@ -1553,11 +1566,13 @@ fn test_get_protx_register(cl: &Client) {
15531566
).unwrap();
15541567
}
15551568

1569+
#[allow(dead_code)]
15561570
fn test_get_protx_register_fund(cl: &Client) {
15571571
let _protx_register_fund = cl.get_protx_register_fund("yakx4mMRptKhgfjedNzX5FGQq7kSSBF2e7", "3.4.5.6:3456", "yURczr3qY31xkQZfFu8eZvKz19eAEPQxsd", "0e02146e9c34cfbcb3f3037574a1abb35525e2ca0c3c6901dbf82ac591e30218d1711223b7ca956edf39f3d984d06d51", "yURczr3qY31xkQZfFu8eZvKz19eAEPQxsd",
15581572
5.0, "yUYTxqjpCfAAK4vgxXtBPywRBtZqsxN7Vy", Some("yRMFHxcJ2aS2vfo5whhE2Gg73dfQVm8LAF"), Some(false)).unwrap();
15591573
}
15601574

1575+
#[allow(dead_code)]
15611576
fn test_get_protx_register_prepare(cl: &Client) {
15621577
let owner_address = Address::<NetworkUnchecked>::from_str("yemjhGQ99V5ayJMjoyGGPtxteahii6G1Jz")
15631578
.unwrap()
@@ -1589,13 +1604,15 @@ fn test_get_protx_register_prepare(cl: &Client) {
15891604
).unwrap();
15901605
}
15911606

1607+
#[allow(dead_code)]
15921608
fn test_get_protx_register_submit(cl: &Client) {
15931609
let _protx_register_submit = cl.get_protx_register_submit(
15941610
"03000100012d988526d5d1efd32320023c92eff09c2963dcb021b0de9761",
15951611
"H90IvqVtFjZkwLJb08yMEgGixs0/FpcdvwImBcir4cYLJhD3pdX+lKD2GsPl6KNxghVXNk5/HpOdBoWAHo9u++Y=",
15961612
).unwrap();
15971613
}
15981614

1615+
#[allow(dead_code)]
15991616
fn test_get_protx_revoke(cl: &Client) {
16001617
let _protx_revoke = cl
16011618
.get_protx_revoke(
@@ -1607,6 +1624,7 @@ fn test_get_protx_revoke(cl: &Client) {
16071624
.unwrap();
16081625
}
16091626

1627+
#[allow(dead_code)]
16101628
fn test_get_protx_update_registrar(cl: &Client) {
16111629
let voting_address =
16121630
Address::<NetworkUnchecked>::from_str("yX2cDS4kcJ4LK4uq9Hd4TG7kURV3sGLZrw")
@@ -1623,6 +1641,7 @@ fn test_get_protx_update_registrar(cl: &Client) {
16231641
).unwrap();
16241642
}
16251643

1644+
#[allow(dead_code)]
16261645
fn test_get_protx_update_service(cl: &Client) {
16271646
let _protx_update_service = cl
16281647
.get_protx_update_service(
@@ -1635,6 +1654,7 @@ fn test_get_protx_update_service(cl: &Client) {
16351654
.unwrap();
16361655
}
16371656

1657+
#[allow(dead_code)]
16381658
fn test_get_verifychainlock(cl: &Client) {
16391659
let _verifychainlock = cl.get_verifychainlock("00000036d5c520be6e9a32d3829efc983a7b5e88052bf138f80a2b3988689a24", "97ec34efd1615b84af62495e54024880752f57790cf450ae974b80002440963592d96826e24f109e6c149411b70bb9a0035443752368590adae60365cf4251464e0423c1263e9c56a33eae9be9e9c79a117151b2173bcee93497008cace8d793", None).unwrap();
16401660
}
@@ -1645,6 +1665,7 @@ fn test_get_asset_unlock_statuses(cl: &Client) {
16451665
let _statuses = cl.get_asset_unlock_statuses(&indices, height);
16461666
}
16471667

1668+
#[allow(dead_code)]
16481669
fn test_get_verifyislock(cl: &Client) {
16491670
let _verifychainlock = cl.get_verifyislock("d0b1a9c70fdfff6bf7f6cbe3d1fe33a4ca44ceb17059b6381a4ac25d9c9b6495", "8b5174d0e95b5642ebec23c3fe8f0bbf8f6993502f4210322871bba0e818ff3b", "97ec34efd1615b84af62495e54024880752f57790cf450ae974b80002440963592d96826e24f109e6c149411b70bb9a0035443752368590adae60365cf4251464e0423c1263e9c56a33eae9be9e9c79a117151b2173bcee93497008cace8d793", None).unwrap();
16501671
}

rpc-json/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3270,10 +3270,10 @@ mod tests {
32703270
}
32713271

32723272
let json = r#"{"field": 1}"#;
3273-
let result: Test = serde_json::from_str(&json).unwrap();
3273+
let result: Test = serde_json::from_str(json).unwrap();
32743274
assert_eq!(result.field, Some(1));
32753275
let json = r#"{"field": -1}"#;
3276-
let result: Test = serde_json::from_str(&json).unwrap();
3276+
let result: Test = serde_json::from_str(json).unwrap();
32773277
assert_eq!(result.field, None);
32783278
}
32793279

@@ -3294,7 +3294,7 @@ mod tests {
32943294
let result: ExtendedQuorumListResult =
32953295
serde_json::from_str(json_list).expect("expected to deserialize json");
32963296
let first_type = result.quorums_by_type.get(&QuorumType::Llmq50_60).unwrap();
3297-
let first_quorum = first_type.into_iter().nth(0).unwrap();
3297+
let first_quorum = first_type.iter().next().unwrap();
32983298

32993299
assert_eq!(
33003300
first_quorum.0.to_byte_array(),
@@ -3424,7 +3424,7 @@ mod tests {
34243424
]
34253425
}"#;
34263426
let result: MasternodeListDiff =
3427-
serde_json::from_str(&json).expect("expected to deserialize json");
3427+
serde_json::from_str(json).expect("expected to deserialize json");
34283428
println!("{:#?}", result);
34293429
assert_eq!(32, result.added_mns[0].pro_tx_hash.as_byte_array().len());
34303430

0 commit comments

Comments
 (0)