Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: anychain-tron from_bytes() #287

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/anychain-tron/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"]

Expand Down
24 changes: 16 additions & 8 deletions crates/anychain-tron/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,23 @@ impl Transaction for TronTransaction {
self.to_bytes()
}

fn from_bytes(tx: &[u8]) -> Result<Self, TransactionError> {
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<Self, TransactionError> {
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(
Expand Down
Loading