From afddbc4df84d559f1bd698dfdac9402bd2a5b6c4 Mon Sep 17 00:00:00 2001 From: aya015757881 <2581015450@qq.com> Date: Fri, 15 Nov 2024 15:04:49 +0800 Subject: [PATCH] fix: remove bitcoin witness deserialization --- Cargo.lock | 2 +- crates/anychain-bitcoin/Cargo.toml | 2 +- crates/anychain-bitcoin/src/transaction.rs | 40 +++++++++++----------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 97de030..d896127 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -138,7 +138,7 @@ dependencies = [ [[package]] name = "anychain-bitcoin" -version = "0.1.8" +version = "0.1.9" dependencies = [ "anychain-core", "base58", diff --git a/crates/anychain-bitcoin/Cargo.toml b/crates/anychain-bitcoin/Cargo.toml index 2c5f378..6eca6ab 100644 --- a/crates/anychain-bitcoin/Cargo.toml +++ b/crates/anychain-bitcoin/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "anychain-bitcoin" description = "A Rust library for Bitcoin-focused cryptocurrency wallets, enabling seamless transactions on the Bitcoin blockchain" -version = "0.1.8" +version = "0.1.9" keywords = ["bitcoin", "blockchain", "wallet", "transactions"] categories = ["cryptography::cryptocurrencies"] diff --git a/crates/anychain-bitcoin/src/transaction.rs b/crates/anychain-bitcoin/src/transaction.rs index 09347e6..8565331 100644 --- a/crates/anychain-bitcoin/src/transaction.rs +++ b/crates/anychain-bitcoin/src/transaction.rs @@ -775,26 +775,26 @@ impl BitcoinTransactionParameters { let outputs = BitcoinVector::read(&mut reader, BitcoinTransactionOutput::read)?; - if segwit_flag { - for input in &mut inputs { - let witnesses: Vec> = BitcoinVector::read(&mut reader, |s| { - let (size, witness) = BitcoinVector::read_witness(s, |sr| { - let mut byte = [0u8; 1]; - let _ = sr.read(&mut byte)?; - Ok(byte[0]) - })?; - Ok([variable_length_integer(size as u64)?, witness?].concat()) - })?; - - if !witnesses.is_empty() { - input.sighash_code = - SignatureHash::from_byte(&witnesses[0][&witnesses[0].len() - 1]); - input.is_signed = true; - } - - input.witnesses = witnesses; - } - } + // if segwit_flag { + // for input in &mut inputs { + // let witnesses: Vec> = BitcoinVector::read(&mut reader, |s| { + // let (size, witness) = BitcoinVector::read_witness(s, |sr| { + // let mut byte = [0u8; 1]; + // let _ = sr.read(&mut byte)?; + // Ok(byte[0]) + // })?; + // Ok([variable_length_integer(size as u64)?, witness?].concat()) + // })?; + + // if !witnesses.is_empty() { + // input.sighash_code = + // SignatureHash::from_byte(&witnesses[0][&witnesses[0].len() - 1]); + // input.is_signed = true; + // } + + // input.witnesses = witnesses; + // } + // } let mut lock_time = [0u8; 4]; let _ = reader.read(&mut lock_time)?;