diff --git a/Cargo.toml b/Cargo.toml index 0a138f5..fa7c641 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,11 +3,8 @@ name = "btcore" version = "0.1.0" edition = "2021" -[lib] -name = "btcore" - [dependencies] -bitcoin = { version= "0.29.0", features=["std"], default-features = false } -bitcoincore-rpc = { branch = "master", git = "https://github.com/bipa-app/rust-bitcoincore-rpc.git"} +bitcoin = { version= "0.30.0", features = ["std"], default-features = false } +bitcoincore-rpc = { version = "0.17.0", default-features = false } tokio = { version = "1.12.0", features = ["rt", "macros"], default-features = false } tracing = { version = "0.1.37", default-features = false } diff --git a/src/lib.rs b/src/lib.rs index c885bcd..d8f30a0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,10 +1,10 @@ -use bitcoin::{Address, Amount, BlockHash, Txid}; +use bitcoin::{address::NetworkUnchecked, Address, Amount, BlockHash, Txid}; use bitcoincore_rpc::{ bitcoincore_rpc_json::GetTransactionResult, json::{AddressType, GetBalancesResult, ListTransactionResult}, RpcApi, }; -use std::{collections::HashMap, future::Future, sync::Arc}; +use std::{future::Future, sync::Arc}; use tracing::Instrument; pub use bitcoincore_rpc as rpc; @@ -98,72 +98,10 @@ impl Btc { .instrument(span!("gettransaction")) } - pub fn send_to_address( - &self, - address: Address, - amount_satoshi: i64, - fee_rate: Option, - ) -> impl Future> { - let client = self.client.clone(); - - async move { - tokio::task::spawn_blocking(move || { - client.send_to_address( - &address, - Amount::from_sat(amount_satoshi as u64), - Some(""), - Some(""), - Some(true), - Some(true), - None, - None, - None, - fee_rate, - ) - }) - .await - .unwrap() - } - .instrument(span!("sendtoaddress")) - } - - pub fn send_many( - &self, - addresses: HashMap, - fee_rate: i32, - ) -> impl Future> { - let client = self.client.clone(); - - async move { - tokio::task::spawn_blocking(move || { - client.send_many( - addresses, - Some(""), - None, - Some(true), - None, - None, - Some(fee_rate), - ) - }) - .await - .unwrap() - } - .instrument(span!("sendmany")) - } - - /// DANGEROUS: this call will block the thread. it is not safe unless you know what you're doing. - pub fn generate_address_blocking( - &self, - address_type: AddressType, - ) -> bitcoincore_rpc::Result
{ - self.client.get_new_address(None, Some(address_type)) - } - - pub fn generate_address_async( + pub fn generate_address( &self, address_type: AddressType, - ) -> impl Future> { + ) -> impl Future>> { let client = self.client.clone(); async move {