diff --git a/Cargo.lock b/Cargo.lock index 1b731a9..97de030 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -310,7 +310,7 @@ dependencies = [ [[package]] name = "anychain-tron" -version = "0.2.8" +version = "0.2.9" dependencies = [ "anychain-core", "base58", diff --git a/crates/anychain-tron/Cargo.toml b/crates/anychain-tron/Cargo.toml index 886cdcc..c9b11c8 100644 --- a/crates/anychain-tron/Cargo.toml +++ b/crates/anychain-tron/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "anychain-tron" description = "A Rust library for Tron-focused cryptocurrency wallets, enabling seamless transactions on the Tron blockchain" -version = "0.2.8" +version = "0.2.9" keywords = ["tron", "blockchain", "wallet", "transactions"] categories = ["cryptography::cryptocurrencies"] diff --git a/crates/anychain-tron/src/transaction.rs b/crates/anychain-tron/src/transaction.rs index e4fbab9..210cd1c 100644 --- a/crates/anychain-tron/src/transaction.rs +++ b/crates/anychain-tron/src/transaction.rs @@ -146,15 +146,23 @@ impl Transaction for TronTransaction { self.to_bytes() } - fn from_bytes(tx: &[u8]) -> Result { - let (raw, sig) = if let Ok(tx) = TransactionProto::parse_from_bytes(tx) { - let raw = tx.raw_data.unwrap(); - let sig = tx.signature[0].clone(); - match sig.len() == 65 { - true => (raw, Some(TronTransactionSignature(sig))), - false => (raw, None), + fn from_bytes(stream: &[u8]) -> Result { + let (raw, sig) = if let Ok(tx) = TransactionProto::parse_from_bytes(stream) { + if !tx.signature.is_empty() { + let raw = tx.raw_data.unwrap(); + let sig = tx.signature[0].clone(); + match sig.len() == 65 { + true => (raw, Some(TronTransactionSignature(sig))), + false => (raw, None), + } + } else if let Ok(raw) = TransactionRaw::parse_from_bytes(stream) { + (raw, None) + } else { + return Err(TransactionError::Message( + "illegal tron transaction stream".to_string(), + )); } - } else if let Ok(raw) = TransactionRaw::parse_from_bytes(tx) { + } else if let Ok(raw) = TransactionRaw::parse_from_bytes(stream) { (raw, None) } else { return Err(TransactionError::Message(