diff --git a/Cargo.lock b/Cargo.lock index 76d0888cd8..c79acea4dd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -517,6 +517,32 @@ dependencies = [ "serde", ] +[[package]] +name = "bitcoincore-rpc" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d6c0ee9354e3dac217db4cb1dd31941073a87fe53c86bcf3eb2b8bc97f00a08" +dependencies = [ + "bitcoin-private", + "bitcoincore-rpc-json", + "jsonrpc", + "log", + "serde", + "serde_json", +] + +[[package]] +name = "bitcoincore-rpc-json" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d30ce6f40fb0a2e8d98522796219282504b7a4b14e2b4c26139a7bea6aec6586" +dependencies = [ + "bitcoin", + "bitcoin-private", + "serde", + "serde_json", +] + [[package]] name = "bitflags" version = "1.3.2" @@ -2193,6 +2219,7 @@ dependencies = [ "base64 0.22.1", "bip39", "bitcoin", + "bitcoincore-rpc", "boilerplate", "brotli", "chrono", @@ -2219,7 +2246,6 @@ dependencies = [ "mockcore", "mp4", "nix", - "ord-bitcoincore-rpc", "ordinals", "pretty_assertions", "redb", diff --git a/Cargo.toml b/Cargo.toml index bf3538103e..a2b63cd8e8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,7 +47,7 @@ mime = "0.3.16" mime_guess = "2.0.4" miniscript = "10.0.0" mp4 = "0.14.0" -ord-bitcoincore-rpc = "0.17.2" +bitcoincore-rpc = "0.17.0" ordinals = { version = "0.0.10", path = "crates/ordinals" } redb = "2.1.1" ref-cast = "1.0.23" diff --git a/src/subcommand/wallet.rs b/src/subcommand/wallet.rs index fa135076d7..6ccdee909e 100644 --- a/src/subcommand/wallet.rs +++ b/src/subcommand/wallet.rs @@ -1,7 +1,6 @@ use { super::*, - crate::wallet::{batch, wallet_constructor::WalletConstructor, Wallet}, - bitcoincore_rpc::bitcoincore_rpc_json::ListDescriptorsResult, + crate::wallet::{batch, wallet_constructor::WalletConstructor, ListDescriptorsResult, Wallet}, shared_args::SharedArgs, }; diff --git a/src/subcommand/wallet/dump.rs b/src/subcommand/wallet/dump.rs index 16cf1393b5..98a3d21516 100644 --- a/src/subcommand/wallet/dump.rs +++ b/src/subcommand/wallet/dump.rs @@ -9,6 +9,8 @@ pub(crate) fn run(wallet: Wallet) -> SubcommandResult { ); Ok(Some(Box::new( - wallet.bitcoin_client().list_descriptors(Some(true))?, + wallet + .bitcoin_client() + .call::("listdescriptors", &[serde_json::to_value(true)?])?, ))) } diff --git a/src/wallet.rs b/src/wallet.rs index 4507fd1299..abc805172c 100644 --- a/src/wallet.rs +++ b/src/wallet.rs @@ -7,7 +7,7 @@ use { bip32::{ChildNumber, DerivationPath, ExtendedPrivKey, Fingerprint}, psbt::Psbt, }, - bitcoincore_rpc::bitcoincore_rpc_json::{Descriptor, ImportDescriptors, Timestamp}, + bitcoincore_rpc::bitcoincore_rpc_json::{ImportDescriptors, Timestamp}, entry::{EtchingEntry, EtchingEntryValue}, fee_rate::FeeRate, index::entry::Entry, @@ -47,6 +47,22 @@ impl From for u64 { } } +#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)] +pub struct Descriptor { + pub desc: String, + pub timestamp: bitcoincore_rpc::bitcoincore_rpc_json::Timestamp, + pub active: bool, + pub internal: Option, + pub range: Option<(u64, u64)>, + pub next: Option, +} + +#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)] +pub struct ListDescriptorsResult { + pub wallet_name: String, + pub descriptors: Vec, +} + #[derive(Debug, PartialEq)] pub(crate) enum Maturity { BelowMinimumHeight(u64), @@ -465,7 +481,7 @@ impl Wallet { }) .collect::>(); - client.import_descriptors(descriptors)?; + client.call::("importdescriptors", &[serde_json::to_value(descriptors)?])?; Ok(()) } @@ -536,7 +552,7 @@ impl Wallet { settings .bitcoin_rpc_client(Some(name.clone()))? - .import_descriptors(vec![ImportDescriptors { + .import_descriptors(ImportDescriptors { descriptor: descriptor.to_string_with_secret(&key_map), timestamp: Timestamp::Now, active: Some(true), @@ -544,7 +560,7 @@ impl Wallet { next_index: None, internal: Some(change), label: None, - }])?; + })?; Ok(()) } diff --git a/src/wallet/batch/plan.rs b/src/wallet/batch/plan.rs index c3402d3dbb..817802c0d7 100644 --- a/src/wallet/batch/plan.rs +++ b/src/wallet/batch/plan.rs @@ -687,7 +687,7 @@ impl Plan { let response = wallet .bitcoin_client() - .import_descriptors(vec![ImportDescriptors { + .import_descriptors(ImportDescriptors { descriptor: format!("rawtr({})#{}", recovery_private_key.to_wif(), info.checksum), timestamp: Timestamp::Now, active: Some(false), @@ -695,7 +695,7 @@ impl Plan { next_index: None, internal: Some(false), label: Some("commit tx recovery key".to_string()), - }])?; + })?; for result in response { if !result.success { diff --git a/src/wallet/wallet_constructor.rs b/src/wallet/wallet_constructor.rs index b42c979d19..fb75db0dff 100644 --- a/src/wallet/wallet_constructor.rs +++ b/src/wallet/wallet_constructor.rs @@ -56,7 +56,12 @@ impl WalletConstructor { } if client.get_wallet_info()?.private_keys_enabled { - Wallet::check_descriptors(&self.name, client.list_descriptors(None)?.descriptors)?; + Wallet::check_descriptors( + &self.name, + client + .call::("listdescriptors", &[serde_json::Value::Null])? + .descriptors, + )?; } client diff --git a/tests/lib.rs b/tests/lib.rs index 19dfe3670f..80f794f332 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -7,13 +7,12 @@ use { blockdata::constants::COIN_VALUE, Network, OutPoint, Sequence, Txid, Witness, }, - bitcoincore_rpc::bitcoincore_rpc_json::ListDescriptorsResult, chrono::{DateTime, Utc}, executable_path::executable_path, mockcore::TransactionTemplate, ord::{ api, chain::Chain, decimal::Decimal, outgoing::Outgoing, subcommand::runes::RuneInfo, - wallet::batch, InscriptionId, RuneEntry, + wallet::batch, wallet::ListDescriptorsResult, InscriptionId, RuneEntry, }, ordinals::{ Artifact, Charm, Edict, Pile, Rarity, Rune, RuneId, Runestone, Sat, SatPoint, SpacedRune,