Skip to content

Commit 6746011

Browse files
committed
Merge #286: bitcoin 0.29.x -> 0.30.0
201914e bitcoin 0.29.x -> 0.30.0 (Riccardo Casatta) 624ca4f use serde 1.0.152 to avoid syn 2.x (Riccardo Casatta) Pull request description: ~~I temporarily added two crates that must be removed before removing the draft status:~~ * ~~hex crate: because I couldn't quickly figure out how to convert bytes to hex~~ * ~~rand: because it didn't seem to be re-exported anymore~~ about `Address`: * when parameters: `Address<NetworkChecked>` * when return values: `Address<NetworkUnchecked>` and updated tests with `assume_checked()` where needed ACKs for top commit: apoelstra: ACK 201914e Tree-SHA512: f77f5407c4180a65bf6c85a3ae39322204be3d7808efac20c2c0a2d057c54a58bd5d4b27c4dab0be397ccabcf9036940a1b5f316634ba4f2e1bf3d571c562f3f
2 parents 64f2dca + 201914e commit 6746011

File tree

9 files changed

+202
-190
lines changed

9 files changed

+202
-190
lines changed

.github/workflows/rust.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
profile: minimal
2828
toolchain: ${{ matrix.rust }}
2929
override: true
30+
- run: cargo update -p serde --precise 1.0.152
3031
- name: Running test script
3132
env: ${{ matrix.env }}
3233
run: ./contrib/test.sh

client/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ jsonrpc = "0.13.0"
2727
# Used for deserialization of JSON.
2828
serde = "1"
2929
serde_json = "1"
30+
bitcoin-private = "0.1.0"

client/src/client.rs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@ use std::path::PathBuf;
1515
use std::{fmt, result};
1616

1717
use crate::{bitcoin, deserialize_hex};
18+
use bitcoin_private::hex::exts::DisplayHex;
1819
use jsonrpc;
1920
use serde;
2021
use serde_json;
2122

22-
use crate::bitcoin::hashes::hex::{FromHex, ToHex};
23+
use crate::bitcoin::address::{NetworkUnchecked, NetworkChecked};
24+
use crate::bitcoin::hashes::hex::FromHex;
2325
use crate::bitcoin::secp256k1::ecdsa::Signature;
2426
use crate::bitcoin::{
25-
Address, Amount, Block, BlockHeader, OutPoint, PrivateKey, PublicKey, Script, Transaction,
27+
Address, Amount, Block, OutPoint, PrivateKey, PublicKey, Script, Transaction,
2628
};
2729
use log::Level::{Debug, Trace, Warn};
2830

@@ -160,19 +162,19 @@ pub trait RawTx: Sized + Clone {
160162

161163
impl<'a> RawTx for &'a Transaction {
162164
fn raw_hex(self) -> String {
163-
bitcoin::consensus::encode::serialize(self).to_hex()
165+
bitcoin::consensus::encode::serialize_hex(self)
164166
}
165167
}
166168

167169
impl<'a> RawTx for &'a [u8] {
168170
fn raw_hex(self) -> String {
169-
self.to_hex()
171+
self.to_lower_hex_string()
170172
}
171173
}
172174

173175
impl<'a> RawTx for &'a Vec<u8> {
174176
fn raw_hex(self) -> String {
175-
self.to_hex()
177+
self.to_lower_hex_string()
176178
}
177179
}
178180

@@ -345,7 +347,7 @@ pub trait RpcApi: Sized {
345347
}
346348
//TODO(stevenroose) add getblock_txs
347349

348-
fn get_block_header(&self, hash: &bitcoin::BlockHash) -> Result<BlockHeader> {
350+
fn get_block_header(&self, hash: &bitcoin::BlockHash) -> Result<bitcoin::block::Header> {
349351
let hex: String = self.call("getblockheader", &[into_json(hash)?, false.into()])?;
350352
deserialize_hex(&hex)
351353
}
@@ -640,7 +642,7 @@ pub trait RpcApi: Sized {
640642
p2sh: Option<bool>,
641643
) -> Result<()> {
642644
let mut args = [
643-
script.to_hex().into(),
645+
script.to_hex_string().into(),
644646
opt_into_json(label)?,
645647
opt_into_json(rescan)?,
646648
opt_into_json(p2sh)?,
@@ -685,7 +687,7 @@ pub trait RpcApi: Sized {
685687
&self,
686688
minconf: Option<usize>,
687689
maxconf: Option<usize>,
688-
addresses: Option<&[&Address]>,
690+
addresses: Option<&[&Address<NetworkChecked>]>,
689691
include_unsafe: Option<bool>,
690692
query_options: Option<json::ListUnspentQueryOptions>,
691693
) -> Result<Vec<json::ListUnspentResultEntry>> {
@@ -886,12 +888,12 @@ pub trait RpcApi: Sized {
886888
&self,
887889
label: Option<&str>,
888890
address_type: Option<json::AddressType>,
889-
) -> Result<Address> {
891+
) -> Result<Address<NetworkUnchecked>> {
890892
self.call("getnewaddress", &[opt_into_json(label)?, opt_into_json(address_type)?])
891893
}
892894

893895
/// Generate new address for receiving change
894-
fn get_raw_change_address(&self, address_type: Option<json::AddressType>) -> Result<Address> {
896+
fn get_raw_change_address(&self, address_type: Option<json::AddressType>) -> Result<Address<NetworkUnchecked>> {
895897
self.call("getrawchangeaddress", &[opt_into_json(address_type)?])
896898
}
897899

@@ -905,7 +907,7 @@ pub trait RpcApi: Sized {
905907
fn generate_to_address(
906908
&self,
907909
block_num: u64,
908-
address: &Address,
910+
address: &Address<NetworkChecked>,
909911
) -> Result<Vec<bitcoin::BlockHash>> {
910912
self.call("generatetoaddress", &[block_num.into(), address.to_string().into()])
911913
}
@@ -956,7 +958,7 @@ pub trait RpcApi: Sized {
956958

957959
fn send_to_address(
958960
&self,
959-
address: &Address,
961+
address: &Address<NetworkChecked>,
960962
amount: Amount,
961963
comment: Option<&str>,
962964
comment_to: Option<&str>,
@@ -1155,7 +1157,7 @@ pub trait RpcApi: Sized {
11551157
];
11561158
let defaults = [
11571159
true.into(),
1158-
into_json(json::SigHashType::from(bitcoin::EcdsaSighashType::All))?,
1160+
into_json(json::SigHashType::from(bitcoin::sighash::EcdsaSighashType::All))?,
11591161
true.into(),
11601162
];
11611163
self.call("walletprocesspsbt", handle_defaults(&mut args, &defaults))
@@ -1182,7 +1184,7 @@ pub trait RpcApi: Sized {
11821184
self.call("finalizepsbt", handle_defaults(&mut args, &[true.into()]))
11831185
}
11841186

1185-
fn derive_addresses(&self, descriptor: &str, range: Option<[u32; 2]>) -> Result<Vec<Address>> {
1187+
fn derive_addresses(&self, descriptor: &str, range: Option<[u32; 2]>) -> Result<Vec<Address<NetworkUnchecked>>> {
11861188
let mut args = [into_json(descriptor)?, opt_into_json(range)?];
11871189
self.call("deriveaddresses", handle_defaults(&mut args, &[null()]))
11881190
}
@@ -1242,7 +1244,7 @@ pub trait RpcApi: Sized {
12421244

12431245
/// Submit a raw block
12441246
fn submit_block_bytes(&self, block_bytes: &[u8]) -> Result<()> {
1245-
let block_hex: String = block_bytes.to_hex();
1247+
let block_hex: String = block_bytes.to_lower_hex_string();
12461248
self.submit_block_hex(&block_hex)
12471249
}
12481250

client/src/error.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub enum Error {
2525
BitcoinSerialization(bitcoin::consensus::encode::Error),
2626
Secp256k1(secp256k1::Error),
2727
Io(io::Error),
28-
InvalidAmount(bitcoin::util::amount::ParseAmountError),
28+
InvalidAmount(bitcoin::amount::ParseAmountError),
2929
InvalidCookieFile,
3030
/// The JSON result had an unexpected structure.
3131
UnexpectedStructure,
@@ -69,8 +69,8 @@ impl From<io::Error> for Error {
6969
}
7070
}
7171

72-
impl From<bitcoin::util::amount::ParseAmountError> for Error {
73-
fn from(e: bitcoin::util::amount::ParseAmountError) -> Error {
72+
impl From<bitcoin::amount::ParseAmountError> for Error {
73+
fn from(e: bitcoin::amount::ParseAmountError) -> Error {
7474
Error::InvalidAmount(e)
7575
}
7676
}

client/src/queryable.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub trait Queryable<C: RpcApi>: Sized {
2222
fn query(rpc: &C, id: &Self::Id) -> Result<Self>;
2323
}
2424

25-
impl<C: RpcApi> Queryable<C> for bitcoin::blockdata::block::Block {
25+
impl<C: RpcApi> Queryable<C> for bitcoin::block::Block {
2626
type Id = bitcoin::BlockHash;
2727

2828
fn query(rpc: &C, id: &Self::Id) -> Result<Self> {
@@ -33,7 +33,7 @@ impl<C: RpcApi> Queryable<C> for bitcoin::blockdata::block::Block {
3333
}
3434
}
3535

36-
impl<C: RpcApi> Queryable<C> for bitcoin::blockdata::transaction::Transaction {
36+
impl<C: RpcApi> Queryable<C> for bitcoin::transaction::Transaction {
3737
type Id = bitcoin::Txid;
3838

3939
fn query(rpc: &C, id: &Self::Id) -> Result<Self> {

integration_test/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ edition = "2018"
66

77
[dependencies]
88
bitcoincore-rpc = { path = "../client" }
9-
bitcoin = { version = "0.29.0", features = ["serde", "rand"]}
9+
bitcoin = { version = "0.30.0", features = ["serde", "rand"]}
1010
lazy_static = "1.4.0"
1111
log = "0.4"

0 commit comments

Comments
 (0)