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

Depend on bitcoin v0.32.0 #337

Merged
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
88 changes: 74 additions & 14 deletions Cargo-minimal.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,28 @@
# It is not intended for manual editing.
version = 3

[[package]]
name = "arrayvec"
version = "0.7.4"
source = "registry+https:/rust-lang/crates.io-index"
checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711"

[[package]]
name = "autocfg"
version = "1.2.0"
source = "registry+https:/rust-lang/crates.io-index"
checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80"

[[package]]
name = "base58ck"
version = "0.1.0"
source = "registry+https:/rust-lang/crates.io-index"
checksum = "2c8d66485a3a2ea485c1913c4572ce0256067a5377ac8c75c4960e1cda98605f"
dependencies = [
"bitcoin-internals 0.3.0",
"bitcoin_hashes 0.14.0",
]

[[package]]
name = "base64"
version = "0.13.1"
Expand All @@ -16,20 +32,23 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"

[[package]]
name = "bech32"
version = "0.10.0-beta"
version = "0.11.0"
source = "registry+https:/rust-lang/crates.io-index"
checksum = "98f7eed2b2781a6f0b5c903471d48e15f56fb4e1165df8a9a2337fd1a59d45ea"
checksum = "d965446196e3b7decd44aa7ee49e31d630118f90ef12f97900f262eb915c951d"

[[package]]
name = "bitcoin"
version = "0.31.2"
version = "0.32.0"
source = "registry+https:/rust-lang/crates.io-index"
checksum = "6c85783c2fe40083ea54a33aa2f0ba58831d90fcd190f5bdc47e74e84d2a96ae"
checksum = "7170e7750a20974246f17ece04311b4205a6155f1db564c5b224af817663c3ea"
dependencies = [
"base58ck",
"bech32",
"bitcoin-internals",
"bitcoin_hashes",
"hex-conservative",
"bitcoin-internals 0.3.0",
"bitcoin-io",
"bitcoin-units",
"bitcoin_hashes 0.14.0",
"hex-conservative 0.2.0",
"hex_lit",
"secp256k1",
"serde",
Expand All @@ -40,7 +59,29 @@ name = "bitcoin-internals"
version = "0.2.0"
source = "registry+https:/rust-lang/crates.io-index"
checksum = "9425c3bf7089c983facbae04de54513cce73b41c7f9ff8c845b54e7bc64ebbfb"

[[package]]
name = "bitcoin-internals"
version = "0.3.0"
source = "registry+https:/rust-lang/crates.io-index"
checksum = "30bdbe14aa07b06e6cfeffc529a1f099e5fbe249524f8125358604df99a4bed2"
dependencies = [
"serde",
]

[[package]]
name = "bitcoin-io"
version = "0.1.2"
source = "registry+https:/rust-lang/crates.io-index"
checksum = "340e09e8399c7bd8912f495af6aa58bea0c9214773417ffaa8f6460f93aaee56"

[[package]]
name = "bitcoin-units"
version = "0.1.1"
source = "registry+https:/rust-lang/crates.io-index"
checksum = "cb54da0b28892f3c52203a7191534033e051b6f4b52bc15480681b57b7e036f5"
dependencies = [
"bitcoin-internals 0.3.0",
"serde",
]

Expand All @@ -50,8 +91,18 @@ version = "0.13.0"
source = "registry+https:/rust-lang/crates.io-index"
checksum = "1930a4dabfebb8d7d9992db18ebe3ae2876f0a305fab206fd168df931ede293b"
dependencies = [
"bitcoin-internals",
"hex-conservative",
"bitcoin-internals 0.2.0",
"hex-conservative 0.1.1",
]

[[package]]
name = "bitcoin_hashes"
version = "0.14.0"
source = "registry+https:/rust-lang/crates.io-index"
checksum = "bb18c03d0db0247e147a21a6faafd5a7eb851c743db062de72018b6b7e8e4d16"
dependencies = [
"bitcoin-io",
"hex-conservative 0.2.0",
"serde",
]

Expand Down Expand Up @@ -136,6 +187,15 @@ version = "0.1.1"
source = "registry+https:/rust-lang/crates.io-index"
checksum = "30ed443af458ccb6d81c1e7e661545f94d3176752fb1df2f543b902a1e0f51e2"

[[package]]
name = "hex-conservative"
version = "0.2.0"
source = "registry+https:/rust-lang/crates.io-index"
checksum = "e1aa273bf451e37ed35ced41c71a5e2a4e29064afb104158f2514bcd71c2c986"
dependencies = [
"arrayvec",
]

[[package]]
name = "hex_lit"
version = "0.1.1"
Expand Down Expand Up @@ -298,21 +358,21 @@ checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1"

[[package]]
name = "secp256k1"
version = "0.28.2"
version = "0.29.0"
source = "registry+https:/rust-lang/crates.io-index"
checksum = "d24b59d129cdadea20aea4fb2352fa053712e5d713eee47d700cd4b2bc002f10"
checksum = "0e0cc0f1cf93f4969faf3ea1c7d8a9faed25918d96affa959720823dfe86d4f3"
dependencies = [
"bitcoin_hashes",
"bitcoin_hashes 0.13.0",
"rand",
"secp256k1-sys",
"serde",
]

[[package]]
name = "secp256k1-sys"
version = "0.9.2"
version = "0.10.0"
source = "registry+https:/rust-lang/crates.io-index"
checksum = "e5d1746aae42c19d583c3c1a8c646bfad910498e2051c551a7f2e3c0c9fbb7eb"
checksum = "1433bd67156263443f14d603720b082dd3121779323fce20cba2aa07b874bc1b"
dependencies = [
"cc",
]
Expand Down
88 changes: 74 additions & 14 deletions Cargo-recent.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,28 @@
# It is not intended for manual editing.
version = 3

[[package]]
name = "arrayvec"
version = "0.7.4"
source = "registry+https:/rust-lang/crates.io-index"
checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711"

[[package]]
name = "autocfg"
version = "1.2.0"
source = "registry+https:/rust-lang/crates.io-index"
checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80"

[[package]]
name = "base58ck"
version = "0.1.0"
source = "registry+https:/rust-lang/crates.io-index"
checksum = "2c8d66485a3a2ea485c1913c4572ce0256067a5377ac8c75c4960e1cda98605f"
dependencies = [
"bitcoin-internals 0.3.0",
"bitcoin_hashes 0.14.0",
]

[[package]]
name = "base64"
version = "0.13.1"
Expand All @@ -16,20 +32,23 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"

[[package]]
name = "bech32"
version = "0.10.0-beta"
version = "0.11.0"
source = "registry+https:/rust-lang/crates.io-index"
checksum = "98f7eed2b2781a6f0b5c903471d48e15f56fb4e1165df8a9a2337fd1a59d45ea"
checksum = "d965446196e3b7decd44aa7ee49e31d630118f90ef12f97900f262eb915c951d"

[[package]]
name = "bitcoin"
version = "0.31.2"
version = "0.32.0"
source = "registry+https:/rust-lang/crates.io-index"
checksum = "6c85783c2fe40083ea54a33aa2f0ba58831d90fcd190f5bdc47e74e84d2a96ae"
checksum = "7170e7750a20974246f17ece04311b4205a6155f1db564c5b224af817663c3ea"
dependencies = [
"base58ck",
"bech32",
"bitcoin-internals",
"bitcoin_hashes",
"hex-conservative",
"bitcoin-internals 0.3.0",
"bitcoin-io",
"bitcoin-units",
"bitcoin_hashes 0.14.0",
"hex-conservative 0.2.0",
"hex_lit",
"secp256k1",
"serde",
Expand All @@ -40,7 +59,29 @@ name = "bitcoin-internals"
version = "0.2.0"
source = "registry+https:/rust-lang/crates.io-index"
checksum = "9425c3bf7089c983facbae04de54513cce73b41c7f9ff8c845b54e7bc64ebbfb"

[[package]]
name = "bitcoin-internals"
version = "0.3.0"
source = "registry+https:/rust-lang/crates.io-index"
checksum = "30bdbe14aa07b06e6cfeffc529a1f099e5fbe249524f8125358604df99a4bed2"
dependencies = [
"serde",
]

[[package]]
name = "bitcoin-io"
version = "0.1.2"
source = "registry+https:/rust-lang/crates.io-index"
checksum = "340e09e8399c7bd8912f495af6aa58bea0c9214773417ffaa8f6460f93aaee56"

[[package]]
name = "bitcoin-units"
version = "0.1.1"
source = "registry+https:/rust-lang/crates.io-index"
checksum = "cb54da0b28892f3c52203a7191534033e051b6f4b52bc15480681b57b7e036f5"
dependencies = [
"bitcoin-internals 0.3.0",
"serde",
]

Expand All @@ -50,8 +91,18 @@ version = "0.13.0"
source = "registry+https:/rust-lang/crates.io-index"
checksum = "1930a4dabfebb8d7d9992db18ebe3ae2876f0a305fab206fd168df931ede293b"
dependencies = [
"bitcoin-internals",
"hex-conservative",
"bitcoin-internals 0.2.0",
"hex-conservative 0.1.1",
]

[[package]]
name = "bitcoin_hashes"
version = "0.14.0"
source = "registry+https:/rust-lang/crates.io-index"
checksum = "bb18c03d0db0247e147a21a6faafd5a7eb851c743db062de72018b6b7e8e4d16"
dependencies = [
"bitcoin-io",
"hex-conservative 0.2.0",
"serde",
]

Expand Down Expand Up @@ -136,6 +187,15 @@ version = "0.1.1"
source = "registry+https:/rust-lang/crates.io-index"
checksum = "30ed443af458ccb6d81c1e7e661545f94d3176752fb1df2f543b902a1e0f51e2"

[[package]]
name = "hex-conservative"
version = "0.2.0"
source = "registry+https:/rust-lang/crates.io-index"
checksum = "e1aa273bf451e37ed35ced41c71a5e2a4e29064afb104158f2514bcd71c2c986"
dependencies = [
"arrayvec",
]

[[package]]
name = "hex_lit"
version = "0.1.1"
Expand Down Expand Up @@ -298,21 +358,21 @@ checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1"

[[package]]
name = "secp256k1"
version = "0.28.2"
version = "0.29.0"
source = "registry+https:/rust-lang/crates.io-index"
checksum = "d24b59d129cdadea20aea4fb2352fa053712e5d713eee47d700cd4b2bc002f10"
checksum = "0e0cc0f1cf93f4969faf3ea1c7d8a9faed25918d96affa959720823dfe86d4f3"
dependencies = [
"bitcoin_hashes",
"bitcoin_hashes 0.13.0",
"rand",
"secp256k1-sys",
"serde",
]

[[package]]
name = "secp256k1-sys"
version = "0.9.2"
version = "0.10.0"
source = "registry+https:/rust-lang/crates.io-index"
checksum = "e5d1746aae42c19d583c3c1a8c646bfad910498e2051c551a7f2e3c0c9fbb7eb"
checksum = "1433bd67156263443f14d603720b082dd3121779323fce20cba2aa07b874bc1b"
dependencies = [
"cc",
]
Expand Down
5 changes: 3 additions & 2 deletions client/examples/test_against_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ fn main_result() -> Result<(), Error> {

let bitcoin_block: bitcoin::Block = rpc.get_by_id(&best_block_hash)?;
println!("best block hash by `get`: {}", bitcoin_block.header.prev_blockhash);
let bitcoin_tx: bitcoin::Transaction = rpc.get_by_id(&bitcoin_block.txdata[0].txid())?;
println!("tx by `get`: {}", bitcoin_tx.txid());
let bitcoin_tx: bitcoin::Transaction =
rpc.get_by_id(&bitcoin_block.txdata[0].compute_txid())?;
println!("tx by `get`: {}", bitcoin_tx.compute_txid());

Ok(())
}
Expand Down
13 changes: 7 additions & 6 deletions client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ use std::iter::FromIterator;
use std::path::PathBuf;
use std::{fmt, result};

use crate::{bitcoin, deserialize_hex};
use crate::bitcoin;
use crate::bitcoin::consensus::encode;
use bitcoin::hex::DisplayHex;
use jsonrpc;
use serde;
Expand Down Expand Up @@ -163,7 +164,7 @@ pub trait RawTx: Sized + Clone {

impl<'a> RawTx for &'a Transaction {
fn raw_hex(self) -> String {
bitcoin::consensus::encode::serialize_hex(self)
encode::serialize_hex(self)
}
}

Expand Down Expand Up @@ -333,7 +334,7 @@ pub trait RpcApi: Sized {

fn get_block(&self, hash: &bitcoin::BlockHash) -> Result<Block> {
let hex: String = self.call("getblock", &[into_json(hash)?, 0.into()])?;
deserialize_hex(&hex)
Ok(encode::deserialize_hex(&hex)?)
}

fn get_block_hex(&self, hash: &bitcoin::BlockHash) -> Result<String> {
Expand All @@ -347,7 +348,7 @@ pub trait RpcApi: Sized {

fn get_block_header(&self, hash: &bitcoin::BlockHash) -> Result<bitcoin::block::Header> {
let hex: String = self.call("getblockheader", &[into_json(hash)?, false.into()])?;
deserialize_hex(&hex)
Ok(encode::deserialize_hex(&hex)?)
}

fn get_block_header_info(
Expand Down Expand Up @@ -491,7 +492,7 @@ pub trait RpcApi: Sized {
) -> Result<Transaction> {
let mut args = [into_json(txid)?, into_json(false)?, opt_into_json(block_hash)?];
let hex: String = self.call("getrawtransaction", handle_defaults(&mut args, &[null()]))?;
deserialize_hex(&hex)
Ok(encode::deserialize_hex(&hex)?)
}

fn get_raw_transaction_hex(
Expand Down Expand Up @@ -788,7 +789,7 @@ pub trait RpcApi: Sized {
replaceable: Option<bool>,
) -> Result<Transaction> {
let hex: String = self.create_raw_transaction_hex(utxos, outs, locktime, replaceable)?;
deserialize_hex(&hex)
Ok(encode::deserialize_hex(&hex)?)
}

fn decode_raw_transaction<R: RawTx>(
Expand Down
6 changes: 3 additions & 3 deletions client/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub enum Error {
JsonRpc(jsonrpc::error::Error),
Hex(hex::HexToBytesError),
Json(serde_json::error::Error),
BitcoinSerialization(bitcoin::consensus::encode::Error),
BitcoinSerialization(bitcoin::consensus::encode::FromHexError),
Secp256k1(secp256k1::Error),
Io(io::Error),
InvalidAmount(bitcoin::amount::ParseAmountError),
Expand Down Expand Up @@ -51,8 +51,8 @@ impl From<serde_json::error::Error> for Error {
}
}

impl From<bitcoin::consensus::encode::Error> for Error {
fn from(e: bitcoin::consensus::encode::Error) -> Error {
impl From<bitcoin::consensus::encode::FromHexError> for Error {
fn from(e: bitcoin::consensus::encode::FromHexError) -> Error {
Error::BitcoinSerialization(e)
}
}
Expand Down
Loading
Loading