Skip to content

Commit

Permalink
chore: bump bitcoin rust deps
Browse files Browse the repository at this point in the history
Signed-off-by: Gregory Hill <[email protected]>
  • Loading branch information
gregdhill committed Feb 10, 2025
1 parent a2602fd commit 970149f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ bindings = { package = "bob-bindings", path = "crates/bindings" }
utils = { package = "bob-utils", path = "crates/utils" }

# Bitcoin
bitcoin = "0.30.0"
bitcoincore-rpc = "0.17"
bitcoin = "0.32.5"
bitcoincore-rpc = "0.19.0"

# Ethereum
alloy = "0.11.0"
Expand Down
12 changes: 4 additions & 8 deletions crates/utils/src/bitcoin_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use bitcoin::{
address::NetworkChecked,
consensus::{self, serialize},
hashes::{hex::FromHex, sha256d::Hash as Sha256dHash, Hash},
hex::HexToBytesError,
opcodes,
script::{Error as ScriptError, Instruction},
Address, Amount, MerkleBlock, Network, ScriptBuf, Txid,
Expand Down Expand Up @@ -102,7 +103,7 @@ pub enum Error {
#[error("SerdeError: {0}")]
SerdeError(#[from] serde_json::Error),
#[error("HexError: {0}")]
HexError(#[from] bitcoin::hashes::hex::Error),
HexError(#[from] HexToBytesError),
#[error("EncodeError: {0}")]
EncodeError(#[from] bitcoin::consensus::encode::Error),
#[error("Missing Txid")]
Expand Down Expand Up @@ -175,12 +176,7 @@ impl BitcoinClient {

pub fn network(&self) -> Result<Network, Error> {
let info = self.rpc.get_blockchain_info()?;
match info.chain.as_str() {
"main" => Ok(Network::Bitcoin),
"test" => Ok(Network::Testnet),
"regtest" => Ok(Network::Regtest),
_ => Err(Error::InvalidNetwork),
}
Ok(info.chain)
}

pub fn get_block_hash(&self, height: u64) -> Result<BlockHash, Error> {
Expand Down Expand Up @@ -222,7 +218,7 @@ impl BitcoinClient {
block_hash: &BlockHash,
) -> Result<(Vec<Sha256dHash>, usize), Error> {
let block = self.rpc.get_block(block_hash)?;
let txids: Vec<_> = block.txdata.iter().map(|tx| tx.txid()).collect();
let txids: Vec<_> = block.txdata.iter().map(|tx| tx.compute_txid()).collect();
let pos = txids.iter().position(|txid| txid == tx_hash).ok_or(Error::MissingTxId)?;
let txids = txids.into_iter().map(Sha256dHash::from).collect();

Expand Down
2 changes: 1 addition & 1 deletion crates/utils/src/esplora_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ impl EsploraClient {
}

pub async fn validate_and_send_raw_transaction(&self, tx: &Transaction) -> Result<Txid> {
let txid = tx.txid();
let txid = tx.compute_txid();
let tx_status = self.get_tx_status(&txid).await?;
match tx_status {
TransactionStatus { confirmed: true, block_height: Some(_), .. } => Ok(txid),
Expand Down

0 comments on commit 970149f

Please sign in to comment.