Skip to content
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
1 change: 1 addition & 0 deletions client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ jsonrpc = "0.14.0"
# Used for deserialization of JSON.
serde = "1"
serde_json = "1"
bitcoin-private = "0.1.0"
24 changes: 15 additions & 9 deletions client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ use jsonrpc;
use serde;
use serde_json;

use crate::bitcoin::hashes::hex::{FromHex, ToHex};
use crate::bitcoin::hashes::hex::FromHex;
use crate::bitcoin::secp256k1::ecdsa::Signature;
use crate::bitcoin::{
Address, Amount, Block, BlockHeader, OutPoint, PrivateKey, PublicKey, Script, Transaction,
Address, Amount, Block, OutPoint, PrivateKey, PublicKey, Script, Transaction,
};
use bitcoin::blockdata::block::Header as BlockHeader;
use bitcoin_private::hex::display::DisplayHex;
use log::Level::{Debug, Trace, Warn};

use crate::error::*;
Expand Down Expand Up @@ -158,19 +160,19 @@ pub trait RawTx: Sized + Clone {

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

impl<'a> RawTx for &'a [u8] {
fn raw_hex(self) -> String {
self.to_hex()
self.to_lower_hex_string()
}
}

impl<'a> RawTx for &'a Vec<u8> {
fn raw_hex(self) -> String {
self.to_hex()
self.to_lower_hex_string()
}
}

Expand Down Expand Up @@ -634,7 +636,7 @@ pub trait RpcApi: Sized {
p2sh: Option<bool>,
) -> Result<()> {
let mut args = [
script.to_hex().into(),
format!("{:x}", script).into(),
opt_into_json(label)?,
opt_into_json(rescan)?,
opt_into_json(p2sh)?,
Expand Down Expand Up @@ -767,6 +769,7 @@ pub trait RpcApi: Sized {
self.call("fundrawtransaction", handle_defaults(&mut args, &defaults))
}

/*
#[deprecated]
fn sign_raw_transaction<R: RawTx>(
&self,
Expand Down Expand Up @@ -812,6 +815,7 @@ pub trait RpcApi: Sized {
let defaults = [empty_arr(), null()];
self.call("signrawtransactionwithkey", handle_defaults(&mut args, &defaults))
}
*/

fn test_mempool_accept<R: RawTx>(
&self,
Expand Down Expand Up @@ -841,7 +845,7 @@ pub trait RpcApi: Sized {
&self,
label: Option<&str>,
address_type: Option<json::AddressType>,
) -> Result<Address> {
) -> Result<Address<bitcoin::address::NetworkUnchecked>> {
self.call("getnewaddress", &[opt_into_json(label)?, opt_into_json(address_type)?])
}

Expand Down Expand Up @@ -1078,6 +1082,7 @@ pub trait RpcApi: Sized {
)
}

/*
fn wallet_process_psbt(
&self,
psbt: &str,
Expand All @@ -1098,6 +1103,7 @@ pub trait RpcApi: Sized {
];
self.call("walletprocesspsbt", handle_defaults(&mut args, &defaults))
}
*/

fn get_descriptor_info(&self, desc: &str) -> Result<json::GetDescriptorInfoResult> {
self.call("getdescriptorinfo", &[desc.to_string().into()])
Expand All @@ -1116,7 +1122,7 @@ pub trait RpcApi: Sized {
self.call("finalizepsbt", handle_defaults(&mut args, &[true.into()]))
}

fn derive_addresses(&self, descriptor: &str, range: Option<[u32; 2]>) -> Result<Vec<Address>> {
fn derive_addresses(&self, descriptor: &str, range: Option<[u32; 2]>) -> Result<Vec<Address<bitcoin::address::NetworkUnchecked>>> {
let mut args = [into_json(descriptor)?, opt_into_json(range)?];
self.call("deriveaddresses", handle_defaults(&mut args, &[null()]))
}
Expand Down Expand Up @@ -1176,7 +1182,7 @@ pub trait RpcApi: Sized {

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

Expand Down
6 changes: 3 additions & 3 deletions client/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub enum Error {
BitcoinSerialization(bitcoin::consensus::encode::Error),
Secp256k1(secp256k1::Error),
Io(io::Error),
InvalidAmount(bitcoin::util::amount::ParseAmountError),
InvalidAmount(bitcoin::amount::ParseAmountError),
InvalidCookieFile,
/// The JSON result had an unexpected structure.
UnexpectedStructure,
Expand Down Expand Up @@ -69,8 +69,8 @@ impl From<io::Error> for Error {
}
}

impl From<bitcoin::util::amount::ParseAmountError> for Error {
fn from(e: bitcoin::util::amount::ParseAmountError) -> Error {
impl From<bitcoin::amount::ParseAmountError> for Error {
fn from(e: bitcoin::amount::ParseAmountError) -> Error {
Error::InvalidAmount(e)
}
}
Expand Down
3 changes: 2 additions & 1 deletion integration_test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ edition = "2018"

[dependencies]
electrs-bitcoincore-rpc = { path = "../client" }
bitcoin = { version = "0.29.0", features = ["serde", "rand"]}
bitcoin = { version = "0.30.0", features = ["serde", "rand-std"]}
lazy_static = "1.4.0"
log = "0.4"
bitcoin-private = "0.1.0"
Loading