diff --git a/client/examples/test_against_node.rs b/client/examples/test_against_node.rs index 4a6ee675..bedaaa85 100644 --- a/client/examples/test_against_node.rs +++ b/client/examples/test_against_node.rs @@ -37,8 +37,8 @@ async fn main_result() -> Result<(), Error> { let bitcoin_block: bitcoin::Block = rpc.get_by_id(&best_block_hash).await?; 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()).await?; - println!("tx by `get`: {}", bitcoin_tx.txid()); + let bitcoin_tx: bitcoin::Transaction = rpc.get_by_id(&bitcoin_block.txdata[0].compute_txid()).await?; + println!("tx by `get`: {}", bitcoin_tx.compute_txid()); Ok(()) } diff --git a/client/src/lib.rs b/client/src/lib.rs index f44393f4..3ec4f0f2 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -26,9 +26,9 @@ pub extern crate jsonrpc_async; pub extern crate bitcoincore_rpc_json; pub use crate::json::bitcoin; +use bitcoincore_rpc_json::bitcoin::io::Cursor; pub use bitcoincore_rpc_json as json; use json::bitcoin::consensus::{Decodable, ReadExt}; -use json::bitcoin::hex::HexToBytesIter; mod client; mod error; @@ -39,7 +39,7 @@ pub use crate::error::Error; pub use crate::queryable::*; fn deserialize_hex(hex: &str) -> Result { - let mut reader = HexToBytesIter::new(&hex)?; + let mut reader = Cursor::new(hex.as_bytes()); let object = Decodable::consensus_decode(&mut reader)?; if reader.read_u8().is_ok() { Err(Error::BitcoinSerialization(bitcoin::consensus::encode::Error::ParseFailed( diff --git a/integration_test/Cargo.toml b/integration_test/Cargo.toml index 6a35c712..014c3676 100644 --- a/integration_test/Cargo.toml +++ b/integration_test/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] bitcoincore-rpc = { path = "../client" } -bitcoin = { version = "0.31.2", features = ["serde", "rand"]} +bitcoin = { version = "0.32.2", features = ["serde", "rand", "rand-std"]} lazy_static = "1.4.0" log = "0.4" tokio = { version = "1", features = ["full"] } diff --git a/integration_test/src/main.rs b/integration_test/src/main.rs index ed25e7ac..9c083791 100644 --- a/integration_test/src/main.rs +++ b/integration_test/src/main.rs @@ -26,7 +26,7 @@ use crate::json::BlockStatsFields as BsFields; use bitcoin::consensus::encode::{deserialize, serialize_hex}; use bitcoin::hashes::hex::FromHex; use bitcoin::hashes::Hash; -use bitcoin::{secp256k1, sighash, ScriptBuf}; +use bitcoin::{secp256k1, sighash, CompressedPublicKey, NetworkKind, ScriptBuf}; use bitcoin::{ transaction, Address, Amount, Network, OutPoint, PrivateKey, Sequence, SignedAmount, Transaction, TxIn, TxOut, Txid, Witness, @@ -281,7 +281,8 @@ async fn test_dump_private_key(cl: &Client) { let addr = cl.get_new_address(None, Some(json::AddressType::Bech32)).await.unwrap().assume_checked(); let sk = cl.dump_private_key(&addr).await.unwrap(); - assert_eq!(addr, Address::p2wpkh(&sk.public_key(&SECP), *NET).unwrap()); + let pub_key = CompressedPublicKey::from_private_key(&SECP, &sk).unwrap(); + assert_eq!(addr, Address::p2wpkh(&pub_key, *NET)); } async fn test_generate(cl: &Client) { @@ -633,11 +634,13 @@ async fn test_get_block_filter(cl: &Client) { async fn test_sign_raw_transaction_with_send_raw_transaction(cl: &Client) { let sk = PrivateKey { - network: Network::Regtest, + network: NetworkKind::Test, inner: secp256k1::SecretKey::new(&mut secp256k1::rand::thread_rng()), compressed: true, }; - let addr = Address::p2wpkh(&sk.public_key(&SECP), Network::Regtest).unwrap(); + + let pub_key = CompressedPublicKey::from_private_key(&SECP, &sk).unwrap(); + let addr = Address::p2wpkh(&pub_key, Network::Regtest); let options = json::ListUnspentQueryOptions { minimum_amount: Some(btc(2)), @@ -768,7 +771,7 @@ async fn test_decode_raw_transaction(cl: &Client) { let decoded_transaction = cl.decode_raw_transaction(hex, None).await.unwrap(); - assert_eq!(tx.txid(), decoded_transaction.txid); + assert_eq!(tx.compute_txid(), decoded_transaction.txid); assert_eq!(500_000, decoded_transaction.locktime); assert_eq!(decoded_transaction.vin[0].txid.unwrap(), unspent.txid); @@ -1070,7 +1073,7 @@ async fn test_list_received_by_address(cl: &Client) { async fn test_import_public_key(cl: &Client) { let sk = PrivateKey { - network: Network::Regtest, + network: NetworkKind::Test, inner: secp256k1::SecretKey::new(&mut secp256k1::rand::thread_rng()), compressed: true, }; @@ -1081,7 +1084,7 @@ async fn test_import_public_key(cl: &Client) { async fn test_import_priv_key(cl: &Client) { let sk = PrivateKey { - network: Network::Regtest, + network: NetworkKind::Test, inner: secp256k1::SecretKey::new(&mut secp256k1::rand::thread_rng()), compressed: true, }; @@ -1092,7 +1095,7 @@ async fn test_import_priv_key(cl: &Client) { async fn test_import_address(cl: &Client) { let sk = PrivateKey { - network: Network::Regtest, + network: NetworkKind::Test, inner: secp256k1::SecretKey::new(&mut secp256k1::rand::thread_rng()), compressed: true, }; @@ -1104,7 +1107,7 @@ async fn test_import_address(cl: &Client) { async fn test_import_address_script(cl: &Client) { let sk = PrivateKey { - network: Network::Regtest, + network: NetworkKind::Test, inner: secp256k1::SecretKey::new(&mut secp256k1::rand::thread_rng()), compressed: true, }; diff --git a/json/Cargo.toml b/json/Cargo.toml index 4df725b7..d3e2fd5c 100644 --- a/json/Cargo.toml +++ b/json/Cargo.toml @@ -22,4 +22,4 @@ path = "src/lib.rs" serde = { version = "1", features = [ "derive" ] } serde_json = "1" -bitcoin = { version = "0.31.2", features = ["serde", "rand-std"]} +bitcoin = { version = "0.32.2", features = ["serde"]} diff --git a/json/src/lib.rs b/json/src/lib.rs index 158cdd14..34f39199 100644 --- a/json/src/lib.rs +++ b/json/src/lib.rs @@ -30,7 +30,7 @@ use bitcoin::consensus::encode; use bitcoin::hashes::hex::FromHex; use bitcoin::hashes::sha256; use bitcoin::{ - bip158, bip32, Address, Amount, CompactTarget, Network, PrivateKey, PublicKey, Script, + bip158, bip32, Address, Amount, Network, PrivateKey, PublicKey, Script, ScriptBuf, SignedAmount, Transaction, }; use serde::de::Error as SerdeError;