What changed, and why it matters
This commit is a routine cleanup of Rust compiler warnings (Clippy lints). It removes unused imports, rewrites idiomatically cleaner code, fixes variable naming, and updates a few function signatures. There is no indication it fixes a security vulnerability or changes security-critical behavior.
No security action required. Treat as normal maintenance; review the Monero and Bitcoin FFI signature changes in the usual regression/functional testing cycle if desired.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit is titled ‘chore: fix clippy build error’ and touches 91 files, almost entirely removing unused imports, replacing manual match/map_or patterns with idiomatic if let/is_ok_and/first(), renaming variables to snake_case, and applying modern Rust formatting. The only functional-looking changes are in rust/apps/monero/src/transfer.rs and transfer_key.rs where transaction key parameters are threaded through helper functions instead of being recomputed internally, and in rust/rust_c/src/bitcoin/psbt.rs where btc_check_psbt_bytes changes its FFI signature from taking a PtrUR to taking raw psbt_bytes/length. These appear to be refactorings to satisfy Clippy and do not, on their own, constitute security fixes. No vendor security disclosure, CVE, or researcher attribution is present.
Changed components
rust/apps/arweaverust/apps/avalancherust/apps/bitcoinrust/apps/cardanorust/apps/ethereumrust/apps/iotarust/apps/monerorust/apps/nearrust/apps/solanarust/apps/stellarrust/apps/suirust/apps/tonrust/apps/tronrust/apps/walletsrust/apps/xrprust/apps/zcashrust/keystorerust/rust_crust/sim_qr_readerrust/zcash_vendorsrc/managers/keystore.csrc/ui/gui_chain/gui_btc.csrc/ui/gui_chain/multi/web3/gui_iota.csrc/ui/gui_model/gui_model.cInspect captured patch +387 / −499
diff --git a/rust/apps/arweave/src/ao_transaction.rs b/rust/apps/arweave/src/ao_transaction.rs
index 2eeced6..50773ff 100644
--- a/rust/apps/arweave/src/ao_transaction.rs
+++ b/rust/apps/arweave/src/ao_transaction.rs
@@ -43,7 +43,7 @@ impl TryFrom<DataItem> for AOTransferTransaction {
let quantity = quantity.get_value();
let mut tags = vec![];
- while let Some(tag) = rest_tags.next() {
+ for tag in rest_tags {
tags.push(tag.clone());
}
diff --git a/rust/apps/avalanche/src/address.rs b/rust/apps/avalanche/src/address.rs
index 571a077..7dfffa2 100644
--- a/rust/apps/avalanche/src/address.rs
+++ b/rust/apps/avalanche/src/address.rs
@@ -2,7 +2,7 @@ use crate::constants::*;
use crate::errors::{AvaxError, Result};
#[cfg(feature = "testnet")]
use crate::network::TESTNET_ID;
-use crate::network::{Network, MAINNET_ID};
+use crate::network::Network;
use crate::ripple_keypair::hash160;
use crate::transactions::structs::ParsedSizeAble;
use alloc::string::{String, ToString};
@@ -48,7 +48,7 @@ pub fn get_address(
root_x_pub: &str,
root_path: &str,
) -> Result<String> {
- let mut prefix = "avax";
+ let prefix = "avax";
match network {
Network::AvaxMainNet => {}
#[cfg(feature = "testnet")]
diff --git a/rust/apps/avalanche/src/errors.rs b/rust/apps/avalanche/src/errors.rs
index 4fc79d6..848f2fd 100644
--- a/rust/apps/avalanche/src/errors.rs
+++ b/rust/apps/avalanche/src/errors.rs
@@ -1,5 +1,4 @@
use alloc::string::{String, ToString};
-use bitcoin::address::error;
use core2::io;
use keystore::errors::KeystoreError;
use thiserror;
diff --git a/rust/apps/avalanche/src/ripple_keypair.rs b/rust/apps/avalanche/src/ripple_keypair.rs
index 4059674..614b86c 100644
--- a/rust/apps/avalanche/src/ripple_keypair.rs
+++ b/rust/apps/avalanche/src/ripple_keypair.rs
@@ -1,4 +1,3 @@
-use alloc::string::String;
use alloc::vec::Vec;
use cryptoxide::digest::Digest;
use cryptoxide::hashing;
diff --git a/rust/apps/avalanche/src/transactions/C_chain/evm_import.rs b/rust/apps/avalanche/src/transactions/C_chain/evm_import.rs
index 269dd95..2cf90e1 100644
--- a/rust/apps/avalanche/src/transactions/C_chain/evm_import.rs
+++ b/rust/apps/avalanche/src/transactions/C_chain/evm_import.rs
@@ -9,7 +9,6 @@ use crate::transactions::tx_header::Header;
use crate::transactions::{asset_id::AssetId, type_id::TypeId};
use alloc::{
- format,
string::{String, ToString},
vec::Vec,
};
diff --git a/rust/apps/avalanche/src/transactions/P_chain/add_permissionless_delegator.rs b/rust/apps/avalanche/src/transactions/P_chain/add_permissionless_delegator.rs
index 4629950..f267d3c 100644
--- a/rust/apps/avalanche/src/transactions/P_chain/add_permissionless_delegator.rs
+++ b/rust/apps/avalanche/src/transactions/P_chain/add_permissionless_delegator.rs
@@ -5,11 +5,9 @@ use crate::transactions::base_tx::BaseTx;
use crate::transactions::structs::{
AvaxFromToInfo, AvaxMethodInfo, AvaxTxInfo, LengthPrefixedVec, ParsedSizeAble,
};
-use crate::transactions::subnet_auth::SubnetAuth;
use crate::transactions::subnet_id::SubnetId;
use crate::transactions::transferable::TransferableOutput;
use alloc::{
- format,
string::{String, ToString},
vec::Vec,
};
diff --git a/rust/apps/avalanche/src/transactions/P_chain/add_permissionless_validator.rs b/rust/apps/avalanche/src/transactions/P_chain/add_permissionless_validator.rs
index 3882616..dbdc65f 100644
--- a/rust/apps/avalanche/src/transactions/P_chain/add_permissionless_validator.rs
+++ b/rust/apps/avalanche/src/transactions/P_chain/add_permissionless_validator.rs
@@ -10,7 +10,6 @@ use crate::transactions::structs::{
use crate::transactions::subnet_id::SubnetId;
use crate::transactions::transferable::TransferableOutput;
use alloc::{
- format,
string::{String, ToString},
vec::Vec,
};
diff --git a/rust/apps/avalanche/src/transactions/P_chain/signer.rs b/rust/apps/avalanche/src/transactions/P_chain/signer.rs
index 62d5a29..10eba67 100644
--- a/rust/apps/avalanche/src/transactions/P_chain/signer.rs
+++ b/rust/apps/avalanche/src/transactions/P_chain/signer.rs
@@ -1,6 +1,5 @@
use crate::constants::*;
use crate::errors::{AvaxError, Result};
-use alloc::string::ToString;
use bytes::{Buf, Bytes};
use core::convert::TryFrom;
diff --git a/rust/apps/avalanche/src/transactions/P_chain/validator.rs b/rust/apps/avalanche/src/transactions/P_chain/validator.rs
index 5fd9889..ce0313b 100644
--- a/rust/apps/avalanche/src/transactions/P_chain/validator.rs
+++ b/rust/apps/avalanche/src/transactions/P_chain/validator.rs
@@ -1,13 +1,6 @@
-use super::node_id::{self, NodeId};
+use super::node_id::NodeId;
use crate::constants::*;
-use crate::encode::cb58::Cb58Encodable;
use crate::errors::{AvaxError, Result};
-use crate::transactions::base_tx::BaseTx;
-use alloc::{
- format,
- string::{String, ToString},
- vec::Vec,
-};
use bytes::{Buf, Bytes};
use core::convert::TryFrom;
diff --git a/rust/apps/avalanche/src/transactions/inputs/secp256k1_transfer_input.rs b/rust/apps/avalanche/src/transactions/inputs/secp256k1_transfer_input.rs
index 9e55bd6..e86d960 100644
--- a/rust/apps/avalanche/src/transactions/inputs/secp256k1_transfer_input.rs
+++ b/rust/apps/avalanche/src/transactions/inputs/secp256k1_transfer_input.rs
@@ -2,8 +2,8 @@ use crate::errors::{AvaxError, Result};
use crate::transactions::transferable::InputTrait;
use alloc::string::ToString;
use alloc::vec::Vec;
-use bytes::{Buf, BufMut, Bytes, BytesMut};
-use core::{convert::TryFrom, fmt, str::FromStr};
+use bytes::{Buf, Bytes};
+use core::convert::TryFrom;
#[derive(Debug, Clone)]
pub struct SECP256K1TransferInput {
diff --git a/rust/apps/avalanche/src/transactions/outputs/secp256k1_transfer_output.rs b/rust/apps/avalanche/src/transactions/outputs/secp256k1_transfer_output.rs
index 896024c..1d410a7 100644
--- a/rust/apps/avalanche/src/transactions/outputs/secp256k1_transfer_output.rs
+++ b/rust/apps/avalanche/src/transactions/outputs/secp256k1_transfer_output.rs
@@ -4,8 +4,8 @@ use crate::transactions::structs::{LengthPrefixedVec, ParsedSizeAble};
use crate::transactions::transferable::OutputTrait;
use alloc::string::{String, ToString};
use alloc::vec::Vec;
-use bytes::{Buf, BufMut, Bytes, BytesMut};
-use core::{convert::TryFrom, fmt, str::FromStr};
+use bytes::{Buf, Bytes};
+use core::convert::TryFrom;
#[derive(Debug, Clone)]
pub struct SECP256K1TransferOutput {
diff --git a/rust/apps/avalanche/src/transactions/structs.rs b/rust/apps/avalanche/src/transactions/structs.rs
index 8ac0a5d..c52301b 100644
--- a/rust/apps/avalanche/src/transactions/structs.rs
+++ b/rust/apps/avalanche/src/transactions/structs.rs
@@ -1,6 +1,4 @@
-use crate::constants::NAVAX_TO_AVAX_RATIO;
use crate::errors::{AvaxError, Result};
-use crate::get_address;
use crate::transactions::type_id::TypeId;
use alloc::{
string::{String, ToString},
diff --git a/rust/apps/avalanche/src/transactions/subnet_auth.rs b/rust/apps/avalanche/src/transactions/subnet_auth.rs
index 883af8c..b097bc2 100644
--- a/rust/apps/avalanche/src/transactions/subnet_auth.rs
+++ b/rust/apps/avalanche/src/transactions/subnet_auth.rs
@@ -1,6 +1,5 @@
use crate::constants::*;
use crate::errors::{AvaxError, Result};
-use alloc::string::ToString;
use bytes::{Buf, Bytes};
use core::convert::TryFrom;
diff --git a/rust/apps/avalanche/src/transactions/subnet_id.rs b/rust/apps/avalanche/src/transactions/subnet_id.rs
index f5a4768..dd5c6e5 100644
--- a/rust/apps/avalanche/src/transactions/subnet_id.rs
+++ b/rust/apps/avalanche/src/transactions/subnet_id.rs
@@ -1,6 +1,5 @@
use crate::constants::*;
use crate::errors::{AvaxError, Result};
-use alloc::string::ToString;
use bytes::{Buf, Bytes};
use core::convert::TryFrom;
diff --git a/rust/apps/avalanche/src/transactions/transferable.rs b/rust/apps/avalanche/src/transactions/transferable.rs
index 5280085..02ef0f4 100644
--- a/rust/apps/avalanche/src/transactions/transferable.rs
+++ b/rust/apps/avalanche/src/transactions/transferable.rs
@@ -11,7 +11,7 @@ use alloc::{
vec::Vec,
};
use bytes::{Buf, Bytes};
-use core::{convert::TryFrom, fmt};
+use core::convert::TryFrom;
pub const TX_ID_LEN: usize = 32;
pub type TxId = [u8; TX_ID_LEN];
@@ -169,7 +169,7 @@ enum InputType {
impl TryFrom<Bytes> for InputType {
type Error = AvaxError;
- fn try_from(mut bytes: Bytes) -> Result<Self> {
+ fn try_from(bytes: Bytes) -> Result<Self> {
let mut type_bytes = bytes.clone();
let type_id = type_bytes.get_u32();
match TypeId::try_from(type_id)? {
diff --git a/rust/apps/bitcoin/src/addresses/cashaddr.rs b/rust/apps/bitcoin/src/addresses/cashaddr.rs
index 98f52c9..715bddb 100644
--- a/rust/apps/bitcoin/src/addresses/cashaddr.rs
+++ b/rust/apps/bitcoin/src/addresses/cashaddr.rs
@@ -349,7 +349,7 @@ impl CashAddrCodec {
#[cfg(test)]
mod tests {
use super::*;
- use bitcoin::ScriptBuf;
+
use hex::ToHex;
#[test]
diff --git a/rust/apps/bitcoin/src/addresses/encoding.rs b/rust/apps/bitcoin/src/addresses/encoding.rs
index fb24606..bb3a033 100644
--- a/rust/apps/bitcoin/src/addresses/encoding.rs
+++ b/rust/apps/bitcoin/src/addresses/encoding.rs
@@ -36,6 +36,7 @@ pub struct DOGEAddressEncoding<'a> {
pub p2sh_prefix: u8,
}
+#[allow(unused)]
struct UpperWriter<W: fmt::Write>(W);
impl<W: fmt::Write> fmt::Write for UpperWriter<W> {
diff --git a/rust/apps/bitcoin/src/lib.rs b/rust/apps/bitcoin/src/lib.rs
index 1a885aa..d8f77a3 100644
--- a/rust/apps/bitcoin/src/lib.rs
+++ b/rust/apps/bitcoin/src/lib.rs
@@ -123,13 +123,13 @@ pub fn check_raw_tx(raw_tx: protoc::Payload, context: keystone::ParseContext) ->
}
fn deserialize_psbt(psbt_hex: Vec<u8>) -> Result<Psbt> {
- Psbt::deserialize(&psbt_hex).map_err(|e| BitcoinError::InvalidPsbt(format!("{}", e)))
+ Psbt::deserialize(&psbt_hex).map_err(|e| BitcoinError::InvalidPsbt(e.to_string()))
}
#[cfg(test)]
mod test {
use alloc::vec::Vec;
- use core::fmt::Error;
+
use core::str::FromStr;
use app_utils::keystone;
diff --git a/rust/apps/bitcoin/src/multi_sig/wallet.rs b/rust/apps/bitcoin/src/multi_sig/wallet.rs
index 9fe724a..abab2c8 100644
--- a/rust/apps/bitcoin/src/multi_sig/wallet.rs
+++ b/rust/apps/bitcoin/src/multi_sig/wallet.rs
@@ -570,16 +570,16 @@ pub fn strict_verify_wallet_config(
#[cfg(test)]
mod tests {
- use core::result;
+
use alloc::string::ToString;
use crate::multi_sig::wallet::{
- create_wallet, export_wallet_by_ur, generate_config_data, is_valid_xyzpub,
+ create_wallet, generate_config_data, is_valid_xyzpub,
parse_bsms_wallet_config, parse_wallet_config, strict_verify_wallet_config,
};
use crate::multi_sig::{MultiSigXPubInfo, Network};
- use alloc::vec::Vec;
+
use hex;
use ur_registry::bytes::Bytes;
diff --git a/rust/apps/bitcoin/src/transactions/legacy/mod.rs b/rust/apps/bitcoin/src/transactions/legacy/mod.rs
index 89090a8..2349ca5 100644
--- a/rust/apps/bitcoin/src/transactions/legacy/mod.rs
+++ b/rust/apps/bitcoin/src/transactions/legacy/mod.rs
@@ -65,16 +65,16 @@ mod tests {
// check without change address
let payload = prepare_payload(hex);
let context = prepare_parse_context(pubkey_str);
- let check = check_raw_tx(payload, context).unwrap();
- assert_eq!((), check);
+ let check = check_raw_tx(payload, context);
+ assert!(check.is_ok());
}
{
// check with change address
let hex = "1f8b0800000000000003558fbd4a0341144649b458b64948155285458808cbcecfbd7766ac2491086a82011bed66efcc54e24262d0c7b0b448656369ef43f80cfa02f6766e2b7cd5c739c5c9ba83de6a3d6b421c5fad9b87869bbbd15bb77d33a3198317be78e9e67b97d7b3c101b303aaa32a6d042e41d5b1f45ac912c9a3f696134a1abfff7c7dfc8ac3acfeee649fc3feeb7eb1ebe427081eadb1cc48d618762c153a8989d032266d74140a58308b284400a3586bcfb527d44669994667f954a816f144e46c100c96d05b23add7412393a32441440812594182e0406244e742ad83694b9276c3e765d15b54e026959a54a25da58e8ef36271b170b4e1c7ed26f8a58590ead57a7efad4f0cdfcbe996e196efbbbf361e7bf2b2bf107321aa6643d010000";
let payload = prepare_payload(hex);
let context = prepare_parse_context(pubkey_str);
- let check = check_raw_tx(payload, context).unwrap();
- assert_eq!((), check);
+ let check = check_raw_tx(payload, context);
+ assert!(check.is_ok());
}
}
@@ -86,8 +86,8 @@ mod tests {
let extended_pubkey = bitcoin::bip32::Xpub::from_str(extended_pubkey_str).unwrap();
let context = keystone::ParseContext::new(master_fingerprint, extended_pubkey);
let payload = prepare_payload(hex);
- let check = check_raw_tx(payload, context.clone()).unwrap();
- assert_eq!((), check);
+ let check = check_raw_tx(payload, context.clone());
+ assert!(check.is_ok());
}
#[test]
@@ -98,8 +98,8 @@ mod tests {
let extended_pubkey = bitcoin::bip32::Xpub::from_str(extended_pubkey_str).unwrap();
let context = keystone::ParseContext::new(master_fingerprint, extended_pubkey);
let payload = prepare_payload(hex);
- let check = check_raw_tx(payload, context.clone()).unwrap();
- assert_eq!((), check);
+ let check = check_raw_tx(payload, context.clone());
+ assert!(check.is_ok());
}
#[test]
@@ -120,16 +120,16 @@ mod tests {
// check
let payload = prepare_payload(hex);
let context = prepare_parse_context(pubkey_str);
- let check = check_raw_tx(payload, context).unwrap();
- assert_eq!((), check);
+ let check = check_raw_tx(payload, context);
+ assert!(check.is_ok());
}
{
// check with change address
let hex = "1f8b08000000000000034d8cbb4a03411440c962b12445d654c12a2c426461d979dc79596914492318022a763377660ca22e59a248fe44f003ececfd046b4b0bfd016beddc5238d58173d264d09f3507b50fa393a65ed5585f6f3d27ad4d1547e12db1f963d2dd38dc9f4f07db8806a40bacd401b004e6426939a3a5905670ab310a2a472fdf9fafbf6427bdf8eaa46f9bd97b913f75ba7b4244190965d2a38b129011698da59ae816a10565c87c081a99a28a6a678956a82804a5a5f204b264f8d3cb278439e69c17968009d447a18d33dc8918a3891a0238b4a09807c76500a95d7b71c148248ca3a65edaa27f5c018c2b31ae484bc58bdd6e7e1e26feae599f368be66875b98c66feb09e2def17d3da3bc16fafce20fbe80d3b79ffe65f4b2bf2076c698bec3e010000";
let payload = prepare_payload(hex);
let context = prepare_parse_context(pubkey_str);
- let check = check_raw_tx(payload, context).unwrap();
- assert_eq!((), check);
+ let check = check_raw_tx(payload, context);
+ assert!(check.is_ok());
}
}
@@ -141,8 +141,8 @@ mod tests {
let extended_pubkey = bitcoin::bip32::Xpub::from_str(extended_pubkey_str).unwrap();
let context = keystone::ParseContext::new(master_fingerprint, extended_pubkey);
let payload = prepare_payload(hex);
- let check = check_raw_tx(payload, context.clone()).unwrap();
- assert_eq!((), check);
+ let check = check_raw_tx(payload, context.clone());
+ assert!(check.is_ok());
}
#[test]
@@ -187,16 +187,16 @@ mod tests {
// check
let payload = prepare_payload(hex);
let context = prepare_parse_context(pubkey_str);
- let check = check_raw_tx(payload, context).unwrap();
- assert_eq!(check, ());
+ let check = check_raw_tx(payload, context);
+ assert!(check.is_ok());
}
{
// check with change address
let hex="1f8b0800000000000003ad8e3f6b935114c689510959123b854ce545500a21f79e7bcefdb36943a91d14c5a063b9e7dc7b108c491b0df912ee2e05c12fe0ee8710fc061d9dc4b1ddfa429742d7c2333c3cc3eff9f5eeed0cdeac67ab52775faf575f56b25a8ccfbbedda0b4ea864939b3fddfea3fdf9ecf8d5f3f9d1bb83e3b70787ef8fe63b8f45127aae3089156582c075921dd809f94c2e4751b27ef7e7bff35f97e6690fbe767bbf47c31ff79bb34eff998fc8ce8126a7925204086c5995c187546c4a89c0327bb462a2538b1923615b8ca9c4e8717cd8df37ce9942a8c5948260b2afa4b1380fa8a40e2348ae8e8cb6445213c8b112d7aa49a0249bd5c9e82236834fd3884fa6e63a53d37c6ff5587d0a106d604915b268ca56347b66eb2d5355eba2a10c364bb0220801ab27058e4cdc3e0e3be3177722f8edef835b867bb3fe1e8b3d8de2f5f3872d94c576b30cf5e3329d6ed505d9c07a1988362772e2eb62f8ffece1a8d30c5ede80d8a9b90290f88bd8f6010000";
let payload = prepare_payload(hex);
let context = prepare_parse_context(pubkey_str);
- let check = check_raw_tx(payload, context).unwrap();
- assert_eq!(check, ());
+ let check = check_raw_tx(payload, context);
+ assert!(check.is_ok());
}
}
@@ -216,16 +216,16 @@ mod tests {
{
let payload = prepare_payload(hex);
let context = prepare_parse_context(pubkey_str);
- let check = check_raw_tx(payload, context).unwrap();
- assert_eq!((), check);
+ let check = check_raw_tx(payload, context);
+ assert!(check.is_ok());
}
{
//check with change address
let hex="1f8b08000000000000035d8e3d6b94411485892bb8ac4562aa2555580425b0ecfd987be78e9564c514364a9226dddcf9108cf2424c10acfc21d6b696823fc0c2dad2c2d2cade2e2f4995c069ce81e7f04cef6c6fbe3a5b0fb5edbe3c1bce8732bcddf93119d769e42235435e7c9bcc26fb47ebed87a5a4a0de68692d9465206fcbcc844bd12c9cad7441ddfdfaefcff7fff0784a9f26d39f0fb67eed2d3e6fcc9e6a94184d8b5bd3d00395ce4dc6a6298c9f1648bb0117456fad31024bb244923c2504cfb67330db074ece3e126ebd884b83d81d3495685c728912ba54b6c20dcc5bc5a4305ef5ea586b662914e65fee2e36dfad427ab482ebace04a2f8c4cf79a72abb5ba96d23843004382d490b57974175522a78c50136384d2cc230124cd577a443910f61cb24ab658713409c48622d5a447af346abb4565eacce812893a228869ce986cfef7de6d3ddc7b325b7078217a7af8e6f5f1faf8f0991d1c9d5f3c8f259d7cfc309cfa7bbd38895bbfefcf376eb2b8824b3d3de48fdc010000";
let payload = prepare_payload(hex);
let context = prepare_parse_context(pubkey_str);
- let check = check_raw_tx(payload, context).unwrap();
- assert_eq!((), check);
+ let check = check_raw_tx(payload, context);
+ assert!(check.is_ok());
}
}
@@ -246,16 +246,16 @@ mod tests {
// check
let payload = prepare_payload(hex);
let context = prepare_parse_context(pubkey_str);
- let check = check_raw_tx(payload, context).unwrap();
- assert_eq!((), check);
+ let check = check_raw_tx(payload, context);
+ assert!(check.is_ok());
}
{
// check with output(cash address)
let hex="1f8b0800000000000003658dbb4e0241144003361b1a818a58c1c604b3c966e73db39d819858aa7f70e7ce5c88aeac3c43f8173b7b0b3b3fc1da0fe003d4c6c2d8496f72aa539c9334bbc7d78b711d62ff6a51af6aacab9397e6c12656a20ec0207d6ab68e46e3cbee2962a98c8f22775161ae848f3948c1736d404b70489a9bfef3d7fef5979d25379f8de4add37ecfd2c746ebdcb8e049490dca033990e8a3e1589205a7b577b204511a292df1923312a06244a4084c4783e0796fff3348474c781f6df018c879210cd79281333690e58e796ea1645e39415691b0d2f8c3890549569ba84414dc669dfb42a961c1951e16ec40c1b28b56367f704b0ad3c96d35376e5aedeea0ac70b95de16cb3decc02dbceb7eb09ed76a8db1fdf835e23fd97e17f24a9ccb649010000";
let payload = prepare_payload(hex);
let context = prepare_parse_context(pubkey_str);
- let check = check_raw_tx(payload, context).unwrap();
- assert_eq!((), check);
+ let check = check_raw_tx(payload, context);
+ assert!(check.is_ok());
}
}
}
diff --git a/rust/apps/bitcoin/src/transactions/psbt/wrapped_psbt.rs b/rust/apps/bitcoin/src/transactions/psbt/wrapped_psbt.rs
index 9685a3e..061ae11 100644
--- a/rust/apps/bitcoin/src/transactions/psbt/wrapped_psbt.rs
+++ b/rust/apps/bitcoin/src/transactions/psbt/wrapped_psbt.rs
@@ -347,7 +347,7 @@ impl WrappedPsbt {
fn get_multi_sig_script_and_format<'a>(
&'a self,
input: &'a Input,
- ) -> Result<(&ScriptBuf, MultiSigFormat)> {
+ ) -> Result<(&'a ScriptBuf, MultiSigFormat)> {
match (&input.redeem_script, &input.witness_script) {
(Some(script), None) => Ok((script, MultiSigFormat::P2sh)),
(Some(_), Some(script)) => Ok((script, MultiSigFormat::P2wshP2sh)),
diff --git a/rust/apps/cardano/src/address.rs b/rust/apps/cardano/src/address.rs
index 605069c..a774324 100644
--- a/rust/apps/cardano/src/address.rs
+++ b/rust/apps/cardano/src/address.rs
@@ -1,7 +1,6 @@
use crate::errors::{CardanoError, R};
use alloc::string::{String, ToString};
-use crate::slip23::{from_seed_slip23, from_seed_slip23_path};
use cardano_serialization_lib::protocol_types::credential::*;
use cardano_serialization_lib::protocol_types::{
BaseAddress, Ed25519KeyHash, EnterpriseAddress, RewardAddress,
diff --git a/rust/apps/cardano/src/slip23.rs b/rust/apps/cardano/src/slip23.rs
index 2a5172d..1fec8ca 100644
--- a/rust/apps/cardano/src/slip23.rs
+++ b/rust/apps/cardano/src/slip23.rs
@@ -42,7 +42,7 @@ pub fn from_seed_slip23(seed: &[u8]) -> R<CardanoHDNode> {
k.copy_from_slice(&sha512(il));
// Step 5: Modify k by specific bit operations for EdDSA compatibility
- k[0] = k[0] & 0xf8; // Clear the 3 least significant bits
+ k[0] &= 0xf8; // Clear the 3 least significant bits
k[31] = (k[31] & 0x1f) | 0x40; // Set the 6th bit and clear the 3 most significant bits
// Step 6: Construct the 96-byte extended private key
@@ -95,7 +95,7 @@ fn parse_derivation_path(path: &str) -> R<Vec<u32>> {
};
let index: u32 = index_str.parse().map_err(|_| {
- CardanoError::DerivationError(format!("Invalid path component: {}", part))
+ CardanoError::DerivationError(format!("Invalid path component: {part}"))
})?;
if hardened {
diff --git a/rust/apps/cardano/src/structs.rs b/rust/apps/cardano/src/structs.rs
index 87799ea..b55a99a 100644
--- a/rust/apps/cardano/src/structs.rs
+++ b/rust/apps/cardano/src/structs.rs
@@ -196,7 +196,7 @@ impl ParsedCardanoSignCip8Data {
match sign_structure {
Ok(sign_structure) => {
let raw_payload = sign_structure.get_payload();
- let mut payload = String::from_utf8(hex::decode(raw_payload.clone()).unwrap())
+ let payload = String::from_utf8(hex::decode(raw_payload.clone()).unwrap())
.unwrap_or_else(|_| raw_payload.clone());
let mut message_hash = hex::encode(raw_payload);
if hash_payload {
@@ -402,14 +402,11 @@ impl ParsedCardanoTx {
.to_bech32(None)
.map_err(|e| CardanoError::InvalidTransaction(e.to_string()))?,
}];
- match _cert.coin() {
- Some(v) => {
- fields.push(CertField {
- label: LABEL_DEPOSIT.to_string(),
- value: normalize_coin(u64::from(&v)),
- });
- }
- None => {}
+ if let Some(v) = _cert.coin() {
+ fields.push(CertField {
+ label: LABEL_DEPOSIT.to_string(),
+ value: normalize_coin(u64::from(&v)),
+ });
}
certs.push(CardanoCertificate::new(
"Stake Deregistration".to_string(),
@@ -424,14 +421,11 @@ impl ParsedCardanoTx {
.to_bech32(None)
.map_err(|e| CardanoError::InvalidTransaction(e.to_string()))?,
}];
- match _cert.coin() {
- Some(v) => {
- fields.push(CertField {
- label: LABEL_DEPOSIT.to_string(),
- value: normalize_coin(u64::from(&v)),
- });
- }
- None => {}
+ if let Some(v) = _cert.coin() {
+ fields.push(CertField {
+ label: LABEL_DEPOSIT.to_string(),
+ value: normalize_coin(u64::from(&v)),
+ });
}
certs.push(CardanoCertificate::new(
"Account Registration".to_string(),
@@ -995,7 +989,7 @@ impl ParsedCardanoTx {
}
to.assets_text = match to.assets.len() {
0 => None,
- x => Some(format!("{} more assets", x)),
+ x => Some(format!("{x} more assets")),
};
map.insert(address, to);
}
@@ -1015,7 +1009,7 @@ impl ParsedCardanoTx {
assets: assets_map.clone(),
assets_text: match assets_map.len() {
0 => None,
- x => Some(format!("{} more assets", x)),
+ x => Some(format!("{x} more assets")),
},
};
map.insert(address, to);
@@ -1131,24 +1125,18 @@ impl ParsedCardanoTx {
)?);
if let Some(addr) = BaseAddress::from_address(&addr_in_utxo) {
- match addr.payment_cred().to_keyhash() {
- Some(keyhash) => {
- if my_pubkey_hash.eq(&keyhash.to_hex()) {
- pubkey_hash_paired = true;
- }
+ if let Some(keyhash) = addr.payment_cred().to_keyhash() {
+ if my_pubkey_hash.eq(&keyhash.to_hex()) {
+ pubkey_hash_paired = true;
}
- None => {}
}
}
if let Some(addr) = EnterpriseAddress::from_address(&addr_in_utxo) {
- match addr.payment_cred().to_keyhash() {
- Some(keyhash) => {
- if my_pubkey_hash.eq(&keyhash.to_hex()) {
- pubkey_hash_paired = true;
- }
+ if let Some(keyhash) = addr.payment_cred().to_keyhash() {
+ if my_pubkey_hash.eq(&keyhash.to_hex()) {
+ pubkey_hash_paired = true;
}
- None => {}
}
}
diff --git a/rust/apps/ethereum/src/abi.rs b/rust/apps/ethereum/src/abi.rs
index 040e33e..234e087 100644
--- a/rust/apps/ethereum/src/abi.rs
+++ b/rust/apps/ethereum/src/abi.rs
@@ -111,10 +111,10 @@ fn _parse_by_function(
_input.name.clone(),
match _token {
Token::Address(_) => {
- format!("0x{}", _token)
+ format!("0x{_token}")
}
Token::Uint(uint) => {
- format!("{}", uint)
+ format!("{uint}")
}
_ => _token.to_string(),
},
diff --git a/rust/apps/ethereum/src/address.rs b/rust/apps/ethereum/src/address.rs
index 4d00923..e77f1d8 100644
--- a/rust/apps/ethereum/src/address.rs
+++ b/rust/apps/ethereum/src/address.rs
@@ -43,7 +43,7 @@ pub fn derive_address(hd_path: &str, root_x_pub: &str, root_path: &str) -> Resul
let sub_path = hd_path
.strip_prefix(&root_path)
.ok_or(EthereumError::InvalidHDPath(hd_path.to_string()))?;
- derive_public_key(&root_x_pub.to_string(), &format!("m/{}", sub_path))
+ derive_public_key(&root_x_pub.to_string(), &format!("m/{sub_path}"))
.map(generate_address)
.map_err(EthereumError::from)?
}
@@ -53,8 +53,8 @@ mod tests {
use super::*;
extern crate std;
- use core::str::FromStr;
- use std::println;
+
+
#[test]
fn test_generate_address() {
diff --git a/rust/apps/ethereum/src/batch_tx_rules.rs b/rust/apps/ethereum/src/batch_tx_rules.rs
index 6183094..3d35095 100644
--- a/rust/apps/ethereum/src/batch_tx_rules.rs
+++ b/rust/apps/ethereum/src/batch_tx_rules.rs
@@ -7,7 +7,7 @@ use crate::{errors::EthereumError, structs::ParsedEthereumTransaction};
pub fn rule_swap(txs: Vec<ParsedEthereumTransaction>) -> Result<(), EthereumError> {
//
- if txs.len() < 1 || txs.len() > 3 {
+ if txs.is_empty() || txs.len() > 3 {
return Err(EthereumError::InvalidSwapTransaction(format!(
"invalid transaction count: {}",
txs.len()
@@ -32,8 +32,7 @@ pub fn rule_swap(txs: Vec<ParsedEthereumTransaction>) -> Result<(), EthereumErro
let amount = approval_0.value;
if amount != "0" {
return Err(EthereumError::InvalidSwapTransaction(format!(
- "invalid revoke amount: {}",
- amount
+ "invalid revoke amount: {amount}"
)));
}
let _ = parse_erc20_approval(&txs[1].input, 0)
diff --git a/rust/apps/ethereum/src/erc20.rs b/rust/apps/ethereum/src/erc20.rs
index 7eca2bb..12c5521 100644
--- a/rust/apps/ethereum/src/erc20.rs
+++ b/rust/apps/ethereum/src/erc20.rs
@@ -21,8 +21,8 @@ pub fn encode_erc20_transfer_calldata(to: H160, amount: U256) -> String {
let mut calldata = "a9059cbb".to_string();
calldata.push_str(&format!("{:0>64}", hex::encode(to)));
// convert value to hex and pad it to 64 bytes
- let amount_hex = format!("{:x}", amount);
- let amount_padding = format!("{:0>64}", amount_hex);
+ let amount_hex = format!("{amount:x}");
+ let amount_padding = format!("{amount_hex:0>64}");
calldata.push_str(&amount_padding);
calldata
}
@@ -50,7 +50,7 @@ pub fn parse_erc20(input: &str, decimal: u32) -> Result<ParsedErc20Transaction,
// If there is a remainder, convert it to a decimal
let remainder_decimal = remainder.to_string();
let padded_remainder = format!("{:0>width$}", remainder_decimal, width = decimal as usize);
- format!("{}.{}", value_decimal, padded_remainder)
+ format!("{value_decimal}.{padded_remainder}")
.trim_end_matches('0')
.to_string()
} else {
@@ -92,7 +92,7 @@ pub fn parse_erc20_approval(
// If there is a remainder, convert it to a decimal
let remainder_decimal = remainder.to_string();
let padded_remainder = format!("{:0>width$}", remainder_decimal, width = decimal as usize);
- format!("{}.{}", value_decimal, padded_remainder)
+ format!("{value_decimal}.{padded_remainder}")
.trim_end_matches('0')
.to_string()
} else {
diff --git a/rust/apps/ethereum/src/normalizer.rs b/rust/apps/ethereum/src/normalizer.rs
index ca7c3c2..d964562 100644
--- a/rust/apps/ethereum/src/normalizer.rs
+++ b/rust/apps/ethereum/src/normalizer.rs
@@ -16,7 +16,7 @@ pub fn normalize_value(value: U256) -> String {
return "0".to_string();
}
- let padded_value = format!("{:0>18}", value_str);
+ let padded_value = format!("{value_str:0>18}");
let len = padded_value.len();
let mut res = if len <= 18 {
@@ -24,14 +24,14 @@ pub fn normalize_value(value: U256) -> String {
while val.ends_with('0') {
val.pop();
}
- format!("0.{}", val)
+ format!("0.{val}")
} else {
let (int_part, decimal_part) = padded_value.split_at(len - 18);
let mut decimal = decimal_part.to_string();
while decimal.ends_with('0') {
decimal.pop();
}
- format!("{}.{}", int_part, decimal)
+ format!("{int_part}.{decimal}")
};
if res.ends_with('.') {
res.pop();
@@ -52,6 +52,6 @@ mod tests {
fn test() {
let x = U256::from(000_000_100_000_000_001u64);
let y = normalize_value(x);
- println!("{}", y);
+ println!("{y}");
}
}
diff --git a/rust/apps/ethereum/src/structs.rs b/rust/apps/ethereum/src/structs.rs
index dccc6b8..69f1e6f 100644
--- a/rust/apps/ethereum/src/structs.rs
+++ b/rust/apps/ethereum/src/structs.rs
@@ -76,7 +76,7 @@ impl ParsedEthereumTransaction {
nonce: tx.nonce,
gas_limit: tx.gas_limit,
gas_price: Some(tx.gas_price),
- from: from.map_or(None, |key| Some(generate_address(key).unwrap_or_default())),
+ from: from.map(|key| generate_address(key).unwrap_or_default()),
to: tx.to,
value: tx.value,
chain_id: tx.chain_id,
@@ -97,7 +97,7 @@ impl ParsedEthereumTransaction {
Ok(Self {
nonce: tx.nonce,
gas_limit: tx.gas_limit,
- from: from.map_or(None, |key| Some(generate_address(key).unwrap_or_default())),
+ from: from.map(|key| generate_address(key).unwrap_or_default()),
to: tx.to,
value: tx.value,
chain_id: tx.chain_id,
@@ -152,7 +152,7 @@ impl PersonalMessage {
Ok(Self {
raw_message,
utf8_message,
- from: from.map_or(None, |key| Some(generate_address(key).unwrap_or_default())),
+ from: from.map(|key| generate_address(key).unwrap_or_default()),
})
}
}
@@ -174,7 +174,7 @@ pub struct TypedData {
impl TypedData {
pub fn from(data: TypedData, from: Option<PublicKey>) -> Result<Self> {
Ok(Self {
- from: from.map_or(None, |key| Some(generate_address(key).unwrap_or_default())),
+ from: from.map(|key| generate_address(key).unwrap_or_default()),
..data
})
}
@@ -188,7 +188,7 @@ impl TypedData {
// bytes32 safeTxHash = keccak256(
// abi.encode(SAFE_TX_TYPEHASH, to, value, keccak256(data), operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce)
// );
- if self.primary_type != "SafeTx".to_string() {
+ if self.primary_type != "SafeTx" {
return "".to_string();
}
let safe_tx_typehash =
@@ -200,7 +200,7 @@ impl TypedData {
let value = U256::from_dec_str(value_str).unwrap_or_default();
let data = hex::decode(
- &message["data"]
+ message["data"]
.as_str()
.unwrap_or_default()
.trim_start_matches("0x"),
@@ -280,7 +280,7 @@ impl TypedData {
// Convert to hex string with 0x prefix
// return abi.encodePacked(byte(0x19), byte(0x01), domainSeparator, safeTxHash);
let domain_separator =
- hex::decode(&self.domain_separator.trim_start_matches("0x")).unwrap_or_default();
+ hex::decode(self.domain_separator.trim_start_matches("0x")).unwrap_or_default();
let mut transaction_data = Vec::new();
transaction_data.push(0x19);
transaction_data.push(0x01);
diff --git a/rust/apps/ethereum/src/swap.rs b/rust/apps/ethereum/src/swap.rs
index 87f8461..3b73e2f 100644
--- a/rust/apps/ethereum/src/swap.rs
+++ b/rust/apps/ethereum/src/swap.rs
@@ -1,4 +1,3 @@
-use alloc::format;
use alloc::string::String;
use alloc::string::ToString;
use alloc::vec::Vec;
@@ -82,14 +81,12 @@ pub fn parse_swapkit_contract(
}
if vault.is_none() || swap_in_asset.is_none() || swap_in_amount.is_none() || memo.is_none() {
- return Err(EthereumError::InvalidSwapTransaction(format!(
- "Invalid swapkit contract data"
- )));
+ return Err(EthereumError::InvalidSwapTransaction("Invalid swapkit contract data".to_string()));
}
let swapkit_memo = parse_swapkit_memo(&memo.unwrap())?;
- return Ok(SwapkitContractData::new(
+ Ok(SwapkitContractData::new(
vault.unwrap(),
swap_in_asset.unwrap(),
swap_in_amount.unwrap(),
@@ -98,7 +95,7 @@ pub fn parse_swapkit_contract(
swapkit_memo.receive_address,
expiration,
contract_data,
- ));
+ ))
}
pub struct SwapkitMemo {
diff --git a/rust/apps/iota/src/errors.rs b/rust/apps/iota/src/errors.rs
index ead5dcc..260bbf9 100644
--- a/rust/apps/iota/src/errors.rs
+++ b/rust/apps/iota/src/errors.rs
@@ -51,6 +51,6 @@ impl From<KeystoreError> for IotaError {
impl From<hex::FromHexError> for IotaError {
fn from(value: hex::FromHexError) -> Self {
- Self::InvalidData(format!("hex operation failed {}", value))
+ Self::InvalidData(format!("hex operation failed {value}"))
}
}
diff --git a/rust/apps/monero/src/address.rs b/rust/apps/monero/src/address.rs
index 6d978af..35636fb 100644
--- a/rust/apps/monero/src/address.rs
+++ b/rust/apps/monero/src/address.rs
@@ -158,7 +158,6 @@ fn pub_keys_to_address(
"18"
}
}
- _ => return Err(MoneroError::UnknownNetwork),
};
let mut res_hex = format!(
"{}{}{}",
diff --git a/rust/apps/monero/src/extra.rs b/rust/apps/monero/src/extra.rs
index bb679f2..dbccb9c 100644
--- a/rust/apps/monero/src/extra.rs
+++ b/rust/apps/monero/src/extra.rs
@@ -2,6 +2,7 @@ use alloc::vec::Vec;
use curve25519_dalek::edwards::EdwardsPoint;
#[derive(Clone, PartialEq, Eq, Debug)]
+#[allow(unused)]
pub enum ExtraField {
/// Padding.
///
diff --git a/rust/apps/monero/src/key.rs b/rust/apps/monero/src/key.rs
index 196a696..70a3d67 100644
--- a/rust/apps/monero/src/key.rs
+++ b/rust/apps/monero/src/key.rs
@@ -167,9 +167,9 @@ pub fn generate_sub_secret_key(secret_view_key: PrivateKey, major: u32, minor: u
pub fn generate_key_image_from_priavte_key(private_key: &PrivateKey) -> EdwardsPoint {
let x = private_key.scalar;
- let Hp = hash_to_point((EdwardsPoint::mul_base(&x)).compress().0);
+ let hp = hash_to_point((EdwardsPoint::mul_base(&x)).compress().0);
- x * Hp
+ x * hp
}
pub fn calc_subaddress_m(secret_view_key: &[u8], major: u32, minor: u32) -> [u8; PUBKEY_LEH] {
diff --git a/rust/apps/monero/src/signed_transaction.rs b/rust/apps/monero/src/signed_transaction.rs
index 976d2ce..ec3c358 100644
--- a/rust/apps/monero/src/signed_transaction.rs
+++ b/rust/apps/monero/src/signed_transaction.rs
@@ -7,6 +7,7 @@ use curve25519_dalek::Scalar;
use monero_serai::transaction::{NotPruned, Transaction};
#[derive(Debug, Clone)]
+#[allow(unused)]
pub struct PendingTx {
pub tx: Transaction<NotPruned>,
dust: u64,
@@ -23,6 +24,8 @@ pub struct PendingTx {
multisig_tx_key_entropy: PrivateKey,
}
+#[allow(non_snake_case)]
+#[allow(clippy::too_many_arguments)]
impl PendingTx {
pub fn new(
tx: Transaction<NotPruned>,
diff --git a/rust/apps/monero/src/transfer.rs b/rust/apps/monero/src/transfer.rs
index 04e07b5..7dcfdf0 100644
--- a/rust/apps/monero/src/transfer.rs
+++ b/rust/apps/monero/src/transfer.rs
@@ -20,7 +20,7 @@ use monero_serai::ringct::bulletproofs::Bulletproof;
use monero_serai::ringct::clsag::{Clsag, ClsagContext};
use monero_serai::ringct::{RctBase, RctProofs, RctPrunable};
use monero_serai::transaction::{
- Input, NotPruned, Output, Timelock, Transaction, TransactionPrefix,
+ Input, Output, Timelock, Transaction, TransactionPrefix,
};
use rand_core::OsRng;
use zeroize::Zeroizing;
@@ -122,6 +122,9 @@ pub struct TxDestinationEntry {
}
#[derive(Debug, Clone, Copy)]
+#[allow(non_camel_case_types)]
+#[allow(non_snake_case)]
+
pub struct Multisig_kLRki {
pub k: [u8; 32],
pub L: [u8; 32],
@@ -130,6 +133,7 @@ pub struct Multisig_kLRki {
}
#[derive(Debug, Clone)]
+#[allow(non_snake_case)]
pub struct TxSourceEntry {
pub outputs: Vec<OutputEntry>,
pub real_output: u64,
@@ -311,8 +315,8 @@ impl TxConstructionData {
keccak256(&buffer)[0]
}
- pub fn outputs(&self, keypair: &KeyPair) -> InnerOutputs {
- let shared_key_derivations = self.shared_key_derivations(keypair);
+ pub fn outputs(&self, keypair: &KeyPair, tx_key: &PrivateKey, additional_keys: &Vec<PrivateKey>, tx_key_pub: &EdwardsPoint) -> InnerOutputs {
+ let shared_key_derivations = self.shared_key_derivations(keypair, tx_key, additional_keys, tx_key_pub);
let mut res = InnerOutputs::new();
for (dest, shared_key_derivation) in self.splitted_dsts.iter().zip(shared_key_derivations) {
let image = generate_key_image_from_priavte_key(&PrivateKey::new(
@@ -465,6 +469,7 @@ impl UnsignedTx {
let amount = read_next_u64(bytes, &mut offset);
let rct = read_next_bool(bytes, &mut offset);
let mask = read_next_u8_32(bytes, &mut offset);
+ #[allow(non_snake_case)]
let multisig_kLRki = Multisig_kLRki {
k: read_next_u8_32(bytes, &mut offset),
L: read_next_u8_32(bytes, &mut offset),
@@ -557,64 +562,62 @@ impl UnsignedTx {
UnsignedTx { txes, transfers }
}
- pub fn transaction_without_signatures(&self, keypair: &KeyPair) -> Result<Vec<Transaction>> {
- let mut txes = vec![];
- for tx in self.txes.iter() {
- let commitments_and_encrypted_amounts = tx.commitments_and_encrypted_amounts(keypair);
- let mut commitments = Vec::with_capacity(tx.splitted_dsts.len());
- let mut bp_commitments = Vec::with_capacity(tx.splitted_dsts.len());
- let mut encrypted_amounts = Vec::with_capacity(tx.splitted_dsts.len());
- for (commitment, encrypted_amount) in commitments_and_encrypted_amounts {
- commitments.push(commitment.calculate());
- bp_commitments.push(commitment);
- encrypted_amounts.push(encrypted_amount);
- }
- let bulletproof = {
- (match tx.rct_config.bp_version {
- RctType::RCTTypeFull => Bulletproof::prove(&mut OsRng, bp_commitments),
- RctType::RCTTypeNull | RctType::RCTTypeBulletproof2 => {
- Bulletproof::prove_plus(&mut OsRng, bp_commitments)
- }
- _ => panic!("unsupported RctType"),
- })
- .expect(
- "couldn't prove BP(+)s for this many payments despite checking in constructor?",
- )
- };
- let tx: Transaction<NotPruned> = Transaction::V2 {
- prefix: TransactionPrefix {
- additional_timelock: Timelock::None,
- inputs: tx.inputs(keypair)?.get_inputs(),
- outputs: tx.outputs(keypair).get_outputs(),
- extra: tx.extra(keypair),
- },
- proofs: Some(RctProofs {
- base: RctBase {
- fee: tx.fee(),
- encrypted_amounts,
- pseudo_outs: vec![],
- commitments,
- },
- prunable: RctPrunable::Clsag {
- bulletproof,
- clsags: vec![],
- pseudo_outs: vec![],
- },
- }),
- };
- txes.push(tx);
+ pub fn construct_tx(&self, tx: &TxConstructionData, keypair: &KeyPair, tx_key: &PrivateKey, additional_keys: &Vec<PrivateKey>, tx_key_pub: &EdwardsPoint, additional_keys_pub: &Vec<EdwardsPoint>) -> Result<Transaction> {
+ let commitments_and_encrypted_amounts = tx.commitments_and_encrypted_amounts(keypair, tx_key, additional_keys, tx_key_pub);
+ let mut commitments = Vec::with_capacity(tx.splitted_dsts.len());
+ let mut bp_commitments = Vec::with_capacity(tx.splitted_dsts.len());
+ let mut encrypted_amounts = Vec::with_capacity(tx.splitted_dsts.len());
+ for (commitment, encrypted_amount) in commitments_and_encrypted_amounts {
+ commitments.push(commitment.calculate());
+ bp_commitments.push(commitment);
+ encrypted_amounts.push(encrypted_amount);
}
-
- Ok(txes)
+ let bulletproof = {
+ (match tx.rct_config.bp_version {
+ RctType::RCTTypeFull => Bulletproof::prove(&mut OsRng, bp_commitments),
+ RctType::RCTTypeNull | RctType::RCTTypeBulletproof2 => {
+ Bulletproof::prove_plus(&mut OsRng, bp_commitments)
+ }
+ _ => panic!("unsupported RctType"),
+ })
+ .expect(
+ "couldn't prove BP(+)s for this many payments despite checking in constructor?",
+ )
+ };
+ let tx = Transaction::V2 {
+ prefix: TransactionPrefix {
+ additional_timelock: Timelock::None,
+ inputs: tx.inputs(keypair)?.get_inputs(),
+ outputs: tx.outputs(keypair, tx_key, additional_keys, tx_key_pub).get_outputs(),
+ extra: tx.extra(keypair, tx_key, additional_keys, tx_key_pub, additional_keys_pub),
+ },
+ proofs: Some(RctProofs {
+ base: RctBase {
+ fee: tx.fee(),
+ encrypted_amounts,
+ pseudo_outs: vec![],
+ commitments,
+ },
+ prunable: RctPrunable::Clsag {
+ bulletproof,
+ clsags: vec![],
+ pseudo_outs: vec![],
+ },
+ }),
+ };
+ Ok(tx)
}
pub fn sign(&self, keypair: &KeyPair) -> Result<SignedTxSet> {
let mut penging_tx = vec![];
- let txes = self.transaction_without_signatures(keypair)?;
let mut tx_key_images = vec![];
- for (tx, unsigned_tx) in txes.iter().zip(self.txes.iter()) {
- let mask_sum = unsigned_tx.sum_output_masks(keypair);
+ for unsigned_tx in self.txes.iter() {
+ let (tx_key, additional_keys, tx_key_pub, additional_keys_pub) = unsigned_tx.transaction_keys();
+
+ let tx = self.construct_tx(unsigned_tx, keypair, &tx_key, &additional_keys, &tx_key_pub, &additional_keys_pub)?;
+
+ let mask_sum = unsigned_tx.sum_output_masks(keypair, &tx_key, &additional_keys, &tx_key_pub);
let inputs = unsigned_tx.inputs(keypair)?;
let mut clsag_signs = Vec::with_capacity(inputs.0.len());
for (i, input) in inputs.0.iter().enumerate() {
@@ -698,7 +701,9 @@ impl UnsignedTx {
key_images_str
};
- let keys = unsigned_tx.transaction_keys();
+ for item in unsigned_tx.outputs(keypair, &tx_key, &additional_keys, &tx_key_pub).0.iter() {
+ tx_key_images.push((PublicKey::new(item.output.key), item.key_image));
+ }
penging_tx.push(PendingTx::new(
tx.clone(),
@@ -708,17 +713,14 @@ impl UnsignedTx {
unsigned_tx.change_dts.clone(),
unsigned_tx.selected_transfers.clone(),
key_images_str,
- keys.0,
- keys.1,
+ tx_key,
+ additional_keys,
unsigned_tx.dests.clone(),
// vec![],
unsigned_tx.clone(),
// PrivateKey::default(),
));
- for item in unsigned_tx.outputs(keypair).0.iter() {
- tx_key_images.push((PublicKey::new(item.output.key), item.key_image));
- }
}
for transfer in self.transfers.details.iter() {
@@ -779,7 +781,7 @@ pub fn sign_tx(keypair: KeyPair, request_data: Vec<u8>) -> Result<Vec<u8>> {
#[cfg(test)]
mod tests {
use super::*;
- use crate::key::PrivateKey;
+
use alloc::vec;
use core::ops::Deref;
use curve25519_dalek::edwards::EdwardsPoint;
diff --git a/rust/apps/monero/src/transfer_key.rs b/rust/apps/monero/src/transfer_key.rs
index cc74aad..867df39 100644
--- a/rust/apps/monero/src/transfer_key.rs
+++ b/rust/apps/monero/src/transfer_key.rs
@@ -77,14 +77,13 @@ impl TxConstructionData {
dest == &self.change_dts
}
- fn ecdhs(&self, keypair: &KeyPair) -> Vec<EdwardsPoint> {
- let (tx_key, additional_keys, tx_key_pub, _) = self.transaction_keys();
+ fn ecdhs(&self, keypair: &KeyPair, tx_key: &PrivateKey, additional_keys: &Vec<PrivateKey>, tx_key_pub: &EdwardsPoint) -> Vec<EdwardsPoint> {
let mut res = Vec::with_capacity(self.splitted_dsts.len());
for (i, dest) in self.splitted_dsts.iter().enumerate() {
let key_to_use = if dest.is_subaddress {
- additional_keys.get(i).unwrap_or(&tx_key)
+ additional_keys.get(i).unwrap_or(tx_key)
} else {
- &tx_key
+ tx_key
};
res.push(if !self.is_change_dest(dest) {
key_to_use.scalar
@@ -101,18 +100,17 @@ impl TxConstructionData {
res
}
- fn payment_id_xors(&self, keypair: &KeyPair) -> Vec<[u8; 8]> {
+ fn payment_id_xors(&self, keypair: &KeyPair, tx_key: &PrivateKey, additional_keys: &Vec<PrivateKey>, tx_key_pub: &EdwardsPoint) -> Vec<[u8; 8]> {
let mut res = Vec::with_capacity(self.splitted_dsts.len());
- for ecdh in self.ecdhs(keypair) {
+ for ecdh in self.ecdhs(keypair, tx_key, additional_keys, tx_key_pub) {
res.push(SharedKeyDerivations::payment_id_xor(Zeroizing::new(ecdh)));
}
res
}
- pub fn extra(&self, keypair: &KeyPair) -> Vec<u8> {
- let (_, _, tx_key, additional_keys) = self.transaction_keys();
- let payment_id_xors = self.payment_id_xors(keypair);
- let mut extra = Extra::new(tx_key, additional_keys);
+ pub fn extra(&self, keypair: &KeyPair, tx_key: &PrivateKey, additional_keys: &Vec<PrivateKey>, tx_key_pub: &EdwardsPoint, additional_keys_pub: &Vec<EdwardsPoint>) -> Vec<u8> {
+ let payment_id_xors = self.payment_id_xors(keypair, tx_key, additional_keys, tx_key_pub);
+ let mut extra = Extra::new(*tx_key_pub, additional_keys_pub.clone());
if self.splitted_dsts.len() == 2 {
let (_, payment_id_xor) = self
.splitted_dsts
@@ -132,8 +130,11 @@ impl TxConstructionData {
pub fn shared_key_derivations(
&self,
keypair: &KeyPair,
+ tx_key: &PrivateKey,
+ additional_keys: &Vec<PrivateKey>,
+ tx_key_pub: &EdwardsPoint,
) -> Vec<Zeroizing<SharedKeyDerivations>> {
- let ecdhs = self.ecdhs(keypair);
+ let ecdhs = self.ecdhs(keypair, tx_key, additional_keys, tx_key_pub);
let mut res = Vec::with_capacity(self.splitted_dsts.len());
for (i, (_, ecdh)) in self.splitted_dsts.iter().zip(ecdhs).enumerate() {
res.push(SharedKeyDerivations::output_derivations(
@@ -149,8 +150,11 @@ impl TxConstructionData {
pub fn commitments_and_encrypted_amounts(
&self,
keypair: &KeyPair,
+ tx_key: &PrivateKey,
+ additional_keys: &Vec<PrivateKey>,
+ tx_key_pub: &EdwardsPoint,
) -> Vec<(Commitment, EncryptedAmount)> {
- let shared_key_derivations = self.shared_key_derivations(keypair);
+ let shared_key_derivations = self.shared_key_derivations(keypair, tx_key, additional_keys, tx_key_pub);
let mut res = Vec::with_capacity(self.splitted_dsts.len());
for (dest, shared_key_derivation) in self.splitted_dsts.iter().zip(shared_key_derivations) {
@@ -166,8 +170,8 @@ impl TxConstructionData {
res
}
- pub fn sum_output_masks(&self, keypair: &KeyPair) -> Scalar {
- self.commitments_and_encrypted_amounts(keypair)
+ pub fn sum_output_masks(&self, keypair: &KeyPair, tx_key: &PrivateKey, additional_keys: &Vec<PrivateKey>, tx_key_pub: &EdwardsPoint) -> Scalar {
+ self.commitments_and_encrypted_amounts(keypair, tx_key, additional_keys, tx_key_pub)
.into_iter()
.map(|(commitment, _)| commitment.mask)
.sum()
diff --git a/rust/apps/near/src/account_id/borsh.rs b/rust/apps/near/src/account_id/borsh.rs
index c2a141b..3e841a8 100644
--- a/rust/apps/near/src/account_id/borsh.rs
+++ b/rust/apps/near/src/account_id/borsh.rs
@@ -17,7 +17,7 @@ impl BorshDeserialize for AccountId {
Self::validate(&account_id).map_err(|err| {
io::Error::new(
io::ErrorKind::InvalidData,
- format!("invalid value: \"{}\", {}", account_id, err),
+ format!("invalid value: \"{account_id}\", {err}"),
)
})?;
Ok(Self(account_id))
@@ -35,20 +35,20 @@ mod tests {
fn test_is_valid_account_id() {
for account_id in OK_ACCOUNT_IDS.iter() {
let parsed_account_id = account_id.parse::<AccountId>().unwrap_or_else(|err| {
- panic!("Valid account id {:?} marked invalid: {}", account_id, err)
+ panic!("Valid account id {account_id:?} marked invalid: {err}")
});
let str_serialized_account_id = account_id.try_to_vec().unwrap();
let deserialized_account_id = AccountId::try_from_slice(&str_serialized_account_id)
.unwrap_or_else(|err| {
- panic!("failed to deserialize account ID {:?}: {}", account_id, err)
+ panic!("failed to deserialize account ID {account_id:?}: {err}")
});
assert_eq!(deserialized_account_id, parsed_account_id);
let serialized_account_id =
deserialized_account_id.try_to_vec().unwrap_or_else(|err| {
- panic!("failed to serialize account ID {:?}: {}", account_id, err)
+ panic!("failed to serialize account ID {account_id:?}: {err}")
});
assert_eq!(serialized_account_id, str_serialized_account_id);
}
@@ -58,8 +58,7 @@ mod tests {
assert!(
AccountId::try_from_slice(&str_serialized_account_id).is_err(),
- "successfully deserialized invalid account ID {:?}",
- account_id
+ "successfully deserialized invalid account ID {account_id:?}"
);
}
}
diff --git a/rust/apps/near/src/account_id/errors.rs b/rust/apps/near/src/account_id/errors.rs
index fcc9a2d..3dffd0b 100644
--- a/rust/apps/near/src/account_id/errors.rs
+++ b/rust/apps/near/src/account_id/errors.rs
@@ -20,7 +20,7 @@ impl fmt::Display for ParseAccountError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let mut buf = self.kind.to_string();
if let Some((idx, char)) = self.char {
- write!(buf, " {:?} at index {}", char, idx)?
+ write!(buf, " {char:?} at index {idx}")?
}
buf.fmt(f)
}
diff --git a/rust/apps/near/src/account_id/mod.rs b/rust/apps/near/src/account_id/mod.rs
index 87b0c6f..d292fec 100644
--- a/rust/apps/near/src/account_id/mod.rs
+++ b/rust/apps/near/src/account_id/mod.rs
@@ -26,7 +26,7 @@ impl AccountId {
pub fn is_sub_account_of(&self, parent: &AccountId) -> bool {
self.strip_suffix(parent.as_str())
- .map_or(false, |s| !s.is_empty() && s.find('.') == Some(s.len() - 1))
+ .is_some_and(|s| !s.is_empty() && s.find('.') == Some(s.len() - 1))
}
pub fn is_implicit(&self) -> bool {
@@ -244,7 +244,7 @@ mod tests {
for account_id in BAD_ACCOUNT_IDS.iter().cloned() {
if AccountId::validate(account_id).is_ok() {
- panic!("Invalid account id {:?} marked valid", account_id);
+ panic!("Invalid account id {account_id:?} marked valid");
}
}
}
@@ -260,8 +260,7 @@ mod tests {
char: Some((0, 'E'))
})
),
- "{:?}",
- id
+ "{id:?}"
);
let id = "-KarlUrban.near".parse::<AccountId>();
@@ -273,8 +272,7 @@ mod tests {
char: Some((0, '-'))
})
),
- "{:?}",
- id
+ "{id:?}"
);
let id = "anthonystarr.".parse::<AccountId>();
@@ -286,8 +284,7 @@ mod tests {
char: Some((12, '.'))
})
),
- "{:?}",
- id
+ "{id:?}"
);
let id = "jack__Quaid.near".parse::<AccountId>();
@@ -299,8 +296,7 @@ mod tests {
char: Some((5, '_'))
})
),
- "{:?}",
- id
+ "{id:?}"
);
}
@@ -326,9 +322,8 @@ mod tests {
assert!(
account_id
.parse::<AccountId>()
- .map_or(false, |account_id| account_id.is_top_level()),
- "Valid top level account id {:?} marked invalid",
- account_id
+ .is_ok_and(|account_id| account_id.is_top_level()),
+ "Valid top level account id {account_id:?} marked invalid"
);
}
@@ -374,9 +369,8 @@ mod tests {
assert!(
!account_id
.parse::<AccountId>()
- .map_or(false, |account_id| account_id.is_top_level()),
- "Invalid top level account id {:?} marked valid",
- account_id
+ .is_ok_and(|account_id| account_id.is_top_level()),
+ "Invalid top level account id {account_id:?} marked valid"
);
}
}
@@ -400,9 +394,7 @@ mod tests {
(signer_id.parse::<AccountId>(), sub_account_id.parse::<AccountId>()),
(Ok(signer_id), Ok(sub_account_id)) if sub_account_id.is_sub_account_of(&signer_id)
),
- "Failed to create sub-account {:?} by account {:?}",
- sub_account_id,
- signer_id
+ "Failed to create sub-account {sub_account_id:?} by account {signer_id:?}"
);
}
@@ -456,9 +448,7 @@ mod tests {
(signer_id.parse::<AccountId>(), sub_account_id.parse::<AccountId>()),
(Ok(signer_id), Ok(sub_account_id)) if sub_account_id.is_sub_account_of(&signer_id)
),
- "Invalid sub-account {:?} created by account {:?}",
- sub_account_id,
- signer_id
+ "Invalid sub-account {sub_account_id:?} created by account {signer_id:?}"
);
}
}
@@ -478,8 +468,7 @@ mod tests {
valid_account_id.parse::<AccountId>(),
Ok(account_id) if account_id.is_implicit()
),
- "Account ID {} should be valid 64-len hex",
- valid_account_id
+ "Account ID {valid_account_id} should be valid 64-len hex"
);
}
@@ -497,8 +486,7 @@ mod tests {
invalid_account_id.parse::<AccountId>(),
Ok(account_id) if account_id.is_implicit()
),
- "Account ID {} is not an implicit account",
- invalid_account_id
+ "Account ID {invalid_account_id} is not an implicit account"
);
}
}
diff --git a/rust/apps/near/src/account_id/serde.rs b/rust/apps/near/src/account_id/serde.rs
index 3817aac..8e06890 100644
--- a/rust/apps/near/src/account_id/serde.rs
+++ b/rust/apps/near/src/account_id/serde.rs
@@ -18,7 +18,7 @@ impl<'de> de::Deserialize<'de> for AccountId {
{
let account_id = Box::<str>::deserialize(deserializer)?;
AccountId::validate(&account_id).map_err(|err| {
- de::Error::custom(format!("invalid value: \"{}\", {}", account_id, err))
+ de::Error::custom(format!("invalid value: \"{account_id}\", {err}"))
})?;
Ok(AccountId(account_id))
}
@@ -35,18 +35,18 @@ mod tests {
fn test_is_valid_account_id() {
for account_id in OK_ACCOUNT_IDS.iter() {
let parsed_account_id = account_id.parse::<AccountId>().unwrap_or_else(|err| {
- panic!("Valid account id {:?} marked invalid: {}", account_id, err)
+ panic!("Valid account id {account_id:?} marked invalid: {err}")
});
let deserialized_account_id: AccountId = serde_json::from_value(json!(account_id))
.unwrap_or_else(|err| {
- panic!("failed to deserialize account ID {:?}: {}", account_id, err)
+ panic!("failed to deserialize account ID {account_id:?}: {err}")
});
assert_eq!(deserialized_account_id, parsed_account_id);
let serialized_account_id = serde_json::to_value(&deserialized_account_id)
.unwrap_or_else(|err| {
- panic!("failed to serialize account ID {:?}: {}", account_id, err)
+ panic!("failed to serialize account ID {account_id:?}: {err}")
});
assert_eq!(serialized_account_id, json!(account_id));
}
@@ -54,8 +54,7 @@ mod tests {
for account_id in BAD_ACCOUNT_IDS.iter() {
assert!(
serde_json::from_value::<AccountId>(json!(account_id)).is_err(),
- "successfully deserialized invalid account ID {:?}",
- account_id
+ "successfully deserialized invalid account ID {account_id:?}"
);
}
}
diff --git a/rust/apps/near/src/primitives_core/hash.rs b/rust/apps/near/src/primitives_core/hash.rs
index 2975006..b0baa88 100644
--- a/rust/apps/near/src/primitives_core/hash.rs
+++ b/rust/apps/near/src/primitives_core/hash.rs
@@ -160,10 +160,7 @@ mod tests {
#[test]
fn test_deserialize_not_base58() {
let encoded = "\"---\"";
- match serde_json::from_str(encoded) {
- Ok(CryptoHash(_)) => assert!(false, "should have failed"),
- Err(_) => (),
- }
+ if let Ok(CryptoHash(_)) = serde_json::from_str(encoded) { assert!(false, "should have failed") }
}
#[test]
@@ -179,8 +176,7 @@ mod tests {
Err(e) => if e.to_string() == "could not convert slice to array" {},
res => assert!(
false,
- "should have failed with incorrect length error: {:?}",
- res
+ "should have failed with incorrect length error: {res:?}"
),
};
}
diff --git a/rust/apps/solana/src/lib.rs b/rust/apps/solana/src/lib.rs
index 1166385..726f0ff 100644
--- a/rust/apps/solana/src/lib.rs
+++ b/rust/apps/solana/src/lib.rs
@@ -57,7 +57,7 @@ mod tests {
use hex::{FromHex, ToHex};
use ur_registry::solana::sol_sign_request::SolSignRequest;
- use crate::solana_lib::solana_program::pubkey::Pubkey;
+
use super::*;
@@ -95,7 +95,7 @@ mod tests {
#[test]
fn test_solana_version_message_2() {
- let mut buffer = hex::decode("800100080ed027455eccf0385fc38f217c5bfbb95f711a16fbe782af7b33a97d1f17ebcd79281764ffe753b4a7a87393561a7178e5d7048eabf5302f5b0ac9ff8c2cd40560f06ebde13476f2455bc64dd1d49730033c0bac118dcbf72c38da62354df37a861c98c04915df1902f5c239c753a4bb55932b2e60b713c81bc81be9badfed8e7968e9def8e27815d652d0072a832a901e7960d89173ba8cb1c9450507eb7129f6d82fac025f4fec4efb956ef13dc4145063534dcddc006382f016f49a64eb71818c97258f4e2489f1bb3d1029148e0d830b5a1399daff1084048e7bd8dbe9f8591b8ffe6224eb2dcd8c0558731a23be68b7f64292a77e9b76889a44264468fff3000000000000000000000000000000000000000000000000000000000000000006ddf6e1d765a193d9cbe146ceeb79ac1cb485ed5f5b37913a8cf5857eff00a90306466fe5211732ffecadba72c39be7bc8ce5bbc5f7126b2c439b3a40000000069b8857feab8184fb687f634618c035dac439dc1aeb3b5598a0f00000000001ca4d39964c9cb5f9790d0a12969f60fd9724936284ea4a12daded42ddfa69c5d0479d52dedbf6bc5ecd09d84534a34aea5975043b36fd02b24650bb58443595c973c265a4390cf341062b67c0c2df7225807028c17a4006a4cfea9e5cfebe53f0706060001071e080901010a000502c05c15000a000903d8d600000000000006060002000b0809010106060003000c080901010d280900041b091c1d00050e0f0210111b091f20000212130314152122160003041718191a092324250126e517cb977ae3ad2a0003000000020302030219a086010000000000054000000000000032004b0903020000010903fe234c2bed04b83d2bc2e13d5320d2c0e31393816adb2d0bca769afbeb0bea1004c6c8c4c30304c5c2ac6488e2949297db40612a5f2340f0bc6a1c476982accc1a20b032e4d99c04fa048e8b898a031d8f8dd64fd4ba4db1bd148b9135fd8024bc94a40d9849e774d871cb2d366ae6a0265205b7b5bfbeb60564bca2bbba").unwrap();
+ let buffer = hex::decode("800100080ed027455eccf0385fc38f217c5bfbb95f711a16fbe782af7b33a97d1f17ebcd79281764ffe753b4a7a87393561a7178e5d7048eabf5302f5b0ac9ff8c2cd40560f06ebde13476f2455bc64dd1d49730033c0bac118dcbf72c38da62354df37a861c98c04915df1902f5c239c753a4bb55932b2e60b713c81bc81be9badfed8e7968e9def8e27815d652d0072a832a901e7960d89173ba8cb1c9450507eb7129f6d82fac025f4fec4efb956ef13dc4145063534dcddc006382f016f49a64eb71818c97258f4e2489f1bb3d1029148e0d830b5a1399daff1084048e7bd8dbe9f8591b8ffe6224eb2dcd8c0558731a23be68b7f64292a77e9b76889a44264468fff3000000000000000000000000000000000000000000000000000000000000000006ddf6e1d765a193d9cbe146ceeb79ac1cb485ed5f5b37913a8cf5857eff00a90306466fe5211732ffecadba72c39be7bc8ce5bbc5f7126b2c439b3a40000000069b8857feab8184fb687f634618c035dac439dc1aeb3b5598a0f00000000001ca4d39964c9cb5f9790d0a12969f60fd9724936284ea4a12daded42ddfa69c5d0479d52dedbf6bc5ecd09d84534a34aea5975043b36fd02b24650bb58443595c973c265a4390cf341062b67c0c2df7225807028c17a4006a4cfea9e5cfebe53f0706060001071e080901010a000502c05c15000a000903d8d600000000000006060002000b0809010106060003000c080901010d280900041b091c1d00050e0f0210111b091f20000212130314152122160003041718191a092324250126e517cb977ae3ad2a0003000000020302030219a086010000000000054000000000000032004b0903020000010903fe234c2bed04b83d2bc2e13d5320d2c0e31393816adb2d0bca769afbeb0bea1004c6c8c4c30304c5c2ac6488e2949297db40612a5f2340f0bc6a1c476982accc1a20b032e4d99c04fa048e8b898a031d8f8dd64fd4ba4db1bd148b9135fd8024bc94a40d9849e774d871cb2d366ae6a0265205b7b5bfbeb60564bca2bbba").unwrap();
let pubkey = "e671e524ef43ccc5ef0006876f9a2fd66681d5abc5871136b343a3e4b073efde".to_string();
let parsed = parse(&buffer);
assert_eq!(true, parsed.is_ok())
diff --git a/rust/apps/stellar/src/address.rs b/rust/apps/stellar/src/address.rs
index 6635cf2..88e2386 100644
--- a/rust/apps/stellar/src/address.rs
+++ b/rust/apps/stellar/src/address.rs
@@ -23,8 +23,7 @@ pub fn get_address(pub_key: &String) -> Result<String> {
Ok(encode_base32(&data))
}
Err(e) => Err(StellarError::AddressError(format!(
- "hex decode error {}",
- e
+ "hex decode error {e}"
))),
}
}
diff --git a/rust/apps/stellar/src/errors.rs b/rust/apps/stellar/src/errors.rs
index c960a22..cbe647a 100644
--- a/rust/apps/stellar/src/errors.rs
+++ b/rust/apps/stellar/src/errors.rs
@@ -29,7 +29,7 @@ impl From<KeystoreError> for StellarError {
impl From<hex::FromHexError> for StellarError {
fn from(value: hex::FromHexError) -> Self {
- Self::InvalidData(format!("hex operation failed {}", value))
+ Self::InvalidData(format!("hex operation failed {value}"))
}
}
diff --git a/rust/apps/sui/src/errors.rs b/rust/apps/sui/src/errors.rs
index 6a5ac62..1096dbc 100644
--- a/rust/apps/sui/src/errors.rs
+++ b/rust/apps/sui/src/errors.rs
@@ -22,13 +22,13 @@ pub type Result<T> = core::result::Result<T, SuiError>;
impl From<hex::FromHexError> for SuiError {
fn from(value: hex::FromHexError) -> Self {
- Self::InvalidData(format!("hex operation failed {}", value))
+ Self::InvalidData(format!("hex operation failed {value}"))
}
}
impl From<serde_json::Error> for SuiError {
fn from(value: serde_json::Error) -> Self {
- Self::InvalidData(format!("serde_json operation failed {}", value))
+ Self::InvalidData(format!("serde_json operation failed {value}"))
}
}
diff --git a/rust/apps/ton/src/messages/jetton.rs b/rust/apps/ton/src/messages/jetton.rs
index 9db4469..389eee1 100644
--- a/rust/apps/ton/src/messages/jetton.rs
+++ b/rust/apps/ton/src/messages/jetton.rs
@@ -38,8 +38,7 @@ impl ParseCell for JettonMessage {
JettonTransferMessage::parse(cell).map(JettonMessage::JettonTransferMessage)
}
_ => Err(TonCellError::InternalError(format!(
- "Invalid Op Code: {:X}",
- op_code
+ "Invalid Op Code: {op_code:X}"
))),
}
})
diff --git a/rust/apps/ton/src/messages/mod.rs b/rust/apps/ton/src/messages/mod.rs
index 3c2dbad..0fcbf8c 100644
--- a/rust/apps/ton/src/messages/mod.rs
+++ b/rust/apps/ton/src/messages/mod.rs
@@ -150,12 +150,12 @@ impl ParseCell for InternalMessage {
let op_code = parser.load_u32(32)?;
match op_code {
JETTON_TRANSFER => Ok(Self {
- op_code: format!("{:x}", op_code),
+ op_code: format!("{op_code:x}"),
action: infer_action(op_code),
operation: Operation::JettonMessage(JettonMessage::parse(cell)?),
}),
NFT_TRANSFER => Ok(Self {
- op_code: format!("{:x}", op_code),
+ op_code: format!("{op_code:x}"),
action: infer_action(op_code),
operation: Operation::NFTMessage(NFTMessage::parse(cell)?),
}),
@@ -173,7 +173,7 @@ impl ParseCell for InternalMessage {
child = t.reference(0);
}
Ok(Self {
- op_code: format!("{:x}", op_code),
+ op_code: format!("{op_code:x}"),
action: None,
operation: Operation::Comment(comment),
})
@@ -181,7 +181,7 @@ impl ParseCell for InternalMessage {
_ => {
let remaining_bytes = parser.remaining_bytes();
Ok(Self {
- op_code: format!("{:x}", op_code),
+ op_code: format!("{op_code:x}"),
action: infer_action(op_code),
operation: Operation::OtherMessage(OtherMessage {
payload: hex::encode(parser.load_bytes(remaining_bytes)?),
diff --git a/rust/apps/ton/src/messages/nft.rs b/rust/apps/ton/src/messages/nft.rs
index e477162..15b6dd8 100644
--- a/rust/apps/ton/src/messages/nft.rs
+++ b/rust/apps/ton/src/messages/nft.rs
@@ -25,8 +25,7 @@ impl ParseCell for NFTMessage {
match op_code {
NFT_TRANSFER => NFTTransferMessage::parse(cell).map(NFTMessage::NFTTransferMessage),
_ => Err(crate::vendor::cell::TonCellError::InternalError(format!(
- "Invalid Op Code: {:X}",
- op_code
+ "Invalid Op Code: {op_code:X}"
))),
}
})
diff --git a/rust/apps/ton/src/structs.rs b/rust/apps/ton/src/structs.rs
index 6125ff5..d60cee8 100644
--- a/rust/apps/ton/src/structs.rs
+++ b/rust/apps/ton/src/structs.rs
@@ -49,7 +49,7 @@ impl TryFrom<&SigningMessage> for TonTransaction {
type Error = TonError;
fn try_from(signing_message: &SigningMessage) -> Result<Self> {
- if signing_message.messages.first().is_none() {
+ if signing_message.messages.is_empty() {
return Err(TonError::InvalidTransaction(
"transaction does not contain transfer info".to_string(),
));
diff --git a/rust/apps/ton/src/transaction.rs b/rust/apps/ton/src/transaction.rs
index 978de9c..ae56f86 100644
--- a/rust/apps/ton/src/transaction.rs
+++ b/rust/apps/ton/src/transaction.rs
@@ -60,11 +60,11 @@ mod tests {
let body = "te6cckEBAwEA7AABHCmpoxdmOZW/AAAABgADAQHTYgAIqFqMWTE1aoxM/MRD/EEluAMqKyKvv/FAn4CTTNIDD6B4KbgAAAAAAAAAAAAAAAAAAA+KfqUACSD7UyTMBDtxsAgA7zuZAqJxsqAciTilI8/iTnGEeq62piAAHtRKd6wOcJwQOThwAwIA1yWThWGAApWA5YrFIkZa+bJ7vYJARri8uevEBP6Td4tUTty6RJsGAh5xAC1IywyQwixSOU8pezOZDC9rv2xCV4CGJzOWH6RX8BTsMAK2ELwgIrsrweR+b2yZuUsWugqtisQzBm6gPg1ubkuzBkk1zw8=";
let result = STANDARD.decode(body).unwrap();
let result = BagOfCells::parse(&result).unwrap();
- println!("{:?}", result);
+ println!("{result:?}");
result.single_root().unwrap().parse_fully(|parser| {
let address = parser.load_address().unwrap();
println!("{}", parser.remaining_bits());
- println!("{}", address);
+ println!("{address}");
Ok(())
});
// let result = super::parse_transaction(&serial);
@@ -77,9 +77,9 @@ mod tests {
let body = "te6cckEBAgEARwABHCmpoxdmOz6lAAAACAADAQBoQgArFnMvHAX9tOjTp4/RDd3vP2Bn8xG+U5MTuKRKUE1NoqHc1lAAAAAAAAAAAAAAAAAAAHBy4G8=";
let serial = STANDARD.decode(body).unwrap();
let tx = parse_transaction(&serial).unwrap();
- println!("{:?}", tx);
+ println!("{tx:?}");
let tx_json = tx.to_json().unwrap();
- println!("{}", tx_json);
+ println!("{tx_json}");
}
#[test]
@@ -112,7 +112,7 @@ mod tests {
//true destination UQBWLOZeOAv7adGnTx-iG7vefsDP5iN8pyYncUiUoJqbRdx9
//transaction to: EQASODeyhIBbcGlrLvpUJiYjOHRwAZHCBGf1HV5tjKvZVsJb
//contract destination: EQBWLOZeOAv7adGnTx+iG7vefsDP5iN8pyYncUiUoJqbRYG4
- println!("{:?}", tx);
+ println!("{tx:?}");
}
// #[test]
@@ -130,7 +130,7 @@ mod tests {
let serial = "b5ee9c724102050100019700011c29a9a31766611df6000000140003010166420013587ccf19c39b1ca51c29f0253ac98d03b8e5ccfc64c3ac2f21c59c20ee8b65987a1200000000000000000000000000010201fe000000004b657973746f6e652068617264776172652077616c6c6574206f666665727320756e6265617461626c65207365637572697479207769746820332050434920736563757269747920636869707320746f206d616e61676520426974636f696e20616e64206f746865722063727970746f20617373657473206f66660301fe6c696e652e4b657973746f6e65206f666665727320332077616c6c6574732c207768696368206d65616e7320796f752063616e206d616e616765206d756c7469706c65206163636f756e74732073657061726174656c79206f6e206f6e65206465766963652e4b657973746f6e65206f666665727320332077616c6c6574730400942c207768696368206d65616e7320796f752063616e206d616e616765206d756c7469706c65206163636f756e74732073657061726174656c79206f6e206f6e65206465766963652e0a0ac04eabc7";
let serial = hex::decode(serial).unwrap();
let tx = parse_transaction(&serial).unwrap();
- println!("{:?}", tx);
+ println!("{tx:?}");
}
#[test]
diff --git a/rust/apps/ton/src/vendor/address/mod.rs b/rust/apps/ton/src/vendor/address/mod.rs
index b39d9fa..7c13a2b 100644
--- a/rust/apps/ton/src/vendor/address/mod.rs
+++ b/rust/apps/ton/src/vendor/address/mod.rs
@@ -434,18 +434,18 @@ mod tests {
let res = "EQDk2VTvn04SUKJrW7rXahzdF8_Qi6utb0wj43InCu9vdjrR".parse::<TonAddress>()?;
let serial = serde_json::to_string(&res).unwrap();
- println!("{}", serial);
+ println!("{serial}");
assert_eq!(serial.as_str(), expected);
let res = "0:e4d954ef9f4e1250a26b5bbad76a1cdd17cfd08babad6f4c23e372270aef6f76"
.parse::<TonAddress>()?;
let serial = serde_json::to_string(&res).unwrap();
- println!("{}", serial);
+ println!("{serial}");
assert_eq!(serial.as_str(), expected);
let res = "EQDk2VTvn04SUKJrW7rXahzdF8/Qi6utb0wj43InCu9vdjrR".parse::<TonAddress>()?;
let serial = serde_json::to_string(&res).unwrap();
- println!("{}", serial);
+ println!("{serial}");
assert_eq!(serial.as_str(), expected);
Ok(())
@@ -454,35 +454,35 @@ mod tests {
#[test]
fn deserialization_works() -> anyhow::Result<()> {
let address = "EQDk2VTvn04SUKJrW7rXahzdF8_Qi6utb0wj43InCu9vdjrR";
- let a = format!("\"{}\"", address);
+ let a = format!("\"{address}\"");
let deserial: TonAddress = serde_json::from_str(a.as_str()).unwrap();
let expected = address.parse()?;
- println!("{}", deserial);
+ println!("{deserial}");
assert_eq!(deserial, expected);
let address = "EQDk2VTvn04SUKJrW7rXahzdF8/Qi6utb0wj43InCu9vdjrR";
- let a = format!("\"{}\"", address);
+ let a = format!("\"{address}\"");
let deserial: TonAddress = serde_json::from_str(a.as_str()).unwrap();
let expected = address.parse()?;
- println!("{}", deserial);
+ println!("{deserial}");
assert_eq!(deserial, expected);
let address = "0:e4d954ef9f4e1250a26b5bbad76a1cdd17cfd08babad6f4c23e372270aef6f76";
- let a = format!("\"{}\"", address);
+ let a = format!("\"{address}\"");
let deserial: TonAddress = serde_json::from_str(a.as_str()).unwrap();
let expected = address.parse()?;
- println!("{}", deserial);
+ println!("{deserial}");
assert_eq!(deserial, expected);
let address =
String::from("0:e4d954ef9f4e1250a26b5bbad76a1cdd17cfd08babad6f4c23e372270aef6f76");
let deserial: TonAddress = serde_json::from_value(Value::String(address.clone())).unwrap();
let expected = address.clone().parse()?;
- println!("{}", deserial);
+ println!("{deserial}");
assert_eq!(deserial, expected);
let address = "124";
- let a = format!("\"{}\"", address);
+ let a = format!("\"{address}\"");
let deserial: serde_json::Result<TonAddress> = serde_json::from_str(a.as_str());
assert!(deserial.is_err());
diff --git a/rust/apps/ton/src/vendor/cell/bag_of_cells.rs b/rust/apps/ton/src/vendor/cell/bag_of_cells.rs
index 88074f9..61f3fcd 100644
--- a/rust/apps/ton/src/vendor/cell/bag_of_cells.rs
+++ b/rust/apps/ton/src/vendor/cell/bag_of_cells.rs
@@ -49,8 +49,7 @@ impl BagOfCells {
Ok(&self.roots[0])
} else {
Err(TonCellError::CellParserError(format!(
- "Single root expected, got {}",
- root_count
+ "Single root expected, got {root_count}"
)))
}
}
diff --git a/rust/apps/ton/src/vendor/cell/builder.rs b/rust/apps/ton/src/vendor/cell/builder.rs
index c23d9e3..d8daf4a 100644
--- a/rust/apps/ton/src/vendor/cell/builder.rs
+++ b/rust/apps/ton/src/vendor/cell/builder.rs
@@ -177,7 +177,7 @@ impl CellBuilder {
if val.is_zero() {
self.store_u8(4, 0)
} else {
- let num_bytes = (val.bits() as usize + 7) / 8;
+ let num_bytes = (val.bits() as usize).div_ceil(8);
self.store_u8(4, num_bytes as u8)?;
self.store_uint(num_bytes * 8, val)
}
@@ -210,8 +210,7 @@ impl CellBuilder {
let ref_count = self.references.len() + 1;
if ref_count > 4 {
return Err(TonCellError::cell_builder_error(format!(
- "Cell must contain at most 4 references, got {}",
- ref_count
+ "Cell must contain at most 4 references, got {ref_count}"
)));
}
self.references.push(cell.clone());
@@ -268,15 +267,13 @@ impl CellBuilder {
let bit_len = vec.len() * 8 - trailing_zeros;
if bit_len > MAX_CELL_BITS {
return Err(TonCellError::cell_builder_error(format!(
- "Cell must contain at most {} bits, got {}",
- MAX_CELL_BITS, bit_len
+ "Cell must contain at most {MAX_CELL_BITS} bits, got {bit_len}"
)));
}
let ref_count = self.references.len();
if ref_count > MAX_CELL_REFERENCES {
return Err(TonCellError::cell_builder_error(format!(
- "Cell must contain at most 4 references, got {}",
- ref_count
+ "Cell must contain at most 4 references, got {ref_count}"
)));
}
@@ -297,13 +294,12 @@ impl CellBuilder {
fn extend_and_invert_bits(bits_cnt: usize, src: &BigUint) -> Result<BigUint, TonCellError> {
if bits_cnt < src.bits() as usize {
return Err(TonCellError::cell_builder_error(format!(
- "Can't invert bits: value {} doesn't fit in {} bits",
- src, bits_cnt
+ "Can't invert bits: value {src} doesn't fit in {bits_cnt} bits"
)));
}
let src_bytes = src.to_bytes_be();
- let inverted_bytes_cnt = (bits_cnt + 7) / 8;
+ let inverted_bytes_cnt = bits_cnt.div_ceil(8);
let mut inverted = vec![0xffu8; inverted_bytes_cnt];
// can be optimized
for (pos, byte) in src_bytes.iter().rev().enumerate() {
diff --git a/rust/apps/ton/src/vendor/cell/cell_type.rs b/rust/apps/ton/src/vendor/cell/cell_type.rs
index 9a0a5f4..20d15d2 100644
--- a/rust/apps/ton/src/vendor/cell/cell_type.rs
+++ b/rust/apps/ton/src/vendor/cell/cell_type.rs
@@ -42,8 +42,7 @@ impl CellType {
4 => CellType::MerkleUpdate,
cell_type => {
return Err(TonCellError::InvalidExoticCellData(format!(
- "Invalid first byte in exotic cell data: {}",
- cell_type
+ "Invalid first byte in exotic cell data: {cell_type}"
)))
}
};
@@ -213,16 +212,14 @@ impl CellType {
let proof_hash: [u8; HASH_BYTES] = data[1..(1 + HASH_BYTES)].try_into().map_err(|err| {
TonCellError::InvalidExoticCellData(format!(
- "Can't get proof hash bytes from cell data, {}",
- err
+ "Can't get proof hash bytes from cell data, {err}"
))
})?;
let proof_depth_bytes = data[(1 + HASH_BYTES)..(1 + HASH_BYTES + 2)]
.try_into()
.map_err(|err| {
TonCellError::InvalidExoticCellData(format!(
- "Can't get proof depth bytes from cell data, {}",
- err
+ "Can't get proof depth bytes from cell data, {err}"
))
})?;
let proof_depth = u16::from_be_bytes(proof_depth_bytes);
@@ -269,26 +266,22 @@ impl CellType {
let proof_hash1: [u8; 32] = data[1..33].try_into().map_err(|err| {
TonCellError::InvalidExoticCellData(format!(
- "Can't get proof hash bytes 1 from cell data, {}",
- err
+ "Can't get proof hash bytes 1 from cell data, {err}"
))
})?;
let proof_hash2: [u8; 32] = data[33..65].try_into().map_err(|err| {
TonCellError::InvalidExoticCellData(format!(
- "Can't get proof hash bytes 2 from cell data, {}",
- err
+ "Can't get proof hash bytes 2 from cell data, {err}"
))
})?;
let proof_depth_bytes1 = data[65..67].try_into().map_err(|err| {
TonCellError::InvalidExoticCellData(format!(
- "Can't get proof depth bytes 1 from cell data, {}",
- err
+ "Can't get proof depth bytes 1 from cell data, {err}"
))
})?;
let proof_depth_bytes2 = data[67..69].try_into().map_err(|err| {
TonCellError::InvalidExoticCellData(format!(
- "Can't get proof depth bytes 2 from cell data, {}",
- err
+ "Can't get proof depth bytes 2 from cell data, {err}"
))
})?;
let proof_depth1 = u16::from_be_bytes(proof_depth_bytes1);
diff --git a/rust/apps/ton/src/vendor/cell/mod.rs b/rust/apps/ton/src/vendor/cell/mod.rs
index 6c1d42a..f816919 100644
--- a/rust/apps/ton/src/vendor/cell/mod.rs
+++ b/rust/apps/ton/src/vendor/cell/mod.rs
@@ -185,8 +185,7 @@ impl Cell {
let ref_count = self.references.len();
if ref_count != expected_refs {
Err(TonCellError::CellParserError(format!(
- "Cell should contain {} reference cells, actual: {}",
- expected_refs, ref_count
+ "Cell should contain {expected_refs} reference cells, actual: {ref_count}"
)))
} else {
Ok(())
@@ -207,7 +206,7 @@ impl Debug for Cell {
t,
self.data
.iter()
- .map(|&byte| format!("{:02X}", byte))
+ .map(|&byte| format!("{byte:02X}"))
.collect::<Vec<_>>()
.join(""),
self.bit_len,
@@ -217,7 +216,7 @@ impl Debug for Cell {
writeln!(
f,
" {}\n",
- format!("{:?}", reference).replace('\n', "\n ")
+ format!("{reference:?}").replace('\n', "\n ")
)?;
}
diff --git a/rust/apps/ton/src/vendor/cell/parser.rs b/rust/apps/ton/src/vendor/cell/parser.rs
index 76a1f20..82583fa 100644
--- a/rust/apps/ton/src/vendor/cell/parser.rs
+++ b/rust/apps/ton/src/vendor/cell/parser.rs
@@ -18,11 +18,7 @@ pub struct CellParser<'a> {
impl CellParser<'_> {
pub fn remaining_bits(&mut self) -> usize {
let pos = self.bit_reader.position_in_bits().unwrap_or_default() as usize;
- if self.bit_len > pos {
- self.bit_len - pos
- } else {
- 0
- }
+ self.bit_len.saturating_sub(pos)
}
/// Return number of full bytes remaining
@@ -83,7 +79,7 @@ impl CellParser<'_> {
}
pub fn load_uint(&mut self, bit_len: usize) -> Result<BigUint, TonCellError> {
- let num_words = (bit_len + 31) / 32;
+ let num_words = bit_len.div_ceil(32);
let high_word_bits = if bit_len % 32 == 0 { 32 } else { bit_len % 32 };
let mut words: Vec<u32> = vec![0_u32; num_words];
let high_word = self.load_u32(high_word_bits)?;
@@ -97,7 +93,7 @@ impl CellParser<'_> {
}
pub fn load_int(&mut self, bit_len: usize) -> Result<BigInt, TonCellError> {
- let num_words = (bit_len + 31) / 32;
+ let num_words = bit_len.div_ceil(32);
let high_word_bits = if bit_len % 32 == 0 { 32 } else { bit_len % 32 };
let mut words: Vec<u32> = vec![0_u32; num_words];
let high_word = self.load_u32(high_word_bits)?;
@@ -139,7 +135,7 @@ impl CellParser<'_> {
}
pub fn load_bits(&mut self, num_bits: usize) -> Result<Vec<u8>, TonCellError> {
- let total_bytes = (num_bits + 7) / 8;
+ let total_bytes = num_bits.div_ceil(8);
let mut res = vec![0_u8; total_bytes];
self.load_bits_to_slice(num_bits, res.as_mut_slice())?;
Ok(res)
diff --git a/rust/apps/ton/src/vendor/cell/raw.rs b/rust/apps/ton/src/vendor/cell/raw.rs
index acd5303..b0a05ae 100644
--- a/rust/apps/ton/src/vendor/cell/raw.rs
+++ b/rust/apps/ton/src/vendor/cell/raw.rs
@@ -80,8 +80,7 @@ impl RawBagOfCells {
}
magic => {
return Err(TonCellError::boc_deserialization_error(format!(
- "Unsupported cell magic number: {:#}",
- magic
+ "Unsupported cell magic number: {magic:#}"
)));
}
};
@@ -133,7 +132,7 @@ impl RawBagOfCells {
let root_count = self.roots.len();
let num_ref_bits = 32 - (self.cells.len() as u32).leading_zeros();
- let num_ref_bytes = (num_ref_bits + 7) / 8;
+ let num_ref_bytes = num_ref_bits.div_ceil(8);
let has_idx = false;
let mut full_size = 0u32;
@@ -143,7 +142,7 @@ impl RawBagOfCells {
}
let num_offset_bits = 32 - full_size.leading_zeros();
- let num_offset_bytes = (num_offset_bits + 7) / 8;
+ let num_offset_bytes = num_offset_bits.div_ceil(8);
let total_size = 4 + // magic
1 + // flags and s_bytes
@@ -268,7 +267,7 @@ fn read_cell(
}
fn raw_cell_size(cell: &RawCell, ref_size_bytes: u32) -> u32 {
- let data_len = (cell.bit_len + 7) / 8;
+ let data_len = cell.bit_len.div_ceil(8);
2 + data_len as u32 + cell.references.len() as u32 * ref_size_bytes
}
@@ -285,7 +284,7 @@ fn write_raw_cell(
let padding_bits = cell.bit_len % 8;
let full_bytes = padding_bits == 0;
let data = cell.data.as_slice();
- let data_len_bytes = (cell.bit_len + 7) / 8;
+ let data_len_bytes = cell.bit_len.div_ceil(8);
// data_len_bytes <= 128 by spec, but d2 must be u8 by spec as well
let d2 = (data_len_bytes * 2 - if full_bytes { 0 } else { 1 }) as u8; //subtract 1 if the last byte is not full
diff --git a/rust/apps/ton/src/vendor/cell/slice.rs b/rust/apps/ton/src/vendor/cell/slice.rs
index 0e27ea0..15bbb2b 100644
--- a/rust/apps/ton/src/vendor/cell/slice.rs
+++ b/rust/apps/ton/src/vendor/cell/slice.rs
@@ -136,7 +136,7 @@ impl CellSlice {
/// Converts the slice to full `Cell` dropping references to original cell.
pub fn to_cell(&self) -> Result<Cell, TonCellError> {
let bit_len = self.end_bit - self.start_bit;
- let total_bytes = (bit_len + 7) / 8;
+ let total_bytes = bit_len.div_ceil(8);
let mut data = vec![0u8; total_bytes];
let cursor = Cursor::new(&self.cell.data);
let mut bit_reader: BitReader<Cursor<&Vec<u8>>, BigEndian> =
diff --git a/rust/apps/ton/src/vendor/cell/util.rs b/rust/apps/ton/src/vendor/cell/util.rs
index 3b1ced5..c1da5cd 100644
--- a/rust/apps/ton/src/vendor/cell/util.rs
+++ b/rust/apps/ton/src/vendor/cell/util.rs
@@ -11,7 +11,7 @@ pub trait BitReadExt {
impl<R: io::Read, E: Endianness> BitReadExt for BitReader<R, E> {
fn read_bits(&mut self, num_bits: usize, slice: &mut [u8]) -> Result<(), TonCellError> {
- let total_bytes = (num_bits + 7) / 8;
+ let total_bytes = num_bits.div_ceil(8);
if total_bytes > slice.len() {
let msg = format!(
"Attempt to read {} bits into buffer {} bytes",
diff --git a/rust/apps/tron/src/transaction/wrapped_tron.rs b/rust/apps/tron/src/transaction/wrapped_tron.rs
index bce69b5..9c3a3e5 100644
--- a/rust/apps/tron/src/transaction/wrapped_tron.rs
+++ b/rust/apps/tron/src/transaction/wrapped_tron.rs
@@ -235,7 +235,7 @@ impl WrappedTron {
Token::Uint(value),
];
fun.encode_input(&tokens)
- .map_err(|_| TronError::InvalidRawTxCryptoBytes(format!("invalid token {:?}", tokens)))
+ .map_err(|_| TronError::InvalidRawTxCryptoBytes(format!("invalid token {tokens:?}")))
}
fn generate_trc20_tx(tx_data: &protoc::TronTx) -> Result<Transaction> {
diff --git a/rust/apps/wallets/src/backpack.rs b/rust/apps/wallets/src/backpack.rs
index 7bcdf41..de8903a 100644
--- a/rust/apps/wallets/src/backpack.rs
+++ b/rust/apps/wallets/src/backpack.rs
@@ -67,7 +67,7 @@ pub fn generate_crypto_multi_accounts(
Some(origin),
None,
None,
- Some(format!("Keystone")),
+ Some("Keystone".to_string()),
None,
);
keys.push(hd_key);
diff --git a/rust/apps/wallets/src/blue_wallet.rs b/rust/apps/wallets/src/blue_wallet.rs
index 8739fff..12b9563 100644
--- a/rust/apps/wallets/src/blue_wallet.rs
+++ b/rust/apps/wallets/src/blue_wallet.rs
@@ -43,10 +43,7 @@ fn get_path_level_number(path: &str, index: usize) -> Option<u32> {
}
let num_str = segments[index].trim_matches('\'');
- match num_str.parse::<u32>() {
- Ok(num) => Some(num),
- Err(_) => None,
- }
+ num_str.parse::<u32>().ok()
}
fn generate_output(
@@ -68,8 +65,7 @@ fn generate_output(
PURPOSE_NATIVE_SEGWIT => vec![ScriptExpression::WitnessPublicKeyHash],
_ => {
return Err(URError::UrEncodeError(format!(
- "not supported purpose:{}",
- purpose
+ "not supported purpose:{purpose}"
)))
}
};
diff --git a/rust/apps/wallets/src/core_wallet.rs b/rust/apps/wallets/src/core_wallet.rs
index b1857f5..6f1e47f 100644
--- a/rust/apps/wallets/src/core_wallet.rs
+++ b/rust/apps/wallets/src/core_wallet.rs
@@ -1,12 +1,9 @@
-use core::str::FromStr;
-
use alloc::{
string::{String, ToString},
vec::Vec,
};
use {
- bitcoin::bip32::{ChildNumber, DerivationPath},
- bitcoin::secp256k1::Secp256k1,
+ bitcoin::bip32::ChildNumber,
ur_registry::{
crypto_hd_key::CryptoHDKey,
crypto_key_path::{CryptoKeyPath, PathComponent},
@@ -17,11 +14,6 @@ use {
use crate::{common::get_path_component, ExtendedPublicKey};
-fn get_device_id(serial_number: &str) -> String {
- use cryptoxide::hashing::sha256;
- hex::encode(&sha256(&sha256(serial_number.as_bytes()))[0..20])
-}
-
const AVAX_STANDARD_PREFIX: &str = "44'/60'/0'";
const AVAX_X_P_PREFIX: &str = "44'/9000'/0'";
@@ -55,7 +47,7 @@ pub fn generate_crypto_multi_accounts(
_ => {
return Err(URError::UrEncodeError(format!(
"Unknown key path: {}",
- ele.path.to_string()
+ ele.path
)))
}
}
@@ -81,8 +73,8 @@ fn generate_k1_normal_key(
let key_path = CryptoKeyPath::new(
path.into_iter()
.map(|v| match v {
- ChildNumber::Normal { index } => get_path_component(Some(index.clone()), false),
- ChildNumber::Hardened { index } => get_path_component(Some(index.clone()), true),
+ ChildNumber::Normal { index } => get_path_component(Some(*index), false),
+ ChildNumber::Hardened { index } => get_path_component(Some(*index), true),
})
.collect::<URResult<Vec<PathComponent>>>()?,
Some(mfp),
@@ -100,43 +92,3 @@ fn generate_k1_normal_key(
note,
))
}
-
-fn generate_eth_ledger_live_key(
- mfp: [u8; 4],
- key: ExtendedPublicKey,
- note: Option<String>,
-) -> URResult<CryptoHDKey> {
- let xpub = bitcoin::bip32::Xpub::decode(&key.get_key())
- .map_err(|_e| URError::UrEncodeError(_e.to_string()))?;
- let path = key.get_path();
- let sub_path =
- DerivationPath::from_str("m/0/0").map_err(|_e| URError::UrEncodeError(_e.to_string()))?;
- let _target_key = xpub
- .derive_pub(&Secp256k1::new(), &sub_path)
- .map_err(|_e| URError::UrEncodeError(_e.to_string()))?;
- let target_path = path
- .child(ChildNumber::Normal { index: 0 })
- .child(ChildNumber::Normal { index: 0 });
- let key_path = CryptoKeyPath::new(
- target_path
- .into_iter()
- .map(|v| match v {
- ChildNumber::Normal { index } => get_path_component(Some(index.clone()), false),
- ChildNumber::Hardened { index } => get_path_component(Some(index.clone()), true),
- })
- .collect::<URResult<Vec<PathComponent>>>()?,
- Some(mfp),
- Some(xpub.depth as u32),
- );
- Ok(CryptoHDKey::new_extended_key(
- Some(false),
- _target_key.public_key.serialize().to_vec(),
- None,
- None,
- Some(key_path),
- None,
- Some(_target_key.parent_fingerprint.to_bytes()),
- Some("Keystone".to_string()),
- note,
- ))
-}
diff --git a/rust/apps/wallets/src/utils.rs b/rust/apps/wallets/src/utils.rs
index 3214a41..e07f293 100644
--- a/rust/apps/wallets/src/utils.rs
+++ b/rust/apps/wallets/src/utils.rs
@@ -52,7 +52,7 @@ pub fn generate_crypto_multi_accounts_sync_ur(
Some(origin),
None,
None,
- Some(format!("{}-{}", account_prefix, index)),
+ Some(format!("{account_prefix}-{index}")),
None,
);
keys.push(hd_key);
diff --git a/rust/apps/wallets/src/xrp_toolkit.rs b/rust/apps/wallets/src/xrp_toolkit.rs
index 903975c..e347d5f 100644
--- a/rust/apps/wallets/src/xrp_toolkit.rs
+++ b/rust/apps/wallets/src/xrp_toolkit.rs
@@ -16,7 +16,7 @@ pub fn generate_sync_ur(hd_path: &str, root_x_pub: &str, root_path: &str) -> URR
let sub_path = hd_path.strip_prefix(&root_path).unwrap();
if let (Ok(address), Ok(pubkey)) = (
get_address(hd_path, root_x_pub, root_path.as_str()),
- derive_public_key(&root_x_pub.to_string(), &format!("m/{}", sub_path)),
+ derive_public_key(&root_x_pub.to_string(), &format!("m/{sub_path}")),
) {
let v: Value = json!({
"address": address,
diff --git a/rust/apps/xrp/src/address/mod.rs b/rust/apps/xrp/src/address/mod.rs
index a764dc0..7dc4f92 100644
--- a/rust/apps/xrp/src/address/mod.rs
+++ b/rust/apps/xrp/src/address/mod.rs
@@ -16,7 +16,7 @@ pub fn get_address(hd_path: &str, root_x_pub: &str, root_path: &str) -> R<String
let sub_path = hd_path
.strip_prefix(&root_path)
.ok_or(XRPError::InvalidHDPath(hd_path.to_string()))?;
- let pubkey = derive_public_key(&root_x_pub.to_string(), &format!("m/{}", sub_path))?;
+ let pubkey = derive_public_key(&root_x_pub.to_string(), &format!("m/{sub_path}"))?;
derive_address(&pubkey.serialize())
}
diff --git a/rust/apps/xrp/src/address/ripple_address_codec.rs b/rust/apps/xrp/src/address/ripple_address_codec.rs
index ce21561..e704d3e 100644
--- a/rust/apps/xrp/src/address/ripple_address_codec.rs
+++ b/rust/apps/xrp/src/address/ripple_address_codec.rs
@@ -7,6 +7,7 @@ const ALPHABET: &str = "rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAx
struct Address;
+#[allow(unused)]
trait Settings {
const PAYLOAD_LEN: usize;
const PREFIX: &'static [u8] = &[];
diff --git a/rust/apps/xrp/src/errors.rs b/rust/apps/xrp/src/errors.rs
index 5927030..59f6141 100644
--- a/rust/apps/xrp/src/errors.rs
+++ b/rust/apps/xrp/src/errors.rs
@@ -24,30 +24,30 @@ pub type R<T> = Result<T, XRPError>;
impl From<KeystoreError> for XRPError {
fn from(value: KeystoreError) -> Self {
- Self::KeystoreError(format!("{}", value))
+ Self::KeystoreError(format!("{value}"))
}
}
impl From<Utf8Error> for XRPError {
fn from(value: Utf8Error) -> Self {
- Self::InvalidData(format!("utf8 operation failed {}", value))
+ Self::InvalidData(format!("utf8 operation failed {value}"))
}
}
impl From<hex::FromHexError> for XRPError {
fn from(value: hex::FromHexError) -> Self {
- Self::InvalidData(format!("hex operation failed {}", value))
+ Self::InvalidData(format!("hex operation failed {value}"))
}
}
impl From<serde_json::Error> for XRPError {
fn from(value: Error) -> Self {
- Self::InvalidData(format!("serde_json operation failed {}", value))
+ Self::InvalidData(format!("serde_json operation failed {value}"))
}
}
impl From<bitcoin::bip32::Error> for XRPError {
fn from(value: bitcoin::bip32::Error) -> Self {
- Self::InvalidData(format!("bip32 operation failed {}", value))
+ Self::InvalidData(format!("bip32 operation failed {value}"))
}
}
diff --git a/rust/apps/xrp/src/lib.rs b/rust/apps/xrp/src/lib.rs
index 866bf02..a7ed5f9 100644
--- a/rust/apps/xrp/src/lib.rs
+++ b/rust/apps/xrp/src/lib.rs
@@ -1,5 +1,4 @@
#![no_std]
-#![feature(error_in_core)]
extern crate alloc;
extern crate core;
#[cfg(test)]
@@ -59,10 +58,10 @@ pub fn get_pubkey_path(root_xpub: &str, pubkey: &str, max_i: u32) -> R<String> {
let pubkey_arr = hex::decode(pubkey)?;
let pubkey_bytes = pubkey_arr.as_slice();
for i in 0..max_i {
- let pk = a_xpub.derive_pub(&k1, &DerivationPath::from_str(&format!("m/{}", i))?)?;
+ let pk = a_xpub.derive_pub(&k1, &DerivationPath::from_str(&format!("m/{i}"))?)?;
let key = pk.public_key.serialize();
if key.eq(pubkey_bytes) {
- return Ok(format!("{}:m/0/{}", pubkey, i));
+ return Ok(format!("{pubkey}:m/0/{i}"));
}
}
Err(XRPError::InvalidData("pubkey not found".to_string()))
diff --git a/rust/apps/xrp/src/parser/mod.rs b/rust/apps/xrp/src/parser/mod.rs
index cff06ad..a73604f 100644
--- a/rust/apps/xrp/src/parser/mod.rs
+++ b/rust/apps/xrp/src/parser/mod.rs
@@ -60,12 +60,11 @@ impl ParsedXrpTx {
if let (Some(currency), Some(value)) =
(value["currency"].as_str(), value["value"].as_str())
{
- return Ok(format!("{} {}", value, currency));
+ return Ok(format!("{value} {currency}"));
}
}
Err(XRPError::ParseTxError(format!(
- "format amount failed {:?}",
- amount
+ "format amount failed {amount:?}"
)))
}
@@ -74,8 +73,7 @@ impl ParsedXrpTx {
return Ok(v.to_string());
}
Err(XRPError::ParseTxError(format!(
- "format field failed {:?}",
- field
+ "format field failed {field:?}"
)))
}
@@ -84,8 +82,7 @@ impl ParsedXrpTx {
return Ok(value);
}
Err(XRPError::ParseTxError(format!(
- "format field failed {:?}",
- sequence
+ "format field failed {sequence:?}"
)))
}
diff --git a/rust/apps/xrp/src/transaction/mod.rs b/rust/apps/xrp/src/transaction/mod.rs
index a001f9d..e230f83 100644
--- a/rust/apps/xrp/src/transaction/mod.rs
+++ b/rust/apps/xrp/src/transaction/mod.rs
@@ -22,7 +22,7 @@ impl WrappedTxData {
let signing_pubkey = tx_data["SigningPubKey"].as_str().unwrap_or("").to_string();
if let Some(tag) = tx_data["DestinationTag"].as_i64() {
if !(0..=0xffffffff).contains(&tag) {
- return Err(XRPError::SignFailure(format!("invalid tag {:?}", tag)));
+ return Err(XRPError::SignFailure(format!("invalid tag {tag:?}")));
}
}
let serialized_tx: String = rippled_binary_codec::serialize::serialize_tx(
diff --git a/rust/apps/zcash/src/errors.rs b/rust/apps/zcash/src/errors.rs
index 218f589..24d7179 100644
--- a/rust/apps/zcash/src/errors.rs
+++ b/rust/apps/zcash/src/errors.rs
@@ -19,12 +19,12 @@ pub enum ZcashError {
impl From<orchard::pczt::ParseError> for ZcashError {
fn from(e: orchard::pczt::ParseError) -> Self {
- Self::InvalidPczt(alloc::format!("Invalid Orchard bundle: {:?}", e))
+ Self::InvalidPczt(alloc::format!("Invalid Orchard bundle: {e:?}"))
}
}
impl From<transparent::pczt::ParseError> for ZcashError {
fn from(e: transparent::pczt::ParseError) -> Self {
- Self::InvalidPczt(alloc::format!("Invalid transparent bundle: {:?}", e))
+ Self::InvalidPczt(alloc::format!("Invalid transparent bundle: {e:?}"))
}
}
diff --git a/rust/apps/zcash/src/lib.rs b/rust/apps/zcash/src/lib.rs
index da127e8..2217c10 100644
--- a/rust/apps/zcash/src/lib.rs
+++ b/rust/apps/zcash/src/lib.rs
@@ -158,20 +158,20 @@ mod tests {
assert_eq!(orchard.get_from().len(), 1);
assert_eq!(orchard.get_to().len(), 1);
assert_eq!(
- transparent.get_to().get(0).unwrap().get_address(),
+ transparent.get_to().first().unwrap().get_address(),
"t1TMLJ7k2N4Narqk5Fd5uUo82NXSMbKRgCc"
);
- assert_eq!(transparent.get_to().get(0).unwrap().get_value(), "0.1 ZEC");
- assert_eq!(transparent.get_to().get(0).unwrap().get_is_change(), false);
- assert_eq!(orchard.get_from().get(0).unwrap().get_address(), None);
- assert_eq!(orchard.get_from().get(0).unwrap().get_value(), "0.12 ZEC");
- assert_eq!(orchard.get_from().get(0).unwrap().get_is_mine(), true);
+ assert_eq!(transparent.get_to().first().unwrap().get_value(), "0.1 ZEC");
+ assert!(!transparent.get_to().first().unwrap().get_is_change());
+ assert_eq!(orchard.get_from().first().unwrap().get_address(), None);
+ assert_eq!(orchard.get_from().first().unwrap().get_value(), "0.12 ZEC");
+ assert!(orchard.get_from().first().unwrap().get_is_mine());
assert_eq!(
- orchard.get_to().get(0).unwrap().get_address(),
+ orchard.get_to().first().unwrap().get_address(),
"<internal-address>"
);
- assert_eq!(orchard.get_to().get(0).unwrap().get_value(), "0.01985 ZEC");
- assert_eq!(orchard.get_to().get(0).unwrap().get_is_change(), true);
+ assert_eq!(orchard.get_to().first().unwrap().get_value(), "0.01985 ZEC");
+ assert!(orchard.get_to().first().unwrap().get_is_change());
assert_eq!(parsed_pczt.get_fee_value(), "0.00015 ZEC");
}
}
diff --git a/rust/apps/zcash/src/pczt/check.rs b/rust/apps/zcash/src/pczt/check.rs
index 80bee83..1566816 100644
--- a/rust/apps/zcash/src/pczt/check.rs
+++ b/rust/apps/zcash/src/pczt/check.rs
@@ -32,12 +32,12 @@ pub fn check_pczt<P: consensus::Parameters>(
check_orchard(params, seed_fingerprint, account_index, orchard, bundle)
.map_err(pczt::roles::verifier::OrchardError::Custom)
})
- .map_err(|e| ZcashError::InvalidDataError(alloc::format!("{:?}", e)))?
+ .map_err(|e| ZcashError::InvalidDataError(alloc::format!("{e:?}")))?
.with_transparent(|bundle| {
check_transparent(params, seed_fingerprint, account_index, xpub, bundle)
.map_err(pczt::roles::verifier::TransparentError::Custom)
})
- .map_err(|e| ZcashError::InvalidDataError(alloc::format!("{:?}", e)))?;
+ .map_err(|e| ZcashError::InvalidDataError(alloc::format!("{e:?}")))?;
Ok(())
}
@@ -284,7 +284,7 @@ fn check_action<P: consensus::Parameters>(
// Check `cv_net` first so we know that the `value` fields for both the spend and the
// output are present and correct.
action.verify_cv_net().map_err(|e| {
- ZcashError::InvalidPczt(alloc::format!("invalid cv_net in Orchard action: {:?}", e))
+ ZcashError::InvalidPczt(alloc::format!("invalid cv_net in Orchard action: {e:?}"))
})?;
check_action_spend(params, seed_fingerprint, account_index, fvk, action.spend())?;
@@ -322,10 +322,10 @@ fn check_action_spend<P: consensus::Parameters>(
if let Some(expected_fvk) = can_verify_nf_rk {
spend.verify_nullifier(expected_fvk).map_err(|e| {
- ZcashError::InvalidPczt(alloc::format!("invalid Orchard action nullifier: {:?}", e))
+ ZcashError::InvalidPczt(alloc::format!("invalid Orchard action nullifier: {e:?}"))
})?;
spend.verify_rk(expected_fvk).map_err(|e| {
- ZcashError::InvalidPczt(alloc::format!("invalid Orchard action rk: {:?}", e))
+ ZcashError::InvalidPczt(alloc::format!("invalid Orchard action rk: {e:?}"))
})?;
}
@@ -338,7 +338,7 @@ fn check_action_output(action: &orchard::pczt::Action) -> Result<(), ZcashError>
.output()
.verify_note_commitment(action.spend())
.map_err(|e| {
- ZcashError::InvalidPczt(alloc::format!("invalid Orchard action cmx: {:?}", e))
+ ZcashError::InvalidPczt(alloc::format!("invalid Orchard action cmx: {e:?}"))
})?;
// TODO: Currently the "can decrypt output" check is performed implicitly by
diff --git a/rust/apps/zcash/src/pczt/parse.rs b/rust/apps/zcash/src/pczt/parse.rs
index 1ed42f9..587099b 100644
--- a/rust/apps/zcash/src/pczt/parse.rs
+++ b/rust/apps/zcash/src/pczt/parse.rs
@@ -37,7 +37,7 @@ fn format_zec_value(value: f64) -> String {
.trim_end_matches('0')
.trim_end_matches('.')
.to_string();
- format!("{} ZEC", zec_value)
+ format!("{zec_value} ZEC")
}
/// Attempts to decrypt the output with the given `ovk`, or (if `None`) directly via the
@@ -129,13 +129,13 @@ pub fn parse_pczt<P: consensus::Parameters>(
.map_err(pczt::roles::verifier::OrchardError::Custom)?;
Ok(())
})
- .map_err(|e| ZcashError::InvalidDataError(alloc::format!("{:?}", e)))?
+ .map_err(|e| ZcashError::InvalidDataError(alloc::format!("{e:?}")))?
.with_transparent(|bundle| {
parsed_transparent = parse_transparent(params, seed_fingerprint, bundle)
.map_err(pczt::roles::verifier::TransparentError::Custom)?;
Ok(())
})
- .map_err(|e| ZcashError::InvalidDataError(alloc::format!("{:?}", e)))?;
+ .map_err(|e| ZcashError::InvalidDataError(alloc::format!("{e:?}")))?;
let mut total_input_value = 0;
let mut total_output_value = 0;
diff --git a/rust/apps/zcash/src/pczt/sign.rs b/rust/apps/zcash/src/pczt/sign.rs
index 76f643c..79b7576 100644
--- a/rust/apps/zcash/src/pczt/sign.rs
+++ b/rust/apps/zcash/src/pczt/sign.rs
@@ -64,11 +64,11 @@ impl PcztSigner for SeedSigner<'_> {
if let Some(path) = path {
let sk = get_private_key_by_seed(self.seed, &path).map_err(|e| {
- ZcashError::SigningError(alloc::format!("failed to get private key: {:?}", e))
+ ZcashError::SigningError(alloc::format!("failed to get private key: {e:?}"))
})?;
let secp = secp256k1::Secp256k1::new();
input.sign(index, hash, &sk, &secp).map_err(|e| {
- ZcashError::SigningError(alloc::format!("failed to sign input: {:?}", e))
+ ZcashError::SigningError(alloc::format!("failed to sign input: {e:?}"))
})?;
}
diff --git a/rust/keystore/src/algorithms/rsa/mod.rs b/rust/keystore/src/algorithms/rsa/mod.rs
index 0edef1d..eb5098d 100644
--- a/rust/keystore/src/algorithms/rsa/mod.rs
+++ b/rust/keystore/src/algorithms/rsa/mod.rs
@@ -148,9 +148,9 @@ mod tests {
use super::*;
use bitcoin::hex::DisplayHex;
use hex;
- use rsa::pkcs1v15::SigningKey;
- use rsa::signature::{Keypair, RandomizedSigner, SignatureEncoding, Verifier};
- use sha2::Sha256;
+
+
+
#[test]
fn test_private_key_recover() {
diff --git a/rust/keystore/src/algorithms/zcash/mod.rs b/rust/keystore/src/algorithms/zcash/mod.rs
index a089ef2..30d8ed0 100644
--- a/rust/keystore/src/algorithms/zcash/mod.rs
+++ b/rust/keystore/src/algorithms/zcash/mod.rs
@@ -100,7 +100,7 @@ mod tests {
zip32::AccountId,
};
- use zcash_vendor::orchard::keys::{FullViewingKey, SpendAuthorizingKey, SpendingKey};
+ use zcash_vendor::orchard::keys::{SpendAuthorizingKey, SpendingKey};
use zcash_vendor::pasta_curves::group::ff::PrimeField;
use hex;
@@ -108,7 +108,7 @@ mod tests {
use rand_chacha::ChaCha8Rng;
extern crate std;
- use std::println;
+
#[test]
fn test_ufvk_generation_and_encoding() {
diff --git a/rust/rust_c/build.rs b/rust/rust_c/build.rs
index fa75375..9c50e06 100644
--- a/rust/rust_c/build.rs
+++ b/rust/rust_c/build.rs
@@ -89,7 +89,7 @@ fn main() {
.with_config(config)
.generate()
.map_or_else(
- |error| {},
+ |_| {},
|bindings| {
bindings.write_to_file(output_target);
},
diff --git a/rust/rust_c/src/bitcoin/multi_sig/mod.rs b/rust/rust_c/src/bitcoin/multi_sig/mod.rs
index 58b5598..6301370 100644
--- a/rust/rust_c/src/bitcoin/multi_sig/mod.rs
+++ b/rust/rust_c/src/bitcoin/multi_sig/mod.rs
@@ -150,13 +150,13 @@ pub extern "C" fn export_multi_sig_wallet_by_ur_test(
pub unsafe extern "C" fn export_xpub_info_by_ur(
ur: PtrUR,
multi_sig_type: MultiSigFormatType,
- viewType: ViewType,
+ view_type: ViewType,
) -> Ptr<Response<MultiSigXPubInfoItem>> {
- match viewType {
+ match view_type {
ViewType::MultisigCryptoImportXpub => {
let crypto_account = extract_ptr_with_type!(ur, CryptoAccount);
let result =
- extract_xpub_info_from_crypto_account(&crypto_account, multi_sig_type.into());
+ extract_xpub_info_from_crypto_account(crypto_account, multi_sig_type.into());
match result {
Ok(wallet) => {
Response::success_ptr(MultiSigXPubInfoItem::from(wallet).c_ptr()).c_ptr()
diff --git a/rust/rust_c/src/bitcoin/psbt.rs b/rust/rust_c/src/bitcoin/psbt.rs
index e1f0b8c..47f0c18 100644
--- a/rust/rust_c/src/bitcoin/psbt.rs
+++ b/rust/rust_c/src/bitcoin/psbt.rs
@@ -407,7 +407,8 @@ pub unsafe extern "C" fn utxo_check_psbt_extend(
#[no_mangle]
pub unsafe extern "C" fn btc_check_psbt_bytes(
- ptr: PtrUR,
+ psbt_bytes: PtrBytes,
+ psbt_bytes_length: u32,
master_fingerprint: PtrBytes,
length: u32,
public_keys: PtrT<CSliceFFI<ExtendedPublicKey>>,
@@ -417,8 +418,11 @@ pub unsafe extern "C" fn btc_check_psbt_bytes(
if length != 4 {
return TransactionCheckResult::from(RustCError::InvalidMasterFingerprint).c_ptr();
}
- let crypto_psbt = extract_ptr_with_type!(ptr, CryptoPSBT);
- let psbt = crypto_psbt.get_psbt();
+ let psbt = extract_array!(psbt_bytes, u8, psbt_bytes_length as usize);
+ let psbt = match get_psbt_bytes(psbt) {
+ Ok(psbt) => psbt,
+ Err(e) => return TransactionCheckResult::from(e).c_ptr(),
+ };
btc_check_psbt_common(
psbt,
@@ -666,8 +670,7 @@ fn get_psbt_bytes(psbt_bytes: &[u8]) -> Result<Vec<u8>, RustCError> {
}
}
-#[no_mangle]
-pub unsafe extern "C" fn utxo_sign_psbt_extend_dynamic(
+unsafe fn utxo_sign_psbt_extend_dynamic(
psbt: Vec<u8>,
seed: PtrBytes,
seed_len: u32,
diff --git a/rust/rust_c/src/iota/structs.rs b/rust/rust_c/src/iota/structs.rs
index 761b1f5..4733049 100644
--- a/rust/rust_c/src/iota/structs.rs
+++ b/rust/rust_c/src/iota/structs.rs
@@ -255,7 +255,7 @@ impl Free for DisplayIotaSignMessageHash {
}
}
-make_free_method!(DisplayIotaSignMessageHash);
+make_free_method!(TransactionParseResult<DisplayIotaSignMessageHash>);
impl Free for DisplayIotaIntentData {
unsafe fn free(&self) {
diff --git a/rust/rust_c/src/wallet/cypherpunk_wallet/cake.rs b/rust/rust_c/src/wallet/cypherpunk_wallet/cake.rs
index bdd65c8..ae62444 100644
--- a/rust/rust_c/src/wallet/cypherpunk_wallet/cake.rs
+++ b/rust/rust_c/src/wallet/cypherpunk_wallet/cake.rs
@@ -33,14 +33,14 @@ fn safe_parse_pincode(pincode: PtrBytes) -> Result<[u8; 6], RustCError> {
}
fn generate_wallet_result(
- primaryAddress: String,
- privateViewKey: String,
+ primary_address: String,
+ private_view_key: String,
is_encrypted: bool,
) -> UREncodeResult {
let result = json!({
"version": 0,
- "primaryAddress": primaryAddress,
- "privateViewKey": privateViewKey,
+ "primaryAddress": primary_address,
+ "privateViewKey": private_view_key,
"restoreHeight": 0,
"encrypted": is_encrypted,
"source": "Keystone"
diff --git a/rust/sim_qr_reader/src/lib.rs b/rust/sim_qr_reader/src/lib.rs
index 05f0612..76ed5ff 100644
--- a/rust/sim_qr_reader/src/lib.rs
+++ b/rust/sim_qr_reader/src/lib.rs
@@ -50,7 +50,7 @@ where
let mut decoder = Quirc::default();
let scaling_factor = get_screen_scaling_factor();
- println!("Screen scaling factor: {}", scaling_factor);
+ println!("Screen scaling factor: {scaling_factor}");
let mut qr_area: Option<(i32, i32, u32, u32)> = None;
@@ -63,8 +63,7 @@ where
let scaled_width = (width as f64 / scaling_factor) as u32;
let scaled_height = (height as f64 / scaling_factor) as u32;
println!(
- "Capture area: ({}, {}, {}, {})",
- scaled_x, scaled_y, scaled_width, scaled_height
+ "Capture area: ({scaled_x}, {scaled_y}, {scaled_width}, {scaled_height})"
);
screen.capture_area(scaled_x, scaled_y, scaled_width, scaled_height)?
}
@@ -92,7 +91,7 @@ where
let mut loop_count = 0;
while loop_count < max_loop_count {
- println!("Loop count: {}, max: {}", loop_count, max_loop_count);
+ println!("Loop count: {loop_count}, max: {max_loop_count}");
match capture_and_decode(qr_area) {
Ok((content, new_area)) => {
if on_qr_code_detected(&content) {
@@ -102,7 +101,7 @@ where
qr_area = new_area;
}
if let Some(area) = qr_area {
- println!("QR code area determined: {:?}", area);
+ println!("QR code area determined: {area:?}");
}
}
Err(_) => {
diff --git a/rust/zcash_vendor/src/pczt_ext.rs b/rust/zcash_vendor/src/pczt_ext.rs
index 00e092e..25032ff 100644
--- a/rust/zcash_vendor/src/pczt_ext.rs
+++ b/rust/zcash_vendor/src/pczt_ext.rs
@@ -301,15 +301,11 @@ fn sheilded_sig_commitment(pczt: &Pczt, lock_time: u32, input_info: Option<Signa
let sig_digest = transparent_sig_digest(pczt, input_info);
h.update(sig_digest.as_bytes());
h.update(
- has_sapling(pczt)
- .then(|| digest_sapling(pczt))
- .unwrap_or_else(hash_sapling_txid_empty)
+ if has_sapling(pczt) { digest_sapling(pczt) } else { hash_sapling_txid_empty() }
.as_bytes(),
);
h.update(
- has_orchard(pczt)
- .then(|| digest_orchard(pczt))
- .unwrap_or_else(hash_orchard_txid_empty)
+ if has_orchard(pczt) { digest_orchard(pczt) } else { hash_orchard_txid_empty() }
.as_bytes(),
);
h.finalize()
@@ -456,24 +452,24 @@ mod tests {
//orchard to orchard
let pczt_hex = "50435a5401000000058ace9cb502d5a09cc70c010082efad01850100000000000000fbc2f4300c01f0b7820d00e3347c8da4ee614674376cbc45359daa54f9b5493e010000000000000000000000000000000000000000000000000000000000000000027c44511582af6b5e43e3ab36c3ab1e0c2997d8e6b7809ccccdbc212a6a359a39aef8e1290671b922d3a8468de66fc9281dfdf30f5518fd69bdb9652ccaf9280593ba8cb150ee5473d6a98a61581791bacbef4b23d3ae8b60a808f4321b0ccdbf00017390fedb30aa721eb96ca33f1a7da10f9900e21ef8f4ab7e15d744edc60dcdc1a4c9debe9fd9a8b2cf56b90180ade20401e959b1bef8243433317a2c69fc1167f12528cdae5d9c2a19f925a5a3114c7f2801d2d4de02e32e57569d8a25bc3254545c58d8f41e22b1e0f75128e92601ce09a60183ceb48bb24a4debb403c3cc02043f5157ec4f084b8fb359a58f53ab4cd3741b339461f1504081a0765b12b87cac9c4a3baa55b155192d3cfd98a7517b8a59019744b22b89ba0daaa32de9d883a727be7e2ca09446f87efe0e5b29ce98c65f19000192ca4017b375e36aa0a58aa94a644e44964245190a20e40a479b229535df0c0c01af5d9c247e91d0cbf603f6f6f49cfc218eabf9a2c1d886ce94fc167d6da7e66403a080808008858180800880808080080000ea1fb4757517b5726c2968b11fb287644589749f5aab3bcfaf380cae003b1a0cf9b3db1aeee6eba391326b324470bccb0f155a9a9a2750188f9e29ea263bb9bcc4046a98d226a6a2ea117f7b9eb85d8456843f02edc96507cb22213aeeaf7038f014a3b8197e649b886bad2c9a2c7cba19b17f6800825c63dc1740959d25f1affdda6d7e3657da22cdfa9ddf5c6cb45a4d744c1e150697db5b6766daf235d92c52ef3088eddb73c5020f612796cebd02b404a498332a875f6f3c3c0875139708c9e0a430573cf040304d3060049fe464b212a520c79c2bce30635b3c258d4ff00368bfddeafe1c77204db3c3eaf7f037383f43faba6325c3d22635372d62baf3cef53d9729067826652f26f9731d6338887fc902155ec57e85d16d001535aeb3dfd34375cf8109d2c7340e291ed3d0a6e6e4905dfdeb5c6638954b28587ae7e88c6aec3fe71b83ef973d9083c1eaedf5c782919ed9ac5c1d6485bd1acef2cdc8af172d289b27f0f0c32a4196b2dd9ef4e5f40176f5baf432d22dcf7eb7d506c3501cd40b7dd352263207525e03607fbf4b19d0a7db480e0f4aa26ac7c1a7d8335c3de0927a20aabd267872ed19fd52730a5b3f52f92957bce0b97354b7b1b39216163bdac02467f054446e72afafea3dffe85ef524c4092fe74732fcf4dc47bb084fc7c9407ba2ff0eab28af33b12c0b4ef1b4743f518521a8301f2c900c6bc88f631a591f953ea4cbfe7e8131aed76eb0292b12db2ae879d3407030dbaa650749b6fe92ab0790b52362dc9be3899729e10282f8cdf37fd026cba7ef5c6668a5a5c346fd57f96991f874a738ff7437f3c2da90117e99f0bde461784e3fc22ed4d3af23953485722436d4c51d3bd474c457dfbaa8b8dbb65dcec841a85ce9726f5a56eca822be50564ed3670e7259460b54cf9179387bc50b43f45cc75869b510c331444a199f3caeb7d1674d023880cc3b287afb2914bc5038e2db4b08efe0752d54f0edd31d44d3020fc1d81e9f36b4414bb871c0476c01d288df138de809fa058e8b7b240650cb1aae966ea3614fc54db414e8294066e8936b02d96b006cbfffc52701c0843d010d8a10e45671953357c419835d685db7462c67678b9d2c618e237aad4ddd0948000001d501753163637868356e7274366132656d6838687473793461673263397638666c6d786e61733537727468656c6d6377676e76397534766864747575703571646e3570676e6537766a736c35373673337a7333646b63386771377638756c68346573646a746a64727a6c65377138633237723934773672707061726a3737726b6a7633677076703964646a79687838307276756e7767677a646d716a65366e3973723466676e6d777a75656c646c793568707339746c6672796b656179356a6a6d343272773379777966367264716538327734326a737300019f9736e85c4df8db84a6c16f7ab547290055182038e33e1ecef672a0aabe5d0075ac53737630399b01fbaae346e017c15d2ab2af798e268f1f03ceaf6fca6f02643f09ad24e0595215a8ee3e2b51a79ed8550c1b9ee1280082aae3268a0b161abe47b6f2e823adc61207d2f0ca7831e6f2c62af9c3ab8c3d7f5110c39799e88101ef86dd3a4ef054afd8728204cef346bc8118847985075fee7cf3420b1c6589383bab1a24973a0a633a7260c3d9f455391a760814924d569d853f257ed70d0c2f017a3779a010062bb8936ec2ee5dd49d45803bda6b23debad15e557cc56b4682e2338d757001c9cd76a74e2501000178b41d35aaafb6cfe0ebca3394908dd1a7d470a8be71eabeda361b5002c1a23e010af9f077b558d4e71f09ba56c91562adcc550feff26d9b53e1c6600ae0ec7b6e01118945457852e7765e9c7ffa8f154e3b7bd9e485ca81419d7d662628609e5c1eaf1095a229485256020ff1dfc5f00bdf3d43a8150f958542dfba8a792d935b2a48440dd87abcceb2f73bd3d5104ce0cebd86b9ea5f7b69ff6f67f9bc37206a03000151c4407a8eb1f5fedfda4f3ad969e057da950af38b4f1fdcc17574258bc0e33e00000064bca5dfa19fcfeaa4c0f32547b945c53d7492002ea01d5cafc38b5b29afa21b378f4b30c10f2561ff28ece62d5d53bd0f65af67312836c0c1da2bff357af690c404a214d4b126ffbb847fd825cd69e467342e77c8be8ed5ec578f2db0bee6753bd134f819e1053dab1fcb1d58375477ff15234cabb528d174f66476c3dc3fedbafd16c63f62f30176a9c7c0d85516150379d77bf0d9510726f6dd5d3e1dd20a77b32124fd6e7012958d7dfef9d73781ae15a89e5f3d45b8b2e322e5da87721c05135307aa0ab047f7ee71031de0bf9f6d5192e2e1a0b370e8d16daacf9565460332e7e6758de3b59b5fbf585f3ef231da5d8cd3574b5c8eab4ea0368111fd3e39f642cfbd020d10959d60d1ceb21247efba84040a0c3e6b722ec5524a2928418cc321c44a5f74e28cdbe3b484459230c668cf876bd13f7db32d571b756d976ef844023a4c0146108ed1a4e8d9318dbc2cde5de055c6b69f7cb01b869f76b41ac3ebd59a07cae039571c3a67307de946ce5e28652aea2835e934c94fd231889fe9e0cbb5920a1930867e229e04f255ef0cb11e8397aa9fcd4a5b032fe6aea6e920a97f20e3dccf8563f1ffbaee4dc607ef977f95704d855ada4b6bec066ce92bac969bb7f615b8ded28a326b65bbd63be1d7a69d4a5b9903b51b351b563b17d0c469dceff53dfb775886bd1e8c47d8deb95ab2d0478d14ab2311334af47dc33c42061ecff5b476aaef385dfab49fe2444e842a521f62472284d95f0573c6d5d812fb27d83bf0a6f113e78c8de378a7b71143f766a3d303085d7af51dba4ac80937e9e1256246a755e664ff24babb099122c6aa31f4b340b6a4b7a0e9601f244cb030a8624b2bf46942fba2bf1ac15d21263bafa8d648ce1586beb43f0d9f2225addfed115c0a501fc5f856412572e53e4cb3fc6fd9b35761a3d34306b535f8eb86634ebd4274a6d9dc8c6328955722ec2f48a838046cc22f4622a79213ea88e73471a1c75dddfad71e8bae58ee08bbc74ea61a754f17c30138369b5a129c5592507890680300364a6193ec81f4d59f5c7418728f9416731f5ef0f085368010a525a7a001b0daa40401aeeb72da7e5b6b08d443d0d705cbf7e173e02be1d9b1b30f5e9c8cdd4228f6d300000000017d0607eac901c56a1b00d9aa4e1841c0811830c30d3d69b48e362c72e4a9ba0703904e006702c684eca9a8b72d603d306af1f699408e76798fc2bd69c86a67e08253fe1200011c9e3dd2264fbd46a0a69a1ac9cd88e9816d48e34520a8d25c2d9f128f681808";
let pczt = Pczt::parse(&hex::decode(pczt_hex).unwrap()).unwrap();
- assert_eq!(has_transparent(&pczt), false);
- assert_eq!(is_transparent_coinbase(&pczt), false);
- assert_eq!(has_sapling(&pczt), false);
- assert_eq!(has_orchard(&pczt), true);
+ assert!(!has_transparent(&pczt));
+ assert!(!is_transparent_coinbase(&pczt));
+ assert!(!has_sapling(&pczt));
+ assert!(has_orchard(&pczt));
assert_eq!(
hex::encode(digest_header(&pczt, 0).as_bytes()),
"3f85a5b3ff138bde71704243213f0cdd8d7483832dc4c2007c0f15fc2e3d17eb"
);
assert_eq!(
- hex::encode(digest_transparent_prevouts(&pczt.transparent().inputs()).as_bytes()),
+ hex::encode(digest_transparent_prevouts(pczt.transparent().inputs()).as_bytes()),
"a04b16834dc939ccf632d15dddaa6bcaed253d12068dca169fbd28bc403cf3ba"
);
assert_eq!(
- hex::encode(digest_transparent_sequence(&pczt.transparent().inputs()).as_bytes()),
+ hex::encode(digest_transparent_sequence(pczt.transparent().inputs()).as_bytes()),
"3a0033336603235001742438238d713c09c1c55bf67bd20b80805aea0b46eba5"
);
assert_eq!(
- hex::encode(digest_transparent_outputs(&pczt.transparent().outputs()).as_bytes()),
+ hex::encode(digest_transparent_outputs(pczt.transparent().outputs()).as_bytes()),
"25f311cc149ecccef0e8ca8c9facd897ef88806008bc15818069470db9f84a37"
);
assert_eq!(
@@ -494,24 +490,24 @@ mod tests {
fn test_basic_functions_transparent2orchard() {
let pczt_hex = "50435a5401000000058ace9cb502d5a09cc70c0100ebf0ad0185010000025acf12ca226205024695507ed5da494d7900957792d312cd4fe4fecaa04d1ee10000000000c08db7011976a914840418dfb50329ec38a21f869e63ccb4d5d9ef2d88ac00000101035fd07149bf45a6bf1edd52817e57e637228afbe79732fbfb4a293d58aad45cecaf5d9c247e91d0cbf603f6f6f49cfc218eabf9a2c1d886ce94fc167d6da7e66405ac8080800885818080088080808008000000000000009572f7a4fd81fc04ddaff4deb1073cf96db3834fa34afc7cc9719e21d47c9f570000000000c0a8a5041976a914840418dfb50329ec38a21f869e63ccb4d5d9ef2d88ac00000101035fd07149bf45a6bf1edd52817e57e637228afbe79732fbfb4a293d58aad45cecaf5d9c247e91d0cbf603f6f6f49cfc218eabf9a2c1d886ce94fc167d6da7e66405ac80808008858180800880808080080000000000000000000000fbc2f4300c01f0b7820d00e3347c8da4ee614674376cbc45359daa54f9b5493e01000000000000000000000000000000000000000000000000000000000000000002e45d04f3d7a562c6a1794e5e89cf8f36163ab6883f3d8b353e2083bcb1b2249e35a6c9941ef00d0ae9ee84a0e1b3f0856f589f89c67ff6d2d3d0123242373305626c5fd324a19134789116eb2682afc7a03226e308fbc5c2f96e826868b6651a01d4ba7b75d4266bb789a2aadf544d1052b02f34a3fde7d1feb4e22f2fc579598d14d5f12d5867be9b938d18c4424d3e92a89a8581cae7056a42f144ac42f94a060106467650ee9f96ec2ea6f71580e743b645a5b6c9d19c25cb816cc6e7b7747958b3a4576929698dc873d6a3010001ea94578a626ca4e5621fc4407b206fdff0af992ac501ede7c120cf976bc78a1f0169d74e5472fdd307c5eaf279fe330dc7edfba8f111cd870cd92ab08413b1ff8a01c767e69d2d93ff9d6e88ebacd5b91181271470782bdd4db149b6b0695ec76b0c49e471efcf295a933584261e6ff9d979a7d87b748ace5040ee39cd65765afa0adb5325b76e95d75482224edaa7f12e7f908361a0db283647585efe4607839e280001ae6ae6ba850b89ff2c8cc83799472a90ae3b45d119d43a667f24454c93932f2d00000082bfa85adfe80b71cc73aec7412401f7649582cde529cd8029c1359a75dd831d730b61d4e33a37bd22501d591b170bbb80c26e0abb07e477f0953fc2e04110adc40489487a0e18b14486ab2189631d565186c3918d7dfbfbfb6484579850ffa1576b74c5f6206a97f06ab413596e97b2f2b520973bf4517daadae99268d927d27d2457f6be435b6809abbf237955cd07746a7ddf6c0f630ca7ffcabcf05848c111480cbb57ac013985a1f83ac56440ef3f85b1ad72db48c287650758723d56c6881e0cc45d9022ef6d8b3102d65f3231401a7ff7307bc7ddba41f8a1bf440e5c67363b7e28078102b3e04dab3e74933fb0abbda260de62cc480cc76945478d151536b7e26d121873db53dee1a6b89a755605d4c608da0af5844c6dab152b4716093cd4294b1110d4083254fbd7d3f04395ebb52a634f37118b8bf04762bd9179871649c30a723d3eeb7d03949ccaebff60fb385d8d29690ed2472b26c7486462033bf37d4d1ab691b7373a33d6ad043bbfbf9e7a3e01554de639f2c920de8a0af1a12ef2114b5f7545afffa7d85d03ba0421ab5a90734b49c5de39dd7581735bfaa9e5e7685c75c2c5891824ea6b7c36e298a09c56c68de639928cef69850ac8c648bf59edd29caa45b4bef19e93b5c63d71edc97b211480e504af05ac7ea654cef2e13ea3908639f91980f79d148f2c24df46b48632196fa4f760c2e460a6a0a29d6cb0d9a3e2458f0c674089085e0dd9f675377a055132e422dc588f11a7d7c45e11708b4bfb6ab81c134d4ba37cb4a5da09baebbdcf64aaf27f9e6197405494c348c1fe5343f3a5e7957cc6ea9002d90baac76efd6c06988241772b01c512c3b7d5390f3a284833f74effd56ac3723e05b8fa8340da1d6d4a71c4ecaa5762550bdd9ab94550040ed0209b2649245ece137b5f709565f2396d3c79626e640013e16c8112f9a8d046f172464f5be6f76cff56c5c0ebae70d5188b78509b254956b08d76278ac0a93d3338cecb8b233b67a76da168ab010138369b5a129c5592507890680300364a6193ec81f4d59f5c7418728f9416731f5ef0f085368010a525a7a001e099db05016e798c3a068d860dbd0fbf8493f6a495b930b0910dfc9c80da042ee324af8658000000000135049ad6155472f47f4f6c71922caeeec0394f3938a06b2b7fbd27429d78750fd7243a84ff4c759b869f132f939d063d6067f435161bf70bc1c59fea8b38043d45af9e07e68fc4ea58021d1aa8d30b6162fe67c07e60801c33fdc2f14d2c8806e3804c6b1dd4e056185fc25a52820fa5be87656184e00ae49a295d3f362e2baf01f6897096c00f6f4d1f26adc5779903cd07f546a7355499c9a3522724e749aa9edd5ee16e6218b875f79f7ad1c9681177089469549418b4e4f360da5d60a2fb1c015ac82c56f5f22c5cb06d376cd31a257af081ddf79e1448cc7e4654060269cdfd0ac38a2b6c0510bf9e951a01000144725db55f1eef840698c8393450e035c68ede9e914e88453081e045cef34705015cbaa9fb333b10a11d6b98a8ed6f315e36b8f38bfde610806859820a0e87b9c901833fe595747cc0971b28efdb3457c5e2b3ded473485b6f2cc62514e444ea1d0f352e72e22d112bf0407f39572e889ec95cbbdc03e60b14c50f11bf541d457a0745b4b2ede6365538357f51f0fa7f3e9c001389aaf09eedf2824072c50ffdff0e0001506ab89ec073252918bdbefe6298cfee59496c0a52218b8360784de1dc15b43c000000c60cff359faf5712e4894a98862943502a899561525e0f97c0b899c30feafa2604cb447292efc54926c2f9677df030c13808d20bcaed3ad7c727f6764bbb9e86c404feda6d3f41d8c82d02376c7e3437a4ebb9084a985e8a0d085aa470e339d2f8c05988cf53c44cf24e34e738332364aee390cdaa25f478602ca7d83e9964bc31a66ab50683c40bce9f81bd51846f13bfebce2821f4142b319406c4d90eab508bc123e52b30c2d308421e71860eed0a59e43a1aca227ce7e54d9423920709b096d628ca56f8c09c846720808d453cedc856e9cbf804cef1d68abbd614759f8f31cd1784b753baaa70cae727d4f82bc590386bc1bea84e0906367f99d45cfeb68bc8e30b195c601affca838aad5fa7f481612ab4d731162af7db44c096c2313720d52f79a2c617e0916f859ce288c1b055bb590046be19627515e268bfe01a23953dbf55c03e3ae8705d638ce9fb08f53eba34937ef4a2bb35ca6c2f428a469e4db5e97dec974ab583451eb5067d031642e27e655155e77d34a2ad8393737df5ba88d2d4ce7c5db62c762b93eda05a431d2b2cf9a4cd30a4f14579d8f8f2948dd15193706455b5a42b790578bcc8296d2e80a87a50add4950985f2dcc3c9e70221c5141d14a23ce9e6a20d6463326ca51d703f3a81c79545080b99e1f048f6ad5b40da8c57e088c3a6e77ea1811f68d2e9187e188075ec39e4469d67e0a45920e4bc45d29d8544b3bf4b9bf914df374cd449e75732c9f2543026fc220fc3365e6bf5c18f087d15083326184c55bc53fa18c8a51af0131070c1de84d837f00cca36929596fda18560d026170c66d69611fbb18b2f1b1443b68abad8de29c160588e3e2fd549687ee5825ed52119030f59679a5078855532f90b2cff7e00db6616118ca6fda1e3504057a7e67b05025c1f1cf7151fbcd3c860946485f2c936283dea193f3e0aab4c9c9280661212be0e5e7e0085be33e234b21b94eac0fa1db03e563227422f67670747aa2a6bc57226f1ca6c4535926e29011d1274b41a693712d5f50baea17a14534be815ef2261b84847e49e6636ccbaf1f48d4b5efd6612824208a7010001e1450753fdabb3d1e6cb965985bda36d6237bfd06ac24f287fe154f8dad5effb0000000001b95a1022e76e6138181e5eb33770ad25c198fdb874ca1ad2310dd05244e56b1803e099db0501ae2935f1dfd8a24aed7c70df7de3a668eb7a49b1319880dde2bbd9031ae5d82f0001ee5eaaf8fcc2d32c986dca24ca9c5b1482d24cf2ac6a86fdb0caf794e15de127";
let pczt = Pczt::parse(&hex::decode(pczt_hex).unwrap()).unwrap();
- assert_eq!(has_transparent(&pczt), true);
- assert_eq!(is_transparent_coinbase(&pczt), false);
- assert_eq!(has_sapling(&pczt), false);
- assert_eq!(has_orchard(&pczt), true);
+ assert!(has_transparent(&pczt));
+ assert!(!is_transparent_coinbase(&pczt));
+ assert!(!has_sapling(&pczt));
+ assert!(has_orchard(&pczt));
assert_eq!(
hex::encode(digest_header(&pczt, 0).as_bytes()),
"b17f07724f36f3cfe54140d9225d853a9246f4e4cfea722b583fdb151f005f76"
);
assert_eq!(
- hex::encode(digest_transparent_prevouts(&pczt.transparent().inputs()).as_bytes()),
+ hex::encode(digest_transparent_prevouts(pczt.transparent().inputs()).as_bytes()),
"8c34a460a39541d94e062f481e45495c90f3420b39ea0b4ecc45d55485c28c8b"
);
assert_eq!(
- hex::encode(digest_transparent_sequence(&pczt.transparent().inputs()).as_bytes()),
+ hex::encode(digest_transparent_sequence(pczt.transparent().inputs()).as_bytes()),
"7b0e9ba5bfc487e7471c657ef3cb743f90c7548c3fdcc355dc267559394c1bc1"
);
assert_eq!(
- hex::encode(digest_transparent_outputs(&pczt.transparent().outputs()).as_bytes()),
+ hex::encode(digest_transparent_outputs(pczt.transparent().outputs()).as_bytes()),
"25f311cc149ecccef0e8ca8c9facd897ef88806008bc15818069470db9f84a37"
);
assert_eq!(
@@ -534,7 +530,7 @@ mod tests {
0,
&script_code,
&script_code,
- Zatoshis::from_u64(pczt.transparent().inputs()[0].value().clone()).unwrap(),
+ Zatoshis::from_u64(*pczt.transparent().inputs()[0].value()).unwrap(),
);
assert_eq!(
hex::encode(sheilded_sig_commitment(&pczt, 0, Some(signable_input)).as_bytes()),
@@ -546,7 +542,7 @@ mod tests {
1,
&script_code,
&script_code,
- Zatoshis::from_u64(pczt.transparent().inputs()[1].value().clone()).unwrap(),
+ Zatoshis::from_u64(*pczt.transparent().inputs()[1].value()).unwrap(),
);
assert_eq!(
hex::encode(sheilded_sig_commitment(&pczt, 0, Some(signable_input2)).as_bytes()),
@@ -558,24 +554,24 @@ mod tests {
fn test_basic_functions_orchard2transparent() {
let pczt_hex = "50435a5401000000058ace9cb502d5a09cc70c0100a6f0ad01850100000001c0a8a5041976a914840418dfb50329ec38a21f869e63ccb4d5d9ef2d88ac000001237431567565374c47704756654b71635a77346657517472487250654d705a70767a554d00000000fbc2f4300c01f0b7820d00e3347c8da4ee614674376cbc45359daa54f9b5493e0100000000000000000000000000000000000000000000000000000000000000000228f7d939331e2b57f59159b23257b15ff8b62eedcc199204202a504e35039b18aef8e1290671b922d3a8468de66fc9281dfdf30f5518fd69bdb9652ccaf928054984ddfa67257d5ce17f00e4f617bc7473633d591a06b908b2ebdbe7c991173100017390fedb30aa721eb96ca33f1a7da10f9900e21ef8f4ab7e15d744edc60dcdc1a4c9debe9fd9a8b2cf56b90180ade20401e959b1bef8243433317a2c69fc1167f12528cdae5d9c2a19f925a5a3114c7f2801d2d4de02e32e57569d8a25bc3254545c58d8f41e22b1e0f75128e92601ce09a60183ceb48bb24a4debb403c3cc02043f5157ec4f084b8fb359a58f53ab4cd3741b339461f1504081a0765b12b87cac9c4a3baa55b155192d3cfd98a7517b8a59019744b22b89ba0daaa32de9d883a727be7e2ca09446f87efe0e5b29ce98c65f1900015b5ea077873b8e99f4d4d5764814aedc404dfac1bd1595038f416c242627d10901af5d9c247e91d0cbf603f6f6f49cfc218eabf9a2c1d886ce94fc167d6da7e66403a080808008858180800880808080080000263260db365ce227e49b6fc82f3421d43f6e5015140108b6dfbfa8922b453820127bb102f72a0fa8952c1f48309f3555e5dc11596afcf833575cab33c45b07bcc404dac1fce71b7237ae028b033dccfcb48daa80fcfe7fac5f654b6f71fc504f106e5da90e587458cc8085c30aa589f7b8f3463eef7fbef615ed7d299fa510660dc6273a75e5834a3526aeeea392c3ade636780322369ca451603aaa09cf96c6da65b4d97d8b21a780fbba10f33f2b813042c1f98218164df6c605a51a7b2600b879efe3b46ddee584ce036e8d3acad4da581d7a5d0e85286b3958564f8f57b24ca256c7d22243047c817823751bab9f8dd2d927982234a68cba68b8333fc2fb910dff308460d320c1a00f6c81f1c8aebee041e09a5aaac6961d50694def0f550b471a993d739fe55ab951886d2a66cd68b980ac03fe26bbb47ceabdc1e1964f44dc24766dcaa601ea6ed936ea9b18f97e964e042c97a25e5a396b5b51cec8aaf0d317bbdcf618939e6f5abf8afa233ab4e93c31ab9279a85404d78f8a246cde211f3cf3f28a617943c226e2176893b2df222ff868c8b3562b1bd2486df4eb5d2efec1dc1637225d76a9fa871ecadb0d11c243899a5cf4ecc3a9e35579f1356a3ccf11a13b3f9cb5dff8da3a1d860671ace6bfe0f1517d78f076785dc4dc6da5dd90a031af65ab7fc6ceb752e38211976785f99df62fe3870f92b14de895bfef4c4a83e047186ae048b1d63c37b3d359ab1f6c43f99f2e9d1aee5cd23e681219d1eaca638a9a3e21041898f69d135c0a764b7651dcd42518346ce982f4c2db58a1db132d154865fe5f519c6cf3a5b313b59e5707f1c44155f8e7ff4d0032e0974dbef293fb30b358e78c3d84afe5975ca3eae931d845791c5fd6f2934bc2d688eb8435071f1750f0d443b7525b522cba196af504f942867549d86f7be547762e0e2ffb15a980b0a45442a5e77024ecc7d3bc4b2b2f816807821e060c78a24b618e44fd72554d562ed1593f613085f38436728f3790c09d0138369b5a129c5592507890680300364a6193ec81f4d59f5c7418728f9416731f5ef0f085368010a525a7a001a88f3c01fffe88188356ab88a1b657a35a61486f5fb98eec1049b7f04c5f51bbd8cf8b86000000000131a63c58f332274cc0c4e2cec543ed76f0e910eed117c891908ae6448cdb243d391626d82709a53b72bcc726e410d5f2715c086e533b030b991d74f1ebfbbc8b5bbaaba0dc8d344af826e55ef1e4ba402c5ff1f2a07f9ba7aa8da838a1ce902757e5927cb50ee58e55e38e395e72bc567344a9f6e0721507d8f938aec1042fbd0173e74b82eea12d8febce6317d925d0c39c814e6122981e3e665b7c012873a0ae18332aea7e3714b22a18ef3cf27c569ba177e7d18b8c5b934b004c20beeac00401cea03ba224c78cebbcc29aab7e0d9443a24bcacb6a52f96b25d8f4af6308cf3e4c7990fc442a31a348663c0100019d9eae30a3a59d4fe08ad61836b1cfaaa23a76053d9b26179093737f30adf43301d225bd908d85e143de5cbaf98423bc0c3735c77b46225aff10d0e2b6471a2a5201af9626d26a9f6d86cd208c9753d8462b4b7929699484ffe54bfa629f85a9e0283e64b6ac0f6ad307b99006c8fdba71450ad99487fb7e6a00a3ae9b6c85e51b229797292c3f8e260b67b25d5906f614926828fd1a974ac262cfa0d6b011187f1f0001d6e40e658731055551ef8dbb1427b25606a082affe87a279b163cc54bb6c51200000009a88fbf9a9ef37158278bb506ca50d2c845f95dbf9e1e2e43bb0e2201693e8123206e79f6c75a113e56cc2a86a90f22f5f06c641279c0bb9d80ecd9aaa40e080c4046025419e1b75c3a10ae3be56b52abec98a45ff3281114b6d3e4d04f0914b2ff59cd810678aa8375e23565293b44551d81b3243d7241e6063acbc7ce9d251dac468b53ad7d88b50648e05629b3311c568a7a6b45ba0f4f7eadeb5b51daba640743fa7ee182d70f2c21d8ac75e649a8f1144bfcaa1faf1ded13644f450e2a95ac9b7dabb6705c8b77d5f7fe5d805909f711e9a834c2325fa26fc2c0946f60ada5ddae592f9e87e516398856453d8443013b6034ea6edd721b819e6fe32d69568e558ff5aba5693bcd61fa7b46e7724d8e009463385575e5fb4467b47db28669bd5af9db5fad9e2e3dcbe16499d28914613a1174ea72b482a75766226a82879add4ee4dda2523634017341f30cb88e742af5cbdefebd17658522181b7a94fe9be3a42e57c60871c710e8d360aafd256d87e0671b912a8e3712ac18ca8f7c5957229440fcae6a329a6965e3a5079384e0489c22786eb445b4115cc8ed4f1a6720ffd34b1eaec705a996d9c52eae9c64693b5b41e777b5f9229dd0b668428daa439bcf57bfd643362023c47fbf3d458262460a4f4d36cccb01e2c434f2e72ce3eb500975a43222e853866b22cd737610bdcb2d17c30a836f3b56a6c5839d4bccaf3dba45645de8a6e05e05bec4d131162855d0587df0e524c10df282dd3bab6e91e6942d50915a007b6c79fed726a1228415f83c5ff9e77adb46196b578a19a0da9d9f5f0a780ebbe977d342edfdd62cf0687f323f3cbf7bbc0ee4af643df2355dd216c7bc7d6ba80f3a73f129062a057f459692e1f09dee80df372338c7417c0cad51bf004f050ce1ca59bc07ec1dccda5a610016696df431b51a5f34b6c090ecc097398c30d5cf425b56abc309d6d08ddaa7127ffa838d67ff51b3bcb635564877fe51ed3b8ec2dbb4541cdef4183c227c941cc849de201b8e1f32d6700073b93cad2702f9ada4931c2db2f6c019bc8f3fa86afbcbe5aa9ee25230c508362d30074ba0100010834300f4c8af9038f6d32993ada26f6261ac0d97a1d439c96462a116954c5fe00000000012c63452816f36831e4e8efa30514d3114824d896e626102f937ba2bb9782632b03d89da604004b0821b178104998cf5676cdf00f1b6cffb86056518d55a2ff066f8ab992631a00015c098280e83a49f1c6043e69cfbe7966380ee984b83ed8c023068900245e8828";
let pczt = Pczt::parse(&hex::decode(pczt_hex).unwrap()).unwrap();
- assert_eq!(has_transparent(&pczt), true);
- assert_eq!(is_transparent_coinbase(&pczt), false);
- assert_eq!(has_sapling(&pczt), false);
- assert_eq!(has_orchard(&pczt), true);
+ assert!(has_transparent(&pczt));
+ assert!(!is_transparent_coinbase(&pczt));
+ assert!(!has_sapling(&pczt));
+ assert!(has_orchard(&pczt));
assert_eq!(
hex::encode(digest_header(&pczt, 0).as_bytes()),
"96c60ee6c88b3b44c751be6793669a38154552ddb490b58d5b732c80255c5be5"
);
assert_eq!(
- hex::encode(digest_transparent_prevouts(&pczt.transparent().inputs()).as_bytes()),
+ hex::encode(digest_transparent_prevouts(pczt.transparent().inputs()).as_bytes()),
"a04b16834dc939ccf632d15dddaa6bcaed253d12068dca169fbd28bc403cf3ba"
);
assert_eq!(
- hex::encode(digest_transparent_sequence(&pczt.transparent().inputs()).as_bytes()),
+ hex::encode(digest_transparent_sequence(pczt.transparent().inputs()).as_bytes()),
"3a0033336603235001742438238d713c09c1c55bf67bd20b80805aea0b46eba5"
);
assert_eq!(
- hex::encode(digest_transparent_outputs(&pczt.transparent().outputs()).as_bytes()),
+ hex::encode(digest_transparent_outputs(pczt.transparent().outputs()).as_bytes()),
"f214119a412438e233a369039397ed5e247da4511b49af8304f25392292de53c"
);
assert_eq!(
diff --git a/src/managers/keystore.c b/src/managers/keystore.c
index e0ba394..04bf506 100644
--- a/src/managers/keystore.c
+++ b/src/managers/keystore.c
@@ -804,11 +804,6 @@ int32_t GenerateTonMnemonic(char *mnemonic, const char *password)
}
#endif
-int32_t GenerateTRNGRandomness(uint8_t *randomness, uint8_t len)
-{
- return GenerateEntropy(randomness, len, "generate trng randomness");
-}
-
#ifndef COMPILE_SIMULATOR
void random_buffer(uint8_t *buf, size_t len)
{
@@ -830,6 +825,12 @@ void random_buffer(uint8_t *buf, size_t len)
}
#endif
+int32_t GenerateTRNGRandomness(uint8_t *randomness, uint8_t len)
+{
+ random_buffer(randomness, len);
+ return SUCCESS_CODE;
+}
+
#ifndef BUILD_PRODUCTION
/// @brief
diff --git a/src/ui/gui_chain/gui_btc.c b/src/ui/gui_chain/gui_btc.c
index 972cec7..f154413 100644
--- a/src/ui/gui_chain/gui_btc.c
+++ b/src/ui/gui_chain/gui_btc.c
@@ -227,8 +227,10 @@ static UREncodeResult *GetBtcSignDataDynamic(bool unLimit)
encodeResult = btc_sign_msg(data, seed, len, mfp, sizeof(mfp));
} else if (urType == SeedSignerMessage) {
encodeResult = sign_seed_signer_message(data, seed, len);
+#ifdef WEB3_VERSION
} else if (urType == CryptoPSBTExtend) {
encodeResult = utxo_sign_psbt_extend(data, seed, len, mfp, sizeof(mfp), unLimit);
+#endif
}
CHECK_CHAIN_PRINT(encodeResult);
ClearSecretCache();
@@ -430,10 +432,12 @@ void *GuiGetParsedQrData(void)
g_parseMsgResult = parse_seed_signer_message(crypto, public_keys);
CHECK_CHAIN_RETURN(g_parseMsgResult);
return g_parseMsgResult;
+#ifdef WEB3_VERSION
} else if (urType == CryptoPSBTExtend) {
g_parseResult = utxo_parse_extend_psbt(crypto, public_keys, mfp, sizeof(mfp));
CHECK_CHAIN_RETURN(g_parseResult);
return g_parseResult;
+#endif
}
} while (0);
return g_parseResult;
@@ -649,6 +653,7 @@ PtrT_TransactionCheckResult GuiGetPsbtCheckResult(void)
result = btc_check_msg(crypto, mfp, sizeof(mfp));
} else if (urType == SeedSignerMessage) {
result = tx_check_pass();
+#ifdef WEB3_VERSION
} else if (urType == CryptoPSBTExtend) {
PtrT_CSliceFFI_ExtendedPublicKey public_keys = SRAM_MALLOC(sizeof(CSliceFFI_ExtendedPublicKey));
ExtendedPublicKey keys[9];
@@ -674,6 +679,7 @@ PtrT_TransactionCheckResult GuiGetPsbtCheckResult(void)
keys[8].path = "m/44'/145'/0'";
keys[8].xpub = GetCurrentAccountPublicKey(XPUB_TYPE_BCH);
result = utxo_check_psbt_extend(crypto, mfp, sizeof(mfp), public_keys, NULL, NULL);
+#endif
}
return result;
}
diff --git a/src/ui/gui_chain/multi/web3/gui_iota.c b/src/ui/gui_chain/multi/web3/gui_iota.c
index d3df832..47051ec 100644
--- a/src/ui/gui_chain/multi/web3/gui_iota.c
+++ b/src/ui/gui_chain/multi/web3/gui_iota.c
@@ -13,27 +13,29 @@ static bool g_isMulti = false;
static URParseResult *g_urResult = NULL;
static URParseMultiResult *g_urMultiResult = NULL;
static void *g_parseResult = NULL;
+static bool g_isSignMessageHash = false;
void GuiSetIotaUrData(URParseResult *urResult, URParseMultiResult *urMultiResult, bool multi)
{
g_urResult = urResult;
g_urMultiResult = urMultiResult;
g_isMulti = multi;
+ g_isSignMessageHash = false;
}
#define CHECK_FREE_PARSE_RESULT(result) \
if (result != NULL) \
{ \
- free_TransactionParseResult_DisplayIotaIntentData((PtrT_TransactionParseResult_DisplayIotaIntentData)result); \
+ if (g_isSignMessageHash) \
+ { \
+ free_TransactionParseResult_DisplayIotaSignMessageHash((PtrT_TransactionParseResult_DisplayIotaSignMessageHash)result); \
+ } else \
+ { \
+ free_TransactionParseResult_DisplayIotaIntentData((PtrT_TransactionParseResult_DisplayIotaIntentData)result); \
+ } \
result = NULL; \
- }
+ } \
-#define CHECK_FREE_PARSE_RESULT_SIGN_MESSAGE_HASH(result) \
- if (result != NULL) \
- { \
- free_DisplayIotaSignMessageHash((PtrT_DisplayIotaSignMessageHash)result); \
- result = NULL; \
- }
void *GuiGetIotaData(void)
{
@@ -54,6 +56,7 @@ void *GuiGetIotaSignMessageHashData(void)
do {
PtrT_TransactionParseResult_DisplayIotaSignMessageHash parseResult = iota_parse_sign_message_hash(data);
CHECK_CHAIN_BREAK(parseResult);
+ g_isSignMessageHash = true;
g_parseResult = (void *)parseResult;
} while (0);
return g_parseResult;
@@ -81,7 +84,6 @@ void FreeIotaMemory(void)
CHECK_FREE_UR_RESULT(g_urResult, false);
CHECK_FREE_UR_RESULT(g_urMultiResult, true);
CHECK_FREE_PARSE_RESULT(g_parseResult);
- CHECK_FREE_PARSE_RESULT_SIGN_MESSAGE_HASH(g_parseResult);
}
UREncodeResult *GuiGetIotaSignQrCodeData(void)
diff --git a/src/ui/gui_model/gui_model.c b/src/ui/gui_model/gui_model.c
index 51952de..ee4f6cf 100644
--- a/src/ui/gui_model/gui_model.c
+++ b/src/ui/gui_model/gui_model.c
@@ -401,7 +401,7 @@ static int32_t ModelWriteEntropyAndSeed(const void *inData, uint32_t inDataLen)
CHECK_ERRCODE_BREAK("duplicated entropy", ret);
ret = CreateNewAccount(newAccount, entropy, entropyLen, SecretCacheGetNewPassword());
ClearAccountPassphrase(newAccount);
- if (SecretCacheGetPassphrase()) {
+ if (strnlen_s(SecretCacheGetPassphrase(), PASSPHRASE_MAX_LEN) > 0) {
SetPassphrase(GetCurrentAccountIndex(), SecretCacheGetPassphrase(), SecretCacheGetNewPassword());
SetPassphraseQuickAccess(GuiPassphraseQuickAccess());
}
@@ -444,7 +444,7 @@ static int32_t ModelBip39CalWriteEntropyAndSeed(const void *inData, uint32_t inD
ret = CreateNewAccount(newAccount, entropy, (uint8_t)entropyOutLen, SecretCacheGetNewPassword());
CHECK_ERRCODE_BREAK("save entropy error", ret);
ClearAccountPassphrase(newAccount);
- if (SecretCacheGetPassphrase()) {
+ if (strnlen_s(SecretCacheGetPassphrase(), PASSPHRASE_MAX_LEN) > 0) {
SetPassphrase(GetCurrentAccountIndex(), SecretCacheGetPassphrase(), SecretCacheGetNewPassword());
SetPassphraseQuickAccess(GuiPassphraseQuickAccess());
}
@@ -742,7 +742,7 @@ static int32_t ModelSlip39WriteEntropy(const void *inData, uint32_t inDataLen)
ret = CreateNewSlip39Account(newAccount, ems, entropy, entropyLen, SecretCacheGetNewPassword(), SecretCacheGetIdentifier(), SecretCacheGetExtendable(), SecretCacheGetIteration());
CHECK_ERRCODE_BREAK("save slip39 entropy error", ret);
ClearAccountPassphrase(newAccount);
- if (SecretCacheGetPassphrase()) {
+ if (strnlen_s(SecretCacheGetPassphrase(), PASSPHRASE_MAX_LEN) > 0) {
SetPassphrase(GetCurrentAccountIndex(), SecretCacheGetPassphrase(), SecretCacheGetNewPassword());
SetPassphraseQuickAccess(GuiPassphraseQuickAccess());
}
@@ -801,7 +801,7 @@ static int32_t ModelSlip39CalWriteEntropyAndSeed(const void *inData, uint32_t in
ret = CreateNewSlip39Account(newAccount, emsBak, entropy, entropyLen, SecretCacheGetNewPassword(), id, eb, ie);
CHECK_ERRCODE_BREAK("save slip39 entropy error", ret);
ClearAccountPassphrase(newAccount);
- if (SecretCacheGetPassphrase()) {
+ if (strnlen_s(SecretCacheGetPassphrase(), PASSPHRASE_MAX_LEN) > 0) {
SetPassphrase(GetCurrentAccountIndex(), SecretCacheGetPassphrase(), SecretCacheGetNewPassword());
SetPassphraseQuickAccess(GuiPassphraseQuickAccess());
}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.