diff --git a/components/equihash/src/verify.rs b/components/equihash/src/verify.rs index f356acdf9..1fdbb91a9 100644 --- a/components/equihash/src/verify.rs +++ b/components/equihash/src/verify.rs @@ -314,7 +314,7 @@ fn tree_validator(p: &Params, state: &Blake2bState, indices: &[u32]) -> Result State<'a> { let hash = Blake2bParams::new() .hash_length(self.left.len()) .personal(&H_PERS!(i)) - .hash(&self.right); + .hash(self.right); xor(self.left, hash.as_bytes()) } @@ -103,7 +103,7 @@ impl<'a> State<'a> { let hash = Blake2bParams::new() .hash_length(OUTBYTES) .personal(&G_PERS!(i, j as u16)) - .hash(&self.left); + .hash(self.left); xor(&mut self.right[j * OUTBYTES..], hash.as_bytes()); } } @@ -198,11 +198,11 @@ mod common_tests { #[cfg(feature = "std")] let mut cache = vec![0u8; test_vectors::MAX_VECTOR_LENGTH]; for v in test_vectors::TEST_VECTORS { - let mut data = &mut cache[..v.normal.len()]; - data.clone_from_slice(&v.normal); - f4jumble_mut(&mut data).unwrap(); + let data = &mut cache[..v.normal.len()]; + data.clone_from_slice(v.normal); + f4jumble_mut(data).unwrap(); assert_eq!(data, v.jumbled); - f4jumble_inv_mut(&mut data).unwrap(); + f4jumble_inv_mut(data).unwrap(); assert_eq!(data, v.normal); } } @@ -246,9 +246,9 @@ mod std_tests { #[test] fn f4jumble_check_vectors() { for v in test_vectors::TEST_VECTORS { - let jumbled = f4jumble(&v.normal).unwrap(); + let jumbled = f4jumble(v.normal).unwrap(); assert_eq!(jumbled, v.jumbled); - let unjumbled = f4jumble_inv(&v.jumbled).unwrap(); + let unjumbled = f4jumble_inv(v.jumbled).unwrap(); assert_eq!(unjumbled, v.normal); } } diff --git a/components/zcash_note_encryption/src/lib.rs b/components/zcash_note_encryption/src/lib.rs index ed3edd5c3..8a02098e6 100644 --- a/components/zcash_note_encryption/src/lib.rs +++ b/components/zcash_note_encryption/src/lib.rs @@ -475,7 +475,7 @@ impl NoteEncryption { rng: &mut R, ) -> [u8; OUT_CIPHERTEXT_SIZE] { let (ock, input) = if let Some(ovk) = &self.ovk { - let ock = D::derive_ock(ovk, &cv, &cmstar.into(), &D::epk_bytes(&self.epk)); + let ock = D::derive_ock(ovk, cv, &cmstar.into(), &D::epk_bytes(&self.epk)); let input = D::outgoing_plaintext_bytes(&self.note, &self.esk); (ock, input) @@ -563,7 +563,7 @@ fn parse_note_plaintext_without_memo_ivk( cmstar_bytes: &D::ExtractedCommitmentBytes, plaintext: &[u8], ) -> Option<(D::Note, D::Recipient)> { - let (note, to) = domain.parse_note_plaintext_without_memo_ivk(ivk, &plaintext)?; + let (note, to) = domain.parse_note_plaintext_without_memo_ivk(ivk, plaintext)?; if let NoteValidity::Valid = check_note_validity::(¬e, ephemeral_key, cmstar_bytes) { Some((note, to)) @@ -577,10 +577,10 @@ fn check_note_validity( ephemeral_key: &EphemeralKeyBytes, cmstar_bytes: &D::ExtractedCommitmentBytes, ) -> NoteValidity { - if &D::ExtractedCommitmentBytes::from(&D::cmstar(¬e)) == cmstar_bytes { + if &D::ExtractedCommitmentBytes::from(&D::cmstar(note)) == cmstar_bytes { if let Some(derived_esk) = D::derive_esk(note) { - if D::epk_bytes(&D::ka_derive_public(¬e, &derived_esk)) - .ct_eq(&ephemeral_key) + if D::epk_bytes(&D::ka_derive_public(note, &derived_esk)) + .ct_eq(ephemeral_key) .into() { NoteValidity::Valid @@ -614,7 +614,7 @@ pub fn try_compact_note_decryption Option<(D::Note, D::Recipient, D::Memo)> { - let ock = D::derive_ock(ovk, &cv, &output.cmstar_bytes(), &output.ephemeral_key()); + let ock = D::derive_ock(ovk, cv, &output.cmstar_bytes(), &output.ephemeral_key()); try_output_recovery_with_ock(domain, &ock, output, out_ciphertext) } diff --git a/zcash_client_backend/src/data_api/wallet.rs b/zcash_client_backend/src/data_api/wallet.rs index c81c43085..0432b2af8 100644 --- a/zcash_client_backend/src/data_api/wallet.rs +++ b/zcash_client_backend/src/data_api/wallet.rs @@ -347,7 +347,7 @@ where Err(Error::MemoForbidden) } else { builder - .add_transparent_output(&to, payment.amount) + .add_transparent_output(to, payment.amount) .map_err(Error::Builder) } } @@ -439,7 +439,7 @@ where { // Check that the ExtendedSpendingKey we have been given corresponds to the // ExtendedFullViewingKey for the account we are spending from. - if !wallet_db.is_valid_account_extfvk(account, &extfvk)? { + if !wallet_db.is_valid_account_extfvk(account, extfvk)? { return Err(E::from(Error::InvalidExtSk(account))); } diff --git a/zcash_client_backend/src/encoding.rs b/zcash_client_backend/src/encoding.rs index 14e552efc..8ae1f3479 100644 --- a/zcash_client_backend/src/encoding.rs +++ b/zcash_client_backend/src/encoding.rs @@ -32,7 +32,7 @@ where { match bech32::decode(s)? { (decoded_hrp, data, Variant::Bech32) if decoded_hrp == hrp => { - Vec::::from_base32(&data).map(|data| read(data)) + Vec::::from_base32(&data).map(read) } _ => Ok(None), } diff --git a/zcash_client_backend/src/keys.rs b/zcash_client_backend/src/keys.rs index ba9789351..53c44f3a3 100644 --- a/zcash_client_backend/src/keys.rs +++ b/zcash_client_backend/src/keys.rs @@ -35,7 +35,7 @@ pub mod sapling { } ExtendedSpendingKey::from_path( - &ExtendedSpendingKey::master(&seed), + &ExtendedSpendingKey::master(seed), &[ ChildIndex::Hardened(32), ChildIndex::Hardened(coin_type), diff --git a/zcash_client_backend/src/welding_rig.rs b/zcash_client_backend/src/welding_rig.rs index fc943ac32..4eefce85b 100644 --- a/zcash_client_backend/src/welding_rig.rs +++ b/zcash_client_backend/src/welding_rig.rs @@ -68,7 +68,7 @@ fn scan_output( // - Change created by spending fractions of notes. // - Notes created by consolidation transactions. // - Notes sent from one account to itself. - let is_change = spent_from_accounts.contains(&account); + let is_change = spent_from_accounts.contains(account); let witness = IncrementalWitness::from_tree(tree); let nf = vk.nf(¬e, &witness); diff --git a/zcash_client_backend/src/zip321.rs b/zcash_client_backend/src/zip321.rs index c6e3cdda2..2d575844d 100644 --- a/zcash_client_backend/src/zip321.rs +++ b/zcash_client_backend/src/zip321.rs @@ -173,32 +173,32 @@ impl TransactionRequest { payment .memo .as_ref() - .map(|m| render::memo_param(&m, payment_index)), + .map(|m| render::memo_param(m, payment_index)), ) .chain( payment .label .as_ref() - .map(|m| render::str_param("label", &m, payment_index)), + .map(|m| render::str_param("label", m, payment_index)), ) .chain( payment .message .as_ref() - .map(|m| render::str_param("message", &m, payment_index)), + .map(|m| render::str_param("message", m, payment_index)), ) .chain( payment .other_params .iter() - .map(move |(name, value)| render::str_param(&name, &value, payment_index)), + .map(move |(name, value)| render::str_param(name, value, payment_index)), ) } match &self.payments[..] { [] => None, [payment] => { - let query_params = payment_params(&payment, None) + let query_params = payment_params(payment, None) .into_iter() .collect::>(); @@ -217,7 +217,7 @@ impl TransactionRequest { let primary_address = payment.recipient_address.clone(); std::iter::empty() .chain(Some(render::addr_param(params, &primary_address, Some(i)))) - .chain(payment_params(&payment, Some(i))) + .chain(payment_params(payment, Some(i))) }) .collect::>(); @@ -255,7 +255,7 @@ impl TransactionRequest { } Some(current) => { - if parse::has_duplicate_param(¤t, &p.param) { + if parse::has_duplicate_param(current, &p.param) { return Err(Zip321Error::DuplicateParameter(p.param, p.payment_index)); } else { current.push(p.param); @@ -775,12 +775,12 @@ mod tests { #[test] fn test_zip321_parse_simple() { let uri = "zcash:ztestsapling1n65uaftvs2g7075q2x2a04shfk066u3lldzxsrprfrqtzxnhc9ps73v4lhx4l9yfxj46sl0q90k?amount=3768769.02796286&message="; - let parse_result = TransactionRequest::from_uri(&TEST_NETWORK, &uri).unwrap(); + let parse_result = TransactionRequest::from_uri(&TEST_NETWORK, uri).unwrap(); let expected = TransactionRequest { payments: vec![ Payment { - recipient_address: RecipientAddress::Shielded(decode_payment_address(&TEST_NETWORK.hrp_sapling_payment_address(), "ztestsapling1n65uaftvs2g7075q2x2a04shfk066u3lldzxsrprfrqtzxnhc9ps73v4lhx4l9yfxj46sl0q90k").unwrap().unwrap()), + recipient_address: RecipientAddress::Shielded(decode_payment_address(TEST_NETWORK.hrp_sapling_payment_address(), "ztestsapling1n65uaftvs2g7075q2x2a04shfk066u3lldzxsrprfrqtzxnhc9ps73v4lhx4l9yfxj46sl0q90k").unwrap().unwrap()), amount: Amount::from_u64(376876902796286).unwrap(), memo: None, label: None, @@ -833,14 +833,14 @@ mod tests { #[test] fn test_zip321_spec_valid_examples() { let valid_1 = "zcash:ztestsapling10yy2ex5dcqkclhc7z7yrnjq2z6feyjad56ptwlfgmy77dmaqqrl9gyhprdx59qgmsnyfska2kez?amount=1&memo=VGhpcyBpcyBhIHNpbXBsZSBtZW1vLg&message=Thank%20you%20for%20your%20purchase"; - let v1r = TransactionRequest::from_uri(&TEST_NETWORK, &valid_1).unwrap(); + let v1r = TransactionRequest::from_uri(&TEST_NETWORK, valid_1).unwrap(); assert_eq!( v1r.payments.get(0).map(|p| p.amount), Some(Amount::from_u64(100000000).unwrap()) ); let valid_2 = "zcash:?address=tmEZhbWHTpdKMw5it8YDspUXSMGQyFwovpU&amount=123.456&address.1=ztestsapling10yy2ex5dcqkclhc7z7yrnjq2z6feyjad56ptwlfgmy77dmaqqrl9gyhprdx59qgmsnyfska2kez&amount.1=0.789&memo.1=VGhpcyBpcyBhIHVuaWNvZGUgbWVtbyDinKjwn6aE8J-PhvCfjok"; - let mut v2r = TransactionRequest::from_uri(&TEST_NETWORK, &valid_2).unwrap(); + let mut v2r = TransactionRequest::from_uri(&TEST_NETWORK, valid_2).unwrap(); v2r.normalize(&TEST_NETWORK); assert_eq!( v2r.payments.get(0).map(|p| p.amount), @@ -854,7 +854,7 @@ mod tests { // valid; amount just less than MAX_MONEY // 20999999.99999999 let valid_3 = "zcash:ztestsapling10yy2ex5dcqkclhc7z7yrnjq2z6feyjad56ptwlfgmy77dmaqqrl9gyhprdx59qgmsnyfska2kez?amount=20999999.99999999"; - let v3r = TransactionRequest::from_uri(&TEST_NETWORK, &valid_3).unwrap(); + let v3r = TransactionRequest::from_uri(&TEST_NETWORK, valid_3).unwrap(); assert_eq!( v3r.payments.get(0).map(|p| p.amount), Some(Amount::from_u64(2099999999999999u64).unwrap()) @@ -863,7 +863,7 @@ mod tests { // valid; MAX_MONEY // 21000000 let valid_4 = "zcash:ztestsapling10yy2ex5dcqkclhc7z7yrnjq2z6feyjad56ptwlfgmy77dmaqqrl9gyhprdx59qgmsnyfska2kez?amount=21000000"; - let v4r = TransactionRequest::from_uri(&TEST_NETWORK, &valid_4).unwrap(); + let v4r = TransactionRequest::from_uri(&TEST_NETWORK, valid_4).unwrap(); assert_eq!( v4r.payments.get(0).map(|p| p.amount), Some(Amount::from_u64(2100000000000000u64).unwrap()) @@ -874,63 +874,63 @@ mod tests { fn test_zip321_spec_invalid_examples() { // invalid; missing `address=` let invalid_1 = "zcash:?amount=3491405.05201255&address.1=ztestsapling10yy2ex5dcqkclhc7z7yrnjq2z6feyjad56ptwlfgmy77dmaqqrl9gyhprdx59qgmsnyfska2kez&amount.1=5740296.87793245"; - let i1r = TransactionRequest::from_uri(&TEST_NETWORK, &invalid_1); + let i1r = TransactionRequest::from_uri(&TEST_NETWORK, invalid_1); assert!(i1r.is_err()); // invalid; missing `address.1=` let invalid_2 = "zcash:?address=tmEZhbWHTpdKMw5it8YDspUXSMGQyFwovpU&amount=1&amount.1=2&address.2=ztestsapling10yy2ex5dcqkclhc7z7yrnjq2z6feyjad56ptwlfgmy77dmaqqrl9gyhprdx59qgmsnyfska2kez"; - let i2r = TransactionRequest::from_uri(&TEST_NETWORK, &invalid_2); + let i2r = TransactionRequest::from_uri(&TEST_NETWORK, invalid_2); assert!(i2r.is_err()); // invalid; `address.0=` and `amount.0=` are not permitted (leading 0s). let invalid_3 = "zcash:?address.0=ztestsapling10yy2ex5dcqkclhc7z7yrnjq2z6feyjad56ptwlfgmy77dmaqqrl9gyhprdx59qgmsnyfska2kez&amount.0=2"; - let i3r = TransactionRequest::from_uri(&TEST_NETWORK, &invalid_3); + let i3r = TransactionRequest::from_uri(&TEST_NETWORK, invalid_3); assert!(i3r.is_err()); // invalid; duplicate `amount=` field let invalid_4 = "zcash:?amount=1.234&amount=2.345&address=tmEZhbWHTpdKMw5it8YDspUXSMGQyFwovpU"; - let i4r = TransactionRequest::from_uri(&TEST_NETWORK, &invalid_4); + let i4r = TransactionRequest::from_uri(&TEST_NETWORK, invalid_4); assert!(i4r.is_err()); // invalid; duplicate `amount.1=` field let invalid_5 = "zcash:?amount.1=1.234&amount.1=2.345&address.1=tmEZhbWHTpdKMw5it8YDspUXSMGQyFwovpU"; - let i5r = TransactionRequest::from_uri(&TEST_NETWORK, &invalid_5); + let i5r = TransactionRequest::from_uri(&TEST_NETWORK, invalid_5); assert!(i5r.is_err()); //invalid; memo associated with t-addr let invalid_6 = "zcash:?address=tmEZhbWHTpdKMw5it8YDspUXSMGQyFwovpU&amount=123.456&memo=eyAia2V5IjogIlRoaXMgaXMgYSBKU09OLXN0cnVjdHVyZWQgbWVtby4iIH0&address.1=ztestsapling10yy2ex5dcqkclhc7z7yrnjq2z6feyjad56ptwlfgmy77dmaqqrl9gyhprdx59qgmsnyfska2kez&amount.1=0.789&memo.1=VGhpcyBpcyBhIHVuaWNvZGUgbWVtbyDinKjwn6aE8J-PhvCfjok"; - let i6r = TransactionRequest::from_uri(&TEST_NETWORK, &invalid_6); + let i6r = TransactionRequest::from_uri(&TEST_NETWORK, invalid_6); assert!(i6r.is_err()); // invalid; amount component exceeds an i64 // 9223372036854775808 = i64::MAX + 1 let invalid_7 = "zcash:ztestsapling10yy2ex5dcqkclhc7z7yrnjq2z6feyjad56ptwlfgmy77dmaqqrl9gyhprdx59qgmsnyfska2kez?amount=9223372036854775808"; - let i7r = TransactionRequest::from_uri(&TEST_NETWORK, &invalid_7); + let i7r = TransactionRequest::from_uri(&TEST_NETWORK, invalid_7); assert!(i7r.is_err()); // invalid; amount component wraps into a valid small positive i64 // 18446744073709551624 let invalid_7a = "zcash:ztestsapling10yy2ex5dcqkclhc7z7yrnjq2z6feyjad56ptwlfgmy77dmaqqrl9gyhprdx59qgmsnyfska2kez?amount=18446744073709551624"; - let i7ar = TransactionRequest::from_uri(&TEST_NETWORK, &invalid_7a); + let i7ar = TransactionRequest::from_uri(&TEST_NETWORK, invalid_7a); assert!(i7ar.is_err()); // invalid; amount component is MAX_MONEY // 21000000.00000001 let invalid_8 = "zcash:ztestsapling10yy2ex5dcqkclhc7z7yrnjq2z6feyjad56ptwlfgmy77dmaqqrl9gyhprdx59qgmsnyfska2kez?amount=21000000.00000001"; - let i8r = TransactionRequest::from_uri(&TEST_NETWORK, &invalid_8); + let i8r = TransactionRequest::from_uri(&TEST_NETWORK, invalid_8); assert!(i8r.is_err()); // invalid; negative amount let invalid_9 = "zcash:ztestsapling10yy2ex5dcqkclhc7z7yrnjq2z6feyjad56ptwlfgmy77dmaqqrl9gyhprdx59qgmsnyfska2kez?amount=-1"; - let i9r = TransactionRequest::from_uri(&TEST_NETWORK, &invalid_9); + let i9r = TransactionRequest::from_uri(&TEST_NETWORK, invalid_9); assert!(i9r.is_err()); // invalid; parameter index too large let invalid_10 = "zcash:?amount.10000=1.23&address.10000=tmEZhbWHTpdKMw5it8YDspUXSMGQyFwovpU"; - let i10r = TransactionRequest::from_uri(&TEST_NETWORK, &invalid_10); + let i10r = TransactionRequest::from_uri(&TEST_NETWORK, invalid_10); assert!(i10r.is_err()); } diff --git a/zcash_client_sqlite/src/lib.rs b/zcash_client_sqlite/src/lib.rs index 50acbac7a..bdf376b7b 100644 --- a/zcash_client_sqlite/src/lib.rs +++ b/zcash_client_sqlite/src/lib.rs @@ -212,29 +212,29 @@ impl WalletRead for WalletDb

{ fn block_height_extrema(&self) -> Result, Self::Error> { #[allow(deprecated)] - wallet::block_height_extrema(&self).map_err(SqliteClientError::from) + wallet::block_height_extrema(self).map_err(SqliteClientError::from) } fn get_block_hash(&self, block_height: BlockHeight) -> Result, Self::Error> { #[allow(deprecated)] - wallet::get_block_hash(&self, block_height).map_err(SqliteClientError::from) + wallet::get_block_hash(self, block_height).map_err(SqliteClientError::from) } fn get_tx_height(&self, txid: TxId) -> Result, Self::Error> { #[allow(deprecated)] - wallet::get_tx_height(&self, txid).map_err(SqliteClientError::from) + wallet::get_tx_height(self, txid).map_err(SqliteClientError::from) } fn get_extended_full_viewing_keys( &self, ) -> Result, Self::Error> { #[allow(deprecated)] - wallet::get_extended_full_viewing_keys(&self) + wallet::get_extended_full_viewing_keys(self) } fn get_address(&self, account: AccountId) -> Result, Self::Error> { #[allow(deprecated)] - wallet::get_address(&self, account) + wallet::get_address(self, account) } fn is_valid_account_extfvk( @@ -243,7 +243,7 @@ impl WalletRead for WalletDb

{ extfvk: &ExtendedFullViewingKey, ) -> Result { #[allow(deprecated)] - wallet::is_valid_account_extfvk(&self, account, extfvk) + wallet::is_valid_account_extfvk(self, account, extfvk) } fn get_balance_at( @@ -252,12 +252,12 @@ impl WalletRead for WalletDb

{ anchor_height: BlockHeight, ) -> Result { #[allow(deprecated)] - wallet::get_balance_at(&self, account, anchor_height) + wallet::get_balance_at(self, account, anchor_height) } fn get_transaction(&self, id_tx: i64) -> Result { #[allow(deprecated)] - wallet::get_transaction(&self, id_tx) + wallet::get_transaction(self, id_tx) } fn get_memo(&self, id_note: Self::NoteRef) -> Result { @@ -273,7 +273,7 @@ impl WalletRead for WalletDb

{ block_height: BlockHeight, ) -> Result>, Self::Error> { #[allow(deprecated)] - wallet::get_commitment_tree(&self, block_height) + wallet::get_commitment_tree(self, block_height) } #[allow(clippy::type_complexity)] @@ -282,17 +282,17 @@ impl WalletRead for WalletDb

{ block_height: BlockHeight, ) -> Result)>, Self::Error> { #[allow(deprecated)] - wallet::get_witnesses(&self, block_height) + wallet::get_witnesses(self, block_height) } fn get_nullifiers(&self) -> Result, Self::Error> { #[allow(deprecated)] - wallet::get_nullifiers(&self) + wallet::get_nullifiers(self) } fn get_all_nullifiers(&self) -> Result, Self::Error> { #[allow(deprecated)] - wallet::get_all_nullifiers(&self) + wallet::get_all_nullifiers(self) } fn get_spendable_sapling_notes( @@ -301,7 +301,7 @@ impl WalletRead for WalletDb

{ anchor_height: BlockHeight, ) -> Result, Self::Error> { #[allow(deprecated)] - wallet::transact::get_spendable_sapling_notes(&self, account, anchor_height) + wallet::transact::get_spendable_sapling_notes(self, account, anchor_height) } fn select_spendable_sapling_notes( @@ -311,12 +311,7 @@ impl WalletRead for WalletDb

{ anchor_height: BlockHeight, ) -> Result, Self::Error> { #[allow(deprecated)] - wallet::transact::select_spendable_sapling_notes( - &self, - account, - target_value, - anchor_height, - ) + wallet::transact::select_spendable_sapling_notes(self, account, target_value, anchor_height) } } @@ -327,7 +322,7 @@ impl WalletReadTransparent for WalletDb

{ address: &TransparentAddress, max_height: BlockHeight, ) -> Result, Self::Error> { - wallet::get_unspent_transparent_outputs(&self, address, max_height) + wallet::get_unspent_transparent_outputs(self, address, max_height) } } @@ -519,12 +514,12 @@ impl<'a, P: consensus::Parameters> WalletWrite for DataConnStmtCache<'a, P> { block.block_height, block.block_hash, block.block_time, - &block.commitment_tree, + block.commitment_tree, )?; let mut new_witnesses = vec![]; for tx in block.transactions { - let tx_row = wallet::put_tx_meta(up, &tx, block.block_height)?; + let tx_row = wallet::put_tx_meta(up, tx, block.block_height)?; // Mark notes as spent and remove them from the scanning cache for spend in &tx.shielded_spends { @@ -624,7 +619,7 @@ impl<'a, P: consensus::Parameters> WalletWrite for DataConnStmtCache<'a, P> { fn store_sent_tx(&mut self, sent_tx: &SentTransaction) -> Result { // Update the database atomically, to ensure the result is internally consistent. self.transactionally(|up| { - let tx_ref = wallet::put_tx_data(up, &sent_tx.tx, Some(sent_tx.created))?; + let tx_ref = wallet::put_tx_data(up, sent_tx.tx, Some(sent_tx.created))?; // Mark notes as spent. // @@ -642,7 +637,7 @@ impl<'a, P: consensus::Parameters> WalletWrite for DataConnStmtCache<'a, P> { #[cfg(feature = "transparent-inputs")] for utxo_outpoint in &sent_tx.utxos_spent { - wallet::mark_transparent_utxo_spent(up, tx_ref, &utxo_outpoint)?; + wallet::mark_transparent_utxo_spent(up, tx_ref, utxo_outpoint)?; } for output in &sent_tx.outputs { @@ -652,7 +647,7 @@ impl<'a, P: consensus::Parameters> WalletWrite for DataConnStmtCache<'a, P> { tx_ref, output.output_index, sent_tx.account, - &addr, + addr, output.value, output.memo.as_ref(), )?, @@ -661,7 +656,7 @@ impl<'a, P: consensus::Parameters> WalletWrite for DataConnStmtCache<'a, P> { tx_ref, output.output_index, sent_tx.account, - &addr, + addr, output.value, )?, } diff --git a/zcash_client_sqlite/src/wallet.rs b/zcash_client_sqlite/src/wallet.rs index 720873d7a..bae3e3777 100644 --- a/zcash_client_sqlite/src/wallet.rs +++ b/zcash_client_sqlite/src/wallet.rs @@ -564,12 +564,12 @@ pub(crate) fn rewind_to_height( .query_row("SELECT MAX(height) FROM blocks", NO_PARAMS, |row| { row.get(0) .map(|h: u32| h.into()) - .or(Ok(sapling_activation_height - 1)) + .or_else(|_| Ok(sapling_activation_height - 1)) })?; if block_height < last_scanned_height - PRUNING_HEIGHT { #[allow(deprecated)] - if let Some(h) = get_rewind_height(&wdb)? { + if let Some(h) = get_rewind_height(wdb)? { if block_height > h { return Err(SqliteClientError::RequestedRewindInvalid(h, block_height)); } @@ -920,14 +920,14 @@ pub(crate) fn mark_transparent_utxo_spent<'a, P>( outpoint: &OutPoint, ) -> Result<(), SqliteClientError> { let sql_args: &[(&str, &dyn ToSql)] = &[ - (&":spent_in_tx", &tx_ref), - (&":prevout_txid", &outpoint.hash().to_vec()), - (&":prevout_idx", &outpoint.n()), + (":spent_in_tx", &tx_ref), + (":prevout_txid", &outpoint.hash().to_vec()), + (":prevout_idx", &outpoint.n()), ]; stmts .stmt_mark_transparent_utxo_spent - .execute_named(&sql_args)?; + .execute_named(sql_args)?; Ok(()) } @@ -940,19 +940,19 @@ pub(crate) fn put_received_transparent_utxo<'a, P: consensus::Parameters>( ) -> Result { let sql_args: &[(&str, &dyn ToSql)] = &[ ( - &":address", + ":address", &output.address().encode(&stmts.wallet_db.params), ), - (&":prevout_txid", &output.outpoint.hash().to_vec()), - (&":prevout_idx", &output.outpoint.n()), - (&":script", &output.txout.script_pubkey.0), - (&":value_zat", &i64::from(output.txout.value)), - (&":height", &u32::from(output.height)), + (":prevout_txid", &output.outpoint.hash().to_vec()), + (":prevout_idx", &output.outpoint.n()), + (":script", &output.txout.script_pubkey.0), + (":value_zat", &i64::from(output.txout.value)), + (":height", &u32::from(output.height)), ]; stmts .stmt_insert_received_transparent_utxo - .execute_named(&sql_args)?; + .execute_named(sql_args)?; Ok(UtxoId(stmts.wallet_db.conn.last_insert_rowid())) } @@ -969,11 +969,11 @@ pub fn delete_utxos_above<'a, P: consensus::Parameters>( height: BlockHeight, ) -> Result { let sql_args: &[(&str, &dyn ToSql)] = &[ - (&":address", &taddr.encode(&stmts.wallet_db.params)), - (&":above_height", &u32::from(height)), + (":address", &taddr.encode(&stmts.wallet_db.params)), + (":above_height", &u32::from(height)), ]; - let rows = stmts.stmt_delete_utxos.execute_named(&sql_args)?; + let rows = stmts.stmt_delete_utxos.execute_named(sql_args)?; Ok(rows) } @@ -1004,21 +1004,21 @@ pub fn put_received_note<'a, P, T: ShieldedOutput>( let nf_bytes = output.nullifier().map(|nf| nf.0.to_vec()); let sql_args: &[(&str, &dyn ToSql)] = &[ - (&":account", &account), - (&":diversifier", &diversifier), - (&":value", &value), - (&":rcm", &rcm), - (&":nf", &nf_bytes), - (&":memo", &memo), - (&":is_change", &is_change), - (&":tx", &tx), - (&":output_index", &output_index), + (":account", &account), + (":diversifier", &diversifier), + (":value", &value), + (":rcm", &rcm), + (":nf", &nf_bytes), + (":memo", &memo), + (":is_change", &is_change), + (":tx", &tx), + (":output_index", &output_index), ]; // First try updating an existing received note into the database. - if stmts.stmt_update_received_note.execute_named(&sql_args)? == 0 { + if stmts.stmt_update_received_note.execute_named(sql_args)? == 0 { // It isn't there, so insert our note into the database. - stmts.stmt_insert_received_note.execute_named(&sql_args)?; + stmts.stmt_insert_received_note.execute_named(sql_args)?; Ok(NoteId::ReceivedNoteId( stmts.wallet_db.conn.last_insert_rowid(), @@ -1100,7 +1100,7 @@ pub fn put_sent_note<'a, P: consensus::Parameters>( // Try updating an existing sent note. if stmts.stmt_update_sent_note.execute(params![ account.0 as i64, - encode_payment_address_p(&stmts.wallet_db.params, &to), + encode_payment_address_p(&stmts.wallet_db.params, to), ivalue, &memo.map(|m| m.as_slice()), tx_ref, @@ -1109,7 +1109,7 @@ pub fn put_sent_note<'a, P: consensus::Parameters>( ])? == 0 { // It isn't there, so insert. - insert_sent_note(stmts, tx_ref, output_index, account, &to, value, memo)? + insert_sent_note(stmts, tx_ref, output_index, account, to, value, memo)? } Ok(()) @@ -1135,7 +1135,7 @@ pub fn put_sent_utxo<'a, P: consensus::Parameters>( // Try updating an existing sent UTXO. if stmts.stmt_update_sent_note.execute(params![ account.0 as i64, - encode_transparent_address_p(&stmts.wallet_db.params, &to), + encode_transparent_address_p(&stmts.wallet_db.params, to), ivalue, (None::<&[u8]>), tx_ref, @@ -1144,7 +1144,7 @@ pub fn put_sent_utxo<'a, P: consensus::Parameters>( ])? == 0 { // It isn't there, so insert. - insert_sent_utxo(stmts, tx_ref, output_index, account, &to, value)? + insert_sent_utxo(stmts, tx_ref, output_index, account, to, value)? } Ok(()) diff --git a/zcash_primitives/CHANGELOG.md b/zcash_primitives/CHANGELOG.md index 09d24988b..d421bf51f 100644 --- a/zcash_primitives/CHANGELOG.md +++ b/zcash_primitives/CHANGELOG.md @@ -97,6 +97,8 @@ and this library adheres to Rust's notion of account values. - The `zcash_primitives::zip32::AccountId`, a type-safe wrapper for ZIP 32 account indices. +- In `zcash_primitives::transaction::components::amount`: + - `impl Sum<&Amount> for Option` ### Changed - MSRV is now 1.51.0. diff --git a/zcash_primitives/src/block.rs b/zcash_primitives/src/block.rs index 5c8cc9463..1304192d6 100644 --- a/zcash_primitives/src/block.rs +++ b/zcash_primitives/src/block.rs @@ -29,7 +29,7 @@ impl BlockHash { pub fn from_slice(bytes: &[u8]) -> Self { assert_eq!(bytes.len(), 32); let mut hash = [0; 32]; - hash.copy_from_slice(&bytes); + hash.copy_from_slice(bytes); BlockHash(hash) } } diff --git a/zcash_primitives/src/extensions/transparent.rs b/zcash_primitives/src/extensions/transparent.rs index c846959ab..7ca6a3d6c 100644 --- a/zcash_primitives/src/extensions/transparent.rs +++ b/zcash_primitives/src/extensions/transparent.rs @@ -155,7 +155,7 @@ pub trait Extension { self.verify_inner( &Self::Precondition::from_payload(precondition.mode, &precondition.payload)?, &Self::Witness::from_payload(witness.mode, &witness.payload.0)?, - &context, + context, ) } } diff --git a/zcash_primitives/src/legacy/keys.rs b/zcash_primitives/src/legacy/keys.rs index 2915f10c6..86bbf68fc 100644 --- a/zcash_primitives/src/legacy/keys.rs +++ b/zcash_primitives/src/legacy/keys.rs @@ -26,7 +26,7 @@ impl AccountPrivKey { seed: &[u8], account: AccountId, ) -> Result { - ExtendedPrivKey::with_seed(&seed)? + ExtendedPrivKey::with_seed(seed)? .derive_private_key(KeyIndex::hardened_from_normalize_index(44)?)? .derive_private_key(KeyIndex::hardened_from_normalize_index(params.coin_type())?)? .derive_private_key(KeyIndex::hardened_from_normalize_index(account.0)?) diff --git a/zcash_primitives/src/merkle_tree/incremental.rs b/zcash_primitives/src/merkle_tree/incremental.rs index ae3535fef..3e3e3dc52 100644 --- a/zcash_primitives/src/merkle_tree/incremental.rs +++ b/zcash_primitives/src/merkle_tree/incremental.rs @@ -61,7 +61,7 @@ pub fn write_nonempty_frontier_v1( Optional::write(&mut writer, Some(b), |w, n| n.write(w))?; } } - Vector::write(&mut writer, &frontier.ommers(), |w, e| e.write(w))?; + Vector::write(&mut writer, frontier.ommers(), |w, e| e.write(w))?; Ok(()) } diff --git a/zcash_primitives/src/sapling/note_encryption.rs b/zcash_primitives/src/sapling/note_encryption.rs index 43831cdc3..7d5514b8d 100644 --- a/zcash_primitives/src/sapling/note_encryption.rs +++ b/zcash_primitives/src/sapling/note_encryption.rs @@ -253,7 +253,7 @@ impl Domain for SaplingDomain

{ ivk: &Self::IncomingViewingKey, plaintext: &[u8], ) -> Option<(Self::Note, Self::Recipient)> { - sapling_parse_note_plaintext_without_memo(&self, plaintext, |diversifier| { + sapling_parse_note_plaintext_without_memo(self, plaintext, |diversifier| { Some(diversifier.g_d()? * ivk.0) }) } @@ -265,7 +265,7 @@ impl Domain for SaplingDomain

{ ephemeral_key: &EphemeralKeyBytes, plaintext: &NotePlaintextBytes, ) -> Option<(Self::Note, Self::Recipient)> { - sapling_parse_note_plaintext_without_memo(&self, &plaintext.0, |diversifier| { + sapling_parse_note_plaintext_without_memo(self, &plaintext.0, |diversifier| { if (diversifier.g_d()? * esk).to_bytes() == ephemeral_key.0 { Some(*pk_d) } else { @@ -595,7 +595,7 @@ mod tests { out_ciphertext: &[u8; OUT_CIPHERTEXT_SIZE], modify_plaintext: impl Fn(&mut [u8; NOTE_PLAINTEXT_SIZE]), ) { - let ock = prf_ock(&ovk, &cv, &cmu.to_repr(), ephemeral_key); + let ock = prf_ock(ovk, cv, &cmu.to_repr(), ephemeral_key); let mut op = [0; OUT_PLAINTEXT_SIZE]; op.copy_from_slice(&out_ciphertext[..OUT_PLAINTEXT_SIZE]); diff --git a/zcash_primitives/src/sapling/pedersen_hash.rs b/zcash_primitives/src/sapling/pedersen_hash.rs index 6d92b8e3b..0e5ed26c5 100644 --- a/zcash_primitives/src/sapling/pedersen_hash.rs +++ b/zcash_primitives/src/sapling/pedersen_hash.rs @@ -87,7 +87,7 @@ where } let mut table: &[Vec] = - &generators.next().expect("we don't have enough generators"); + generators.next().expect("we don't have enough generators"); let window = PEDERSEN_HASH_EXP_WINDOW_SIZE as usize; let window_mask = (1u64 << window) - 1; diff --git a/zcash_primitives/src/sapling/prover.rs b/zcash_primitives/src/sapling/prover.rs index 1c4ae9ee1..6f6e4d889 100644 --- a/zcash_primitives/src/sapling/prover.rs +++ b/zcash_primitives/src/sapling/prover.rs @@ -106,8 +106,8 @@ pub mod mock { .commitment() .into(); - let rk = PublicKey(proof_generation_key.ak.clone().into()) - .randomize(ar, SPENDING_KEY_GENERATOR); + let rk = + PublicKey(proof_generation_key.ak.into()).randomize(ar, SPENDING_KEY_GENERATOR); Ok(([0u8; GROTH_PROOF_SIZE], cv, rk)) } diff --git a/zcash_primitives/src/sapling/redjubjub.rs b/zcash_primitives/src/sapling/redjubjub.rs index 37efd5d91..74b7b6e0d 100644 --- a/zcash_primitives/src/sapling/redjubjub.rs +++ b/zcash_primitives/src/sapling/redjubjub.rs @@ -55,6 +55,7 @@ impl Signature { } impl PrivateKey { + #[must_use] pub fn randomize(&self, alpha: jubjub::Fr) -> Self { let mut tmp = self.0; tmp.add_assign(&alpha); @@ -100,6 +101,7 @@ impl PublicKey { PublicKey((p_g * privkey.0).into()) } + #[must_use] pub fn randomize(&self, alpha: jubjub::Fr, p_g: SubgroupPoint) -> Self { PublicKey(ExtendedPoint::from(p_g * alpha) + self.0) } diff --git a/zcash_primitives/src/test_vectors/note_encryption.rs b/zcash_primitives/src/test_vectors/note_encryption.rs index 03a1b4c82..09209f29a 100644 --- a/zcash_primitives/src/test_vectors/note_encryption.rs +++ b/zcash_primitives/src/test_vectors/note_encryption.rs @@ -12,10 +12,10 @@ pub(crate) struct TestVector { pub epk: [u8; 32], pub shared_secret: [u8; 32], pub k_enc: [u8; 32], - pub p_enc: [u8; 564], + pub _p_enc: [u8; 564], pub c_enc: [u8; 580], pub ock: [u8; 32], - pub op: [u8; 64], + pub _op: [u8; 64], pub c_out: [u8; 80], } @@ -116,7 +116,7 @@ pub(crate) fn make_test_vectors() -> Vec { 0xb3, 0x3c, 0x3c, 0x32, 0x29, 0xfa, 0x0b, 0x91, 0x26, 0xf9, 0xdd, 0xdb, 0x43, 0x29, 0x66, 0x10, 0x00, 0x69, ], - p_enc: [ + _p_enc: [ 0x01, 0xf1, 0x9d, 0x9b, 0x79, 0x7e, 0x39, 0xf3, 0x37, 0x44, 0x58, 0x39, 0x00, 0xe1, 0xf5, 0x05, 0x00, 0x00, 0x00, 0x00, 0x39, 0x17, 0x6d, 0xac, 0x39, 0xac, 0xe4, 0x98, 0x0e, 0xcc, 0x8d, 0x77, 0x8e, 0x89, 0x86, 0x02, 0x55, 0xec, 0x36, 0x15, 0x06, 0x00, @@ -208,7 +208,7 @@ pub(crate) fn make_test_vectors() -> Vec { 0xca, 0x3a, 0xc6, 0x42, 0x2e, 0xc4, 0xfe, 0x21, 0xe5, 0xd1, 0x53, 0x86, 0x55, 0x8e, 0x4d, 0x37, 0x79, 0x6d, ], - op: [ + _op: [ 0xdb, 0x4c, 0xd2, 0xb0, 0xaa, 0xc4, 0xf7, 0xeb, 0x8c, 0xa1, 0x31, 0xf1, 0x65, 0x67, 0xc4, 0x45, 0xa9, 0x55, 0x51, 0x26, 0xd3, 0xc2, 0x9f, 0x14, 0xe3, 0xd7, 0x76, 0xe8, 0x41, 0xae, 0x74, 0x15, 0x81, 0xc7, 0xb2, 0x17, 0x1f, 0xf4, 0x41, 0x52, 0x50, 0xca, @@ -318,7 +318,7 @@ pub(crate) fn make_test_vectors() -> Vec { 0xa7, 0x02, 0x7a, 0x49, 0x36, 0x2a, 0xa2, 0xdd, 0x3b, 0x54, 0x36, 0xd8, 0x89, 0x75, 0xe0, 0x2a, 0xd0, 0xca, ], - p_enc: [ + _p_enc: [ 0x01, 0xae, 0xf1, 0x80, 0xf6, 0xe3, 0x4e, 0x35, 0x4b, 0x88, 0x8f, 0x81, 0x00, 0xc2, 0xeb, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x47, 0x8b, 0xa0, 0xee, 0x6e, 0x1a, 0x75, 0xb6, 0x00, 0x03, 0x6f, 0x26, 0xf1, 0x8b, 0x70, 0x15, 0xab, 0x55, 0x6b, 0xed, 0xdf, 0x8b, @@ -410,7 +410,7 @@ pub(crate) fn make_test_vectors() -> Vec { 0x4c, 0xa7, 0xe4, 0xa5, 0x82, 0x1d, 0x45, 0x5f, 0x0f, 0xa8, 0x2c, 0xd5, 0x44, 0xec, 0xb4, 0x20, 0x91, 0xfa, ], - op: [ + _op: [ 0xa6, 0xb1, 0x3e, 0xa3, 0x36, 0xdd, 0xb7, 0xa6, 0x7b, 0xb0, 0x9a, 0x0e, 0x68, 0xe9, 0xd3, 0xcf, 0xb3, 0x92, 0x10, 0x83, 0x1e, 0xa3, 0xa2, 0x96, 0xba, 0x09, 0xa9, 0x22, 0x06, 0x0f, 0xd3, 0x8b, 0xad, 0x4a, 0xd6, 0x24, 0x77, 0xc2, 0xc8, 0x83, 0xc8, 0xba, @@ -520,7 +520,7 @@ pub(crate) fn make_test_vectors() -> Vec { 0xa2, 0xd8, 0x06, 0x40, 0x53, 0x0a, 0x4c, 0xa9, 0x7b, 0x82, 0x92, 0xa5, 0xa5, 0x25, 0x0f, 0x1b, 0xf2, 0x40, ], - p_enc: [ + _p_enc: [ 0x01, 0x75, 0x99, 0xf0, 0xbf, 0x9b, 0x57, 0xcd, 0x2d, 0xc2, 0x99, 0xb6, 0x00, 0xa3, 0xe1, 0x11, 0x00, 0x00, 0x00, 0x00, 0x14, 0x7c, 0xf2, 0xb5, 0x1b, 0x4c, 0x7c, 0x63, 0xcb, 0x77, 0xb9, 0x9e, 0x8b, 0x78, 0x3e, 0x5b, 0x51, 0x11, 0xdb, 0x0a, 0x7c, 0xa0, @@ -612,7 +612,7 @@ pub(crate) fn make_test_vectors() -> Vec { 0xcf, 0x0e, 0x49, 0xc3, 0x66, 0xae, 0x72, 0xc9, 0x79, 0xc4, 0x90, 0x49, 0xc9, 0x4b, 0xd3, 0xc7, 0x5c, 0xf4, ], - op: [ + _op: [ 0x66, 0x14, 0x17, 0x39, 0x51, 0x4b, 0x28, 0xf0, 0x5d, 0xef, 0x8a, 0x18, 0xee, 0xee, 0x5e, 0xed, 0x4d, 0x44, 0xc6, 0x22, 0x5c, 0x3c, 0x65, 0xd8, 0x8d, 0xd9, 0x90, 0x77, 0x08, 0x01, 0x2f, 0x5a, 0x99, 0xaa, 0x10, 0xc0, 0x57, 0x88, 0x08, 0x1c, 0x0d, 0xa7, @@ -722,7 +722,7 @@ pub(crate) fn make_test_vectors() -> Vec { 0x33, 0x0c, 0xf9, 0xc8, 0x2b, 0x1e, 0xb1, 0xfe, 0xe6, 0xa1, 0xa5, 0x54, 0x4a, 0x82, 0xc7, 0xb3, 0x16, 0x82, ], - p_enc: [ + _p_enc: [ 0x01, 0x1b, 0x81, 0x61, 0x4f, 0x1d, 0xad, 0xea, 0x0f, 0x8d, 0x0a, 0x58, 0x00, 0x84, 0xd7, 0x17, 0x00, 0x00, 0x00, 0x00, 0x34, 0xa4, 0xb2, 0xa9, 0x14, 0x4f, 0xf5, 0xea, 0x54, 0xef, 0xee, 0x87, 0xcf, 0x90, 0x1b, 0x5b, 0xed, 0x5e, 0x35, 0xd2, 0x1f, 0xbb, @@ -814,7 +814,7 @@ pub(crate) fn make_test_vectors() -> Vec { 0xf1, 0x98, 0x4c, 0x9a, 0x8b, 0x98, 0xe0, 0x6e, 0xe5, 0xd8, 0x36, 0xce, 0x0e, 0x6c, 0x89, 0xab, 0x56, 0xfd, ], - op: [ + _op: [ 0x25, 0xeb, 0x55, 0xfc, 0xcf, 0x76, 0x1f, 0xc6, 0x4e, 0x85, 0xa5, 0x88, 0xef, 0xe6, 0xea, 0xd7, 0x83, 0x2f, 0xb1, 0xf0, 0xf7, 0xa8, 0x31, 0x65, 0x89, 0x5b, 0xdf, 0xf9, 0x42, 0x92, 0x5f, 0x5c, 0xbd, 0xde, 0x13, 0x81, 0xec, 0x9f, 0xf4, 0x21, 0xca, 0xfd, @@ -924,7 +924,7 @@ pub(crate) fn make_test_vectors() -> Vec { 0x7f, 0x26, 0x1f, 0xbb, 0x2d, 0xfa, 0xd8, 0x88, 0x66, 0xb4, 0x32, 0xff, 0x0d, 0xfa, 0xee, 0xc5, 0xb2, 0xcf, ], - p_enc: [ + _p_enc: [ 0x01, 0xfc, 0xfb, 0x68, 0xa4, 0x0d, 0x4b, 0xc6, 0xa0, 0x4b, 0x09, 0xc4, 0x00, 0x65, 0xcd, 0x1d, 0x00, 0x00, 0x00, 0x00, 0xe5, 0x57, 0x85, 0x13, 0x55, 0x74, 0x7c, 0x09, 0xac, 0x59, 0x01, 0x3c, 0xbd, 0xe8, 0x59, 0x80, 0x96, 0x4e, 0xc1, 0x84, 0x4d, 0x9c, @@ -1016,7 +1016,7 @@ pub(crate) fn make_test_vectors() -> Vec { 0x3a, 0x4d, 0xb2, 0x81, 0x86, 0x37, 0x86, 0x88, 0xbe, 0xc6, 0x19, 0x56, 0x23, 0x2e, 0x42, 0xb7, 0x0a, 0xba, ], - op: [ + _op: [ 0x8b, 0x2a, 0x33, 0x7f, 0x03, 0x62, 0x2c, 0x24, 0xff, 0x38, 0x1d, 0x4c, 0x54, 0x6f, 0x69, 0x77, 0xf9, 0x05, 0x22, 0xe9, 0x2f, 0xde, 0x44, 0xc9, 0xd1, 0xbb, 0x09, 0x97, 0x14, 0xb9, 0xdb, 0x2b, 0x3d, 0xc1, 0x66, 0xd5, 0x6a, 0x1d, 0x62, 0xf5, 0xa8, 0xd7, @@ -1126,7 +1126,7 @@ pub(crate) fn make_test_vectors() -> Vec { 0x7c, 0xd0, 0x0c, 0xe0, 0xdc, 0x4b, 0x4d, 0x00, 0xcc, 0x8d, 0x8d, 0x3b, 0xa2, 0xce, 0x6e, 0xa9, 0xc2, 0x97, ], - p_enc: [ + _p_enc: [ 0x01, 0xeb, 0x51, 0x98, 0x82, 0xad, 0x1e, 0x5c, 0xc6, 0x54, 0xcd, 0x59, 0x00, 0x46, 0xc3, 0x23, 0x00, 0x00, 0x00, 0x00, 0x68, 0xf0, 0x61, 0x04, 0x60, 0x6b, 0x0c, 0x54, 0x49, 0x84, 0x5f, 0xf4, 0xc6, 0x5f, 0x73, 0xe9, 0x0f, 0x45, 0xef, 0x5a, 0x43, 0xc9, @@ -1218,7 +1218,7 @@ pub(crate) fn make_test_vectors() -> Vec { 0x5a, 0x11, 0x75, 0x86, 0xae, 0x8a, 0xdd, 0x64, 0x99, 0x7d, 0x02, 0xec, 0xb8, 0xb5, 0xcb, 0xac, 0x14, 0x87, ], - op: [ + _op: [ 0x6b, 0x27, 0xda, 0xcc, 0xb5, 0xa8, 0x20, 0x7f, 0x53, 0x2d, 0x10, 0xca, 0x23, 0x8f, 0x97, 0x86, 0x64, 0x8a, 0x11, 0xb5, 0x96, 0x6e, 0x51, 0xa2, 0xf7, 0xd8, 0x9e, 0x15, 0xd2, 0x9b, 0x8f, 0xdf, 0x4e, 0x41, 0x8c, 0x3c, 0x54, 0x3d, 0x6b, 0xf0, 0x15, 0x31, @@ -1328,7 +1328,7 @@ pub(crate) fn make_test_vectors() -> Vec { 0xba, 0x54, 0x76, 0x19, 0x8e, 0x29, 0x1d, 0xf7, 0x57, 0x8c, 0x2b, 0xef, 0x87, 0xe6, 0x4a, 0x71, 0x6a, 0xe7, ], - p_enc: [ + _p_enc: [ 0x01, 0xbe, 0xbb, 0x0f, 0xb4, 0x6b, 0x8a, 0xaf, 0xf8, 0x90, 0x40, 0xf6, 0x00, 0x27, 0xb9, 0x29, 0x00, 0x00, 0x00, 0x00, 0x49, 0xf9, 0x0b, 0x47, 0xfd, 0x52, 0xfe, 0xe7, 0xc1, 0xc8, 0x1f, 0x0d, 0xcb, 0x5b, 0x74, 0xc3, 0xfb, 0x9b, 0x3e, 0x03, 0x97, 0x6f, @@ -1420,7 +1420,7 @@ pub(crate) fn make_test_vectors() -> Vec { 0x14, 0x92, 0xd1, 0x8d, 0x5c, 0x85, 0x3c, 0x8f, 0x2f, 0x0c, 0xd5, 0xd1, 0x9d, 0x6d, 0x34, 0xcf, 0x7c, 0x2d, ], - op: [ + _op: [ 0xd1, 0x1d, 0xa0, 0x1f, 0x0b, 0x43, 0xbd, 0xd5, 0x28, 0x8d, 0x32, 0x38, 0x5b, 0x87, 0x71, 0xd2, 0x23, 0x49, 0x3c, 0x69, 0x80, 0x25, 0x44, 0x04, 0x3f, 0x77, 0xcf, 0x1d, 0x71, 0xc1, 0xcb, 0x8c, 0x6d, 0xa9, 0x45, 0xd3, 0x03, 0x81, 0xc2, 0xee, 0xd2, 0xb8, @@ -1530,7 +1530,7 @@ pub(crate) fn make_test_vectors() -> Vec { 0x39, 0x97, 0x42, 0xa9, 0x29, 0xbb, 0x23, 0x10, 0x0a, 0x7c, 0x51, 0xed, 0x32, 0xf9, 0xcb, 0x45, 0x96, 0xc6, ], - p_enc: [ + _p_enc: [ 0x01, 0xad, 0x6e, 0x2e, 0x18, 0x5a, 0x31, 0x00, 0xe3, 0xa6, 0xa8, 0xb3, 0x00, 0x08, 0xaf, 0x2f, 0x00, 0x00, 0x00, 0x00, 0x51, 0x65, 0xaf, 0xf2, 0x2d, 0xd4, 0xed, 0x56, 0xb4, 0xd8, 0x1d, 0x1f, 0x17, 0x1c, 0xc3, 0xd6, 0x43, 0x2f, 0xed, 0x1b, 0xeb, 0xf2, @@ -1622,7 +1622,7 @@ pub(crate) fn make_test_vectors() -> Vec { 0x83, 0xa9, 0x27, 0x7c, 0x61, 0x82, 0xa8, 0x08, 0xcc, 0x53, 0xa1, 0xbe, 0xdd, 0xd2, 0x03, 0x68, 0xb1, 0x0a, ], - op: [ + _op: [ 0x32, 0xcb, 0x28, 0x06, 0xb8, 0x82, 0xf1, 0x36, 0x8b, 0x0d, 0x4a, 0x89, 0x8f, 0x72, 0xc4, 0xc8, 0xf7, 0x28, 0x13, 0x2c, 0xc1, 0x24, 0x56, 0x94, 0x6e, 0x7f, 0x4c, 0xb0, 0xfb, 0x05, 0x8d, 0xa9, 0xab, 0x2a, 0xff, 0x03, 0x32, 0xd5, 0x43, 0xfd, 0x1d, 0x80, @@ -1732,7 +1732,7 @@ pub(crate) fn make_test_vectors() -> Vec { 0xa6, 0xb9, 0xca, 0xbe, 0xfd, 0xba, 0x9e, 0x7a, 0x74, 0xf5, 0xba, 0x2f, 0x81, 0xb8, 0x71, 0x40, 0x1f, 0x08, ], - p_enc: [ + _p_enc: [ 0x01, 0x21, 0xc9, 0x0e, 0x1c, 0x65, 0x8b, 0x3e, 0xfe, 0x86, 0xaf, 0x58, 0x00, 0xe9, 0xa4, 0x35, 0x00, 0x00, 0x00, 0x00, 0x8c, 0x3e, 0x56, 0x44, 0x9d, 0xc8, 0x63, 0x54, 0xd3, 0x3b, 0x02, 0x5e, 0xf2, 0x79, 0x34, 0x60, 0xbc, 0xb1, 0x69, 0xf3, 0x32, 0x4e, @@ -1824,7 +1824,7 @@ pub(crate) fn make_test_vectors() -> Vec { 0xa5, 0xf3, 0x58, 0x05, 0xba, 0x78, 0x5a, 0x2c, 0x92, 0xa9, 0xaa, 0x62, 0x32, 0xb0, 0x55, 0x1c, 0xf3, 0xf4, ], - op: [ + _op: [ 0x9e, 0x64, 0x17, 0x4b, 0x4a, 0xb9, 0x81, 0x40, 0x5c, 0x32, 0x3b, 0x5e, 0x12, 0x47, 0x59, 0x45, 0xa4, 0x6d, 0x4f, 0xed, 0xf8, 0x06, 0x08, 0x28, 0x04, 0x1c, 0xd2, 0x0e, 0x62, 0xfd, 0x2c, 0xef, 0xa5, 0x3d, 0x19, 0xf5, 0x69, 0x45, 0x95, 0xd5, 0xae, 0x63, @@ -1934,7 +1934,7 @@ pub(crate) fn make_test_vectors() -> Vec { 0xc9, 0xc9, 0x60, 0xad, 0x7c, 0xcc, 0x59, 0x77, 0x43, 0x74, 0x4c, 0x18, 0xc9, 0xc2, 0xa5, 0x62, 0xf6, 0x3a, ], - p_enc: [ + _p_enc: [ 0x01, 0x23, 0x3c, 0x4a, 0xb8, 0x86, 0xa5, 0x5e, 0x3b, 0xa3, 0x74, 0xc0, 0x00, 0xca, 0x9a, 0x3b, 0x00, 0x00, 0x00, 0x00, 0x6e, 0xbb, 0xed, 0x74, 0x36, 0x19, 0xa2, 0x56, 0xf9, 0xad, 0x2e, 0x85, 0x88, 0x0c, 0xfa, 0xa9, 0x09, 0x8a, 0x5f, 0xdb, 0x16, 0x29, @@ -2026,7 +2026,7 @@ pub(crate) fn make_test_vectors() -> Vec { 0x8c, 0xca, 0x55, 0x71, 0xee, 0xcc, 0x69, 0xb7, 0x22, 0xa0, 0xa3, 0xb8, 0x67, 0x50, 0x72, 0x92, 0x99, 0xa0, ], - op: [ + _op: [ 0xb6, 0x8e, 0x9e, 0xe0, 0xc0, 0x67, 0x8d, 0x7b, 0x30, 0x36, 0x93, 0x1c, 0x83, 0x1a, 0x25, 0x25, 0x5f, 0x7e, 0xe4, 0x87, 0x38, 0x5a, 0x30, 0x31, 0x6e, 0x15, 0xf6, 0x48, 0x2b, 0x87, 0x4f, 0xda, 0x29, 0x95, 0x89, 0x80, 0x69, 0x4f, 0x7f, 0x67, 0x08, 0x09, diff --git a/zcash_primitives/src/transaction/builder.rs b/zcash_primitives/src/transaction/builder.rs index f402cd33a..5c8536681 100644 --- a/zcash_primitives/src/transaction/builder.rs +++ b/zcash_primitives/src/transaction/builder.rs @@ -1,6 +1,5 @@ //! Structs for building transactions. -use std::array; use std::error; use std::fmt; use std::sync::mpsc::Sender; @@ -267,7 +266,7 @@ impl<'a, P: consensus::Parameters, R: RngCore> Builder<'a, P, R> { .ok_or(Error::InvalidAmount)?, ]; - array::IntoIter::new(value_balances) + IntoIterator::into_iter(&value_balances) .sum::>() .ok_or(Error::InvalidAmount) } diff --git a/zcash_primitives/src/transaction/components/amount.rs b/zcash_primitives/src/transaction/components/amount.rs index 7d86f9121..5d4edd8a1 100644 --- a/zcash_primitives/src/transaction/components/amount.rs +++ b/zcash_primitives/src/transaction/components/amount.rs @@ -200,6 +200,12 @@ impl Sum for Option { } } +impl<'a> Sum<&'a Amount> for Option { + fn sum>(iter: I) -> Self { + iter.fold(Some(Amount::zero()), |acc, a| acc? + *a) + } +} + impl Neg for Amount { type Output = Self; diff --git a/zcash_primitives/src/transaction/components/orchard.rs b/zcash_primitives/src/transaction/components/orchard.rs index 0ee878854..a65c7c65d 100644 --- a/zcash_primitives/src/transaction/components/orchard.rs +++ b/zcash_primitives/src/transaction/components/orchard.rs @@ -236,11 +236,11 @@ pub fn write_action_without_auth( mut writer: W, act: &Action<::SpendAuth>, ) -> io::Result<()> { - write_value_commitment(&mut writer, &act.cv_net())?; - write_nullifier(&mut writer, &act.nullifier())?; - write_verification_key(&mut writer, &act.rk())?; - write_cmx(&mut writer, &act.cmx())?; - write_note_ciphertext(&mut writer, &act.encrypted_note())?; + write_value_commitment(&mut writer, act.cv_net())?; + write_nullifier(&mut writer, act.nullifier())?; + write_verification_key(&mut writer, act.rk())?; + write_cmx(&mut writer, act.cmx())?; + write_note_ciphertext(&mut writer, act.encrypted_note())?; Ok(()) } diff --git a/zcash_primitives/src/transaction/components/sprout.rs b/zcash_primitives/src/transaction/components/sprout.rs index b1f3215a5..bba45fe1b 100644 --- a/zcash_primitives/src/transaction/components/sprout.rs +++ b/zcash_primitives/src/transaction/components/sprout.rs @@ -18,9 +18,9 @@ pub struct Bundle { } #[derive(Clone)] +#[allow(clippy::upper_case_acronyms)] pub(crate) enum SproutProof { Groth([u8; GROTH_PROOF_SIZE]), - #[allow(clippy::upper_case_acronyms)] PHGR([u8; PHGR_PROOF_SIZE]), } diff --git a/zcash_primitives/src/transaction/components/transparent/builder.rs b/zcash_primitives/src/transaction/components/transparent/builder.rs index b62b3f9fb..eba02c2ab 100644 --- a/zcash_primitives/src/transaction/components/transparent/builder.rs +++ b/zcash_primitives/src/transaction/components/transparent/builder.rs @@ -3,7 +3,7 @@ use std::fmt; use crate::{ - legacy::TransparentAddress, + legacy::{Script, TransparentAddress}, transaction::components::{ amount::Amount, transparent::{self, Authorization, Authorized, Bundle, TxIn, TxOut}, @@ -12,14 +12,11 @@ use crate::{ #[cfg(feature = "transparent-inputs")] use { - crate::{ - legacy::Script, - transaction::{ - self as tx, - components::OutPoint, - sighash::{signature_hash, SignableInput, SIGHASH_ALL}, - TransactionData, TxDigests, - }, + crate::transaction::{ + self as tx, + components::OutPoint, + sighash::{signature_hash, SignableInput, SIGHASH_ALL}, + TransactionData, TxDigests, }, blake2b_simd::Hash as Blake2bHash, ripemd::Digest, @@ -196,7 +193,7 @@ impl Bundle { #[cfg(feature = "transparent-inputs")] txid_parts_cache: &TxDigests, ) -> Bundle { #[cfg(feature = "transparent-inputs")] - let script_sigs: Vec