Skip to content

Commit c929437

Browse files
committed
run clippy with --all-targets --all-features
...which found another massive pile of stuff.
1 parent 197149f commit c929437

13 files changed

Lines changed: 76 additions & 76 deletions

examples/pset_blind_coinjoin.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,38 +49,38 @@ fn parse_txout(txout_info: &str) -> (TxOut, Secrets, pset::Input) {
4949

5050
let txout = TxOut {
5151
asset: deserialize::<confidential::Asset>(
52-
&Vec::<u8>::from_hex(&v["assetcommitment"].as_str().unwrap()).unwrap(),
52+
&Vec::<u8>::from_hex(v["assetcommitment"].as_str().unwrap()).unwrap(),
5353
)
5454
.unwrap(),
5555
value: deserialize::<confidential::Value>(
56-
&Vec::<u8>::from_hex(&v["amountcommitment"].as_str().unwrap()).unwrap(),
56+
&Vec::<u8>::from_hex(v["amountcommitment"].as_str().unwrap()).unwrap(),
5757
)
5858
.unwrap(),
5959
nonce: deserialize::<confidential::Nonce>(
60-
&Vec::<u8>::from_hex(&v["commitmentnonce"].as_str().unwrap()).unwrap(),
60+
&Vec::<u8>::from_hex(v["commitmentnonce"].as_str().unwrap()).unwrap(),
6161
)
6262
.unwrap(),
63-
script_pubkey: Script::from_hex(&v["scriptPubKey"].as_str().unwrap()).unwrap(),
63+
script_pubkey: Script::from_hex(v["scriptPubKey"].as_str().unwrap()).unwrap(),
6464
witness: TxOutWitness::default(),
6565
};
6666

6767
let txoutsecrets = Secrets {
68-
_sk: bitcoin::PrivateKey::from_wif(&v["skwif"].as_str().unwrap()).unwrap(),
68+
_sk: bitcoin::PrivateKey::from_wif(v["skwif"].as_str().unwrap()).unwrap(),
6969
sec: TxOutSecrets {
70-
asset_bf: AssetBlindingFactor::from_str(&v["assetblinder"].as_str().unwrap()).unwrap(),
71-
value_bf: ValueBlindingFactor::from_str(&v["amountblinder"].as_str().unwrap()).unwrap(),
70+
asset_bf: AssetBlindingFactor::from_str(v["assetblinder"].as_str().unwrap()).unwrap(),
71+
value_bf: ValueBlindingFactor::from_str(v["amountblinder"].as_str().unwrap()).unwrap(),
7272
value: bitcoin::Amount::from_str_in(
73-
&v["amount"].as_str().unwrap(),
73+
v["amount"].as_str().unwrap(),
7474
bitcoin::Denomination::Bitcoin,
7575
)
7676
.unwrap()
7777
.to_sat(),
78-
asset: AssetId::from_str(&v["asset"].as_str().unwrap()).unwrap(),
78+
asset: AssetId::from_str(v["asset"].as_str().unwrap()).unwrap(),
7979
},
8080
};
8181

8282
let inp = pset::Input::from_prevout(OutPoint::new(
83-
Txid::from_str(&v["txid"].as_str().unwrap()).unwrap(),
83+
Txid::from_str(v["txid"].as_str().unwrap()).unwrap(),
8484
v["vout"].as_u64().unwrap() as u32,
8585
));
8686

examples/raw_blind.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,38 +45,38 @@ fn parse_txout(txout_info: &str) -> (TxOut, Secrets, pset::Input) {
4545

4646
let txout = TxOut {
4747
asset: deserialize::<confidential::Asset>(
48-
&Vec::<u8>::from_hex(&v["assetcommitment"].as_str().unwrap()).unwrap(),
48+
&Vec::<u8>::from_hex(v["assetcommitment"].as_str().unwrap()).unwrap(),
4949
)
5050
.unwrap(),
5151
value: deserialize::<confidential::Value>(
52-
&Vec::<u8>::from_hex(&v["amountcommitment"].as_str().unwrap()).unwrap(),
52+
&Vec::<u8>::from_hex(v["amountcommitment"].as_str().unwrap()).unwrap(),
5353
)
5454
.unwrap(),
5555
nonce: deserialize::<confidential::Nonce>(
56-
&Vec::<u8>::from_hex(&v["commitmentnonce"].as_str().unwrap()).unwrap(),
56+
&Vec::<u8>::from_hex(v["commitmentnonce"].as_str().unwrap()).unwrap(),
5757
)
5858
.unwrap(),
59-
script_pubkey: Script::from_hex(&v["scriptPubKey"].as_str().unwrap()).unwrap(),
59+
script_pubkey: Script::from_hex(v["scriptPubKey"].as_str().unwrap()).unwrap(),
6060
witness: TxOutWitness::default(),
6161
};
6262

6363
let txoutsecrets = Secrets {
64-
_sk: bitcoin::PrivateKey::from_wif(&v["skwif"].as_str().unwrap()).unwrap(),
64+
_sk: bitcoin::PrivateKey::from_wif(v["skwif"].as_str().unwrap()).unwrap(),
6565
sec: TxOutSecrets {
66-
asset_bf: AssetBlindingFactor::from_str(&v["assetblinder"].as_str().unwrap()).unwrap(),
67-
value_bf: ValueBlindingFactor::from_str(&v["amountblinder"].as_str().unwrap()).unwrap(),
66+
asset_bf: AssetBlindingFactor::from_str(v["assetblinder"].as_str().unwrap()).unwrap(),
67+
value_bf: ValueBlindingFactor::from_str(v["amountblinder"].as_str().unwrap()).unwrap(),
6868
value: bitcoin::Amount::from_str_in(
69-
&v["amount"].as_str().unwrap(),
69+
v["amount"].as_str().unwrap(),
7070
bitcoin::Denomination::Bitcoin,
7171
)
7272
.unwrap()
7373
.to_sat(),
74-
asset: AssetId::from_str(&v["asset"].as_str().unwrap()).unwrap(),
74+
asset: AssetId::from_str(v["asset"].as_str().unwrap()).unwrap(),
7575
},
7676
};
7777

7878
let inp = pset::Input::from_prevout(OutPoint::new(
79-
Txid::from_str(&v["txid"].as_str().unwrap()).unwrap(),
79+
Txid::from_str(v["txid"].as_str().unwrap()).unwrap(),
8080
v["vout"].as_u64().unwrap() as u32,
8181
));
8282

src/address.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ mod test {
770770
);
771771
#[cfg(feature = "serde")]
772772
assert_eq!(
773-
serde_json::from_value::<Address>(serde_json::to_value(&addr).unwrap()).ok().as_ref(),
773+
serde_json::from_value::<Address>(serde_json::to_value(addr).unwrap()).ok().as_ref(),
774774
Some(addr)
775775
);
776776
}

src/blind.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,7 +1459,7 @@ mod tests {
14591459
let (address, blinding_sk) = {
14601460
let sk = SecretKey::new(&mut thread_rng());
14611461
let pk = PublicKey::from_private_key(
1462-
&SECP256K1,
1462+
SECP256K1,
14631463
&PrivateKey {
14641464
compressed: true,
14651465
network: Network::Regtest,
@@ -1468,7 +1468,7 @@ mod tests {
14681468
);
14691469
let blinding_sk = SecretKey::new(&mut thread_rng());
14701470
let blinding_pk = PublicKey::from_private_key(
1471-
&SECP256K1,
1471+
SECP256K1,
14721472
&PrivateKey {
14731473
compressed: true,
14741474
network: Network::Regtest,

src/block.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ mod tests {
399399

400400
use super::*;
401401

402-
const SIMPLE_BLOCK: &'static str = "\
402+
const SIMPLE_BLOCK: &str = "\
403403
00000020a66e4a4baff69735267346d12e59e8a0da848b593813554deb16a6f3\
404404
6cd035e9aab0e2451724598471dd4e45f0dca40ca5f4ac62e61957e50925af08\
405405
59891fcc8842805b020000000151000102000000010100000000000000000000\
@@ -411,7 +411,7 @@ mod tests {
411411
7d45000000000000012000000000000000000000000000000000000000000000\
412412
000000000000000000000000000000\
413413
";
414-
const DYNAFED_BLOCK: &'static str = "\
414+
const DYNAFED_BLOCK: &str = "\
415415
000000a0da9d569617d1d65c3390a01c18c4fa7c4d0f4738b6fc2b5c5faf2e8a\
416416
463abbaa46eb9123808e1e2ff75e9472fa0f0589b53b7518a69d3d6fcb9228ed\
417417
345734ea06b9c45d070000000122002057c555a91edf9552282d88624d1473c2\

src/dynafed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl<'a> Serialize for HexBytes<'a> {
4343
if s.is_human_readable() {
4444
s.collect_str(self)
4545
} else {
46-
s.serialize_bytes(&self.0[..])
46+
s.serialize_bytes(self.0)
4747
}
4848
}
4949
}

src/fast_merkle_root.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ mod tests {
115115
let mut leaves = vec![];
116116
for i in 0..4 {
117117
let root = fast_merkle_root(&leaves);
118-
assert_eq!(root, FromStr::from_str(&test_roots[i]).unwrap(), "root #{}", i);
119-
leaves.push(sha256::Midstate::from_str(&test_leaves[i]).unwrap().to_byte_array());
118+
assert_eq!(root, FromStr::from_str(test_roots[i]).unwrap(), "root #{}", i);
119+
leaves.push(sha256::Midstate::from_str(test_leaves[i]).unwrap().to_byte_array());
120120
}
121121
assert_eq!(fast_merkle_root(&leaves), FromStr::from_str(test_roots[4]).unwrap());
122122
}

src/issuance.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -340,26 +340,26 @@ mod test {
340340
let correct = r#"{"entity":{"domain":"tether.to"},"issuer_pubkey":"0337cceec0beea0232ebe14cba0197a9fbd45fcf2ec946749de920e71434c2b904","name":"Tether USD","precision":8,"ticker":"USDt","version":0}"#;
341341
let expected = ContractHash::hash(correct.as_bytes());
342342
assert_eq!(tether, expected);
343-
assert_eq!(expected, ContractHash::from_json_contract(&correct).unwrap());
343+
assert_eq!(expected, ContractHash::from_json_contract(correct).unwrap());
344344

345345
let invalid_json = r#"{"entity":{"domain":"tether.to"},"issuer_pubkey:"#;
346-
assert!(ContractHash::from_json_contract(&invalid_json).is_err());
346+
assert!(ContractHash::from_json_contract(invalid_json).is_err());
347347

348348
let unordered = r#"{"precision":8,"ticker":"USDt","entity":{"domain":"tether.to"},"issuer_pubkey":"0337cceec0beea0232ebe14cba0197a9fbd45fcf2ec946749de920e71434c2b904","name":"Tether USD","version":0}"#;
349-
assert_eq!(expected, ContractHash::from_json_contract(&unordered).unwrap());
349+
assert_eq!(expected, ContractHash::from_json_contract(unordered).unwrap());
350350

351351
let unordered = r#"{"precision":8,"name":"Tether USD","ticker":"USDt","entity":{"domain":"tether.to"},"issuer_pubkey":"0337cceec0beea0232ebe14cba0197a9fbd45fcf2ec946749de920e71434c2b904","version":0}"#;
352-
assert_eq!(expected, ContractHash::from_json_contract(&unordered).unwrap());
352+
assert_eq!(expected, ContractHash::from_json_contract(unordered).unwrap());
353353

354354
let spaces = r#"{"precision":8, "name" : "Tether USD", "ticker":"USDt", "entity":{"domain":"tether.to" }, "issuer_pubkey" :"0337cceec0beea0232ebe14cba0197a9fbd45fcf2ec946749de920e71434c2b904","version":0} "#;
355-
assert_eq!(expected, ContractHash::from_json_contract(&spaces).unwrap());
355+
assert_eq!(expected, ContractHash::from_json_contract(spaces).unwrap());
356356

357357
let nested_correct = r#"{"entity":{"author":"Tether Inc","copyright":2020,"domain":"tether.to","hq":"Mars"},"issuer_pubkey":"0337cceec0beea0232ebe14cba0197a9fbd45fcf2ec946749de920e71434c2b904","name":"Tether USD","precision":8,"ticker":"USDt","version":0}"#;
358358
let nested_expected = ContractHash::hash(nested_correct.as_bytes());
359-
assert_eq!(nested_expected, ContractHash::from_json_contract(&nested_correct).unwrap());
359+
assert_eq!(nested_expected, ContractHash::from_json_contract(nested_correct).unwrap());
360360

361361
let nested_unordered = r#"{"ticker":"USDt","entity":{"domain":"tether.to","hq":"Mars","author":"Tether Inc","copyright":2020},"issuer_pubkey":"0337cceec0beea0232ebe14cba0197a9fbd45fcf2ec946749de920e71434c2b904","name":"Tether USD","precision":8,"version":0}"#;
362-
assert_eq!(nested_expected, ContractHash::from_json_contract(&nested_unordered).unwrap());
362+
assert_eq!(nested_expected, ContractHash::from_json_contract(nested_unordered).unwrap());
363363
}
364364

365365
#[test]

src/pset/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ mod tests {
812812

813813
let pset_hex = "70736574ff01020402000000010401010105010201fb04020000000001017a0bb9325c276764451bbc2eb82a4c8c4bb6f4007ba803e5a5ba72d0cd7c09848e1a091622d935953bf06e0b7393239c68c6f810a00fe19d11c6ae343cffd3037077da02535fe4ad0fcd675cd0f62bf73b60a554dc1569b80f1f76a2bbfc9f00d439bf4b160014d2cbec8783bd01c9f178348b08500a830a89a7f9010e20805131ba6b37165c026eed9325ac56059ba872fd569e3ed462734098688b4770010f0400000000000103088c83b50d0000000007fc04707365740220230f4f5d4b7c6fa845806ee4f67713459e1b69e8e60fcee2e4940c7a0d5de1b20104220020e5793ad956ee91ebf3543b37d110701118ed4078ffa0d477eacb8885e486ad8507fc047073657406210212bf0ea45b733dfde8ecb5e896306c4165c666c99fc5d1ab887f71393a975cea07fc047073657408040000000000010308f40100000000000007fc04707365740220230f4f5d4b7c6fa845806ee4f67713459e1b69e8e60fcee2e4940c7a0d5de1b201040000";
814814
let mut pset: PartiallySignedTransaction =
815-
encode::deserialize(&Vec::<u8>::from_hex(&pset_hex).unwrap()[..]).unwrap();
815+
encode::deserialize(&Vec::<u8>::from_hex(pset_hex).unwrap()[..]).unwrap();
816816

817817
let btc_txout_secrets_str = r#"
818818
{
@@ -823,15 +823,15 @@ mod tests {
823823
}"#;
824824
let v: serde_json::Value = serde_json::from_str(btc_txout_secrets_str).unwrap();
825825
let btc_txout_secrets = TxOutSecrets {
826-
asset_bf: AssetBlindingFactor::from_str(&v["assetblinder"].as_str().unwrap()).unwrap(),
827-
value_bf: ValueBlindingFactor::from_str(&v["amountblinder"].as_str().unwrap()).unwrap(),
826+
asset_bf: AssetBlindingFactor::from_str(v["assetblinder"].as_str().unwrap()).unwrap(),
827+
value_bf: ValueBlindingFactor::from_str(v["amountblinder"].as_str().unwrap()).unwrap(),
828828
value: bitcoin::Amount::from_str_in(
829-
&v["amount"].as_str().unwrap(),
829+
v["amount"].as_str().unwrap(),
830830
bitcoin::Denomination::Bitcoin,
831831
)
832832
.unwrap()
833833
.to_sat(),
834-
asset: AssetId::from_str(&v["asset"].as_str().unwrap()).unwrap(),
834+
asset: AssetId::from_str(v["asset"].as_str().unwrap()).unwrap(),
835835
};
836836

837837
let mut inp_txout_sec = HashMap::new();

src/script.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,18 +1090,18 @@ mod test {
10901090
#[test]
10911091
fn provably_unspendable_test() {
10921092
// p2pk
1093-
assert_eq!(hex_script!("410446ef0102d1ec5240f0d061a4246c1bdef63fc3dbab7733052fbbf0ecd8f41fc26bf049ebb4f9527f374280259e7cfa99c48b0e3f39c51347a19a5819651503a5ac").is_provably_unspendable(), false);
1094-
assert_eq!(hex_script!("4104ea1feff861b51fe3f5f8a3b12d0f4712db80e919548a80839fc47c6a21e66d957e9c5d8cd108c7a2d2324bad71f9904ac0ae7336507d785b17a2c115e427a32fac").is_provably_unspendable(), false);
1093+
assert!(!hex_script!("410446ef0102d1ec5240f0d061a4246c1bdef63fc3dbab7733052fbbf0ecd8f41fc26bf049ebb4f9527f374280259e7cfa99c48b0e3f39c51347a19a5819651503a5ac").is_provably_unspendable());
1094+
assert!(!hex_script!("4104ea1feff861b51fe3f5f8a3b12d0f4712db80e919548a80839fc47c6a21e66d957e9c5d8cd108c7a2d2324bad71f9904ac0ae7336507d785b17a2c115e427a32fac").is_provably_unspendable());
10951095
// p2pkhash
1096-
assert_eq!(hex_script!("76a914ee61d57ab51b9d212335b1dba62794ac20d2bcf988ac").is_provably_unspendable(), false);
1097-
assert_eq!(hex_script!("6aa9149eb21980dc9d413d8eac27314938b9da920ee53e87").is_provably_unspendable(), true);
1096+
assert!(!hex_script!("76a914ee61d57ab51b9d212335b1dba62794ac20d2bcf988ac").is_provably_unspendable());
1097+
assert!(hex_script!("6aa9149eb21980dc9d413d8eac27314938b9da920ee53e87").is_provably_unspendable());
10981098
}
10991099

11001100
#[test]
11011101
fn op_return_test() {
1102-
assert_eq!(hex_script!("6aa9149eb21980dc9d413d8eac27314938b9da920ee53e87").is_op_return(), true);
1103-
assert_eq!(hex_script!("76a914ee61d57ab51b9d212335b1dba62794ac20d2bcf988ac").is_op_return(), false);
1104-
assert_eq!(hex_script!("").is_op_return(), false);
1102+
assert!(hex_script!("6aa9149eb21980dc9d413d8eac27314938b9da920ee53e87").is_op_return());
1103+
assert!(!hex_script!("76a914ee61d57ab51b9d212335b1dba62794ac20d2bcf988ac").is_op_return());
1104+
assert!(!hex_script!("").is_op_return());
11051105
}
11061106

11071107
#[test]

0 commit comments

Comments
 (0)