From 0a5785cb91959d39e836a2a1aef25710c4385e12 Mon Sep 17 00:00:00 2001 From: GideonBature Date: Mon, 21 Apr 2025 21:22:09 +0100 Subject: [PATCH] Implement version-specific types for omitted methods --- client/src/client_sync/error.rs | 7 + client/src/client_sync/mod.rs | 142 ++++++ client/src/client_sync/v17/blockchain.rs | 98 ++++ client/src/client_sync/v17/mod.rs | 44 +- client/src/client_sync/v17/network.rs | 206 ++++++++ client/src/client_sync/v17/wallet.rs | 456 ++++++++++++++++++ client/src/client_sync/v18/blockchain.rs | 39 ++ client/src/client_sync/v18/mod.rs | 40 +- client/src/client_sync/v19/blockchain.rs | 29 ++ client/src/client_sync/v19/mod.rs | 39 +- client/src/client_sync/{v20.rs => v20/mod.rs} | 41 +- client/src/client_sync/v20/network.rs | 22 + client/src/client_sync/v20/wallet.rs | 32 ++ client/src/client_sync/v21/mod.rs | 40 +- client/src/client_sync/v22/blockchain.rs | 29 ++ client/src/client_sync/v22/mod.rs | 40 +- client/src/client_sync/v23/blockchain.rs | 20 + client/src/client_sync/v23/mod.rs | 41 +- client/src/client_sync/v24.rs | 40 +- client/src/client_sync/v25/blockchain.rs | 39 ++ client/src/client_sync/{v25.rs => v25/mod.rs} | 41 +- client/src/client_sync/v26/mod.rs | 41 +- client/src/client_sync/v26/network.rs | 39 ++ client/src/client_sync/v27.rs | 40 +- client/src/client_sync/v28/blockchain.rs | 39 ++ client/src/client_sync/v28/mod.rs | 42 +- integration_test/Cargo.toml | 3 +- integration_test/src/lib.rs | 1 + integration_test/tests/blockchain.rs | 133 +++++ integration_test/tests/network.rs | 242 ++++++++++ integration_test/tests/wallet.rs | 446 ++++++++++++++++- types/src/v17/blockchain/mod.rs | 84 ++++ types/src/v17/mod.rs | 31 +- types/src/v17/network/mod.rs | 103 +++- types/src/v17/wallet/mod.rs | 252 ++++++++++ types/src/v18/blockchain.rs | 51 ++ types/src/v18/mod.rs | 56 ++- types/src/v19/blockchain/mod.rs | 37 ++ types/src/v19/mod.rs | 56 ++- types/src/v20/mod.rs | 54 ++- types/src/v20/network.rs | 21 + types/src/v20/wallet.rs | 31 ++ types/src/v21/mod.rs | 54 ++- types/src/v22/blockchain.rs | 18 + types/src/v22/mod.rs | 48 +- types/src/v23/blockchain.rs | 18 + types/src/v23/mod.rs | 51 +- types/src/v24/mod.rs | 50 +- types/src/v25/blockchain.rs | 71 +++ types/src/v25/mod.rs | 38 +- types/src/v26/mod.rs | 36 +- types/src/v27/mod.rs | 36 +- types/src/v28/blockchain.rs | 67 +++ types/src/v28/mod.rs | 42 +- types/src/v28/wallet.rs | 132 +++++ verify/rpc-api-v17.txt | 4 +- verify/src/method/v17.rs | 55 +-- verify/src/method/v18.rs | 55 +-- verify/src/method/v19.rs | 55 +-- verify/src/method/v20.rs | 55 +-- verify/src/method/v21.rs | 55 +-- verify/src/method/v22.rs | 55 +-- verify/src/method/v23.rs | 56 +-- verify/src/method/v24.rs | 56 +-- verify/src/method/v25.rs | 56 +-- verify/src/method/v26.rs | 56 +-- verify/src/method/v27.rs | 56 +-- verify/src/method/v28.rs | 56 +-- 68 files changed, 4029 insertions(+), 589 deletions(-) create mode 100644 client/src/client_sync/v18/blockchain.rs rename client/src/client_sync/{v20.rs => v20/mod.rs} (71%) create mode 100644 client/src/client_sync/v20/network.rs create mode 100644 client/src/client_sync/v20/wallet.rs create mode 100644 client/src/client_sync/v23/blockchain.rs create mode 100644 client/src/client_sync/v25/blockchain.rs rename client/src/client_sync/{v25.rs => v25/mod.rs} (70%) create mode 100644 client/src/client_sync/v26/network.rs create mode 100644 client/src/client_sync/v28/blockchain.rs create mode 100644 types/src/v18/blockchain.rs create mode 100644 types/src/v20/network.rs create mode 100644 types/src/v20/wallet.rs create mode 100644 types/src/v23/blockchain.rs create mode 100644 types/src/v25/blockchain.rs create mode 100644 types/src/v28/wallet.rs diff --git a/client/src/client_sync/error.rs b/client/src/client_sync/error.rs index 112f3cab..60cf09be 100644 --- a/client/src/client_sync/error.rs +++ b/client/src/client_sync/error.rs @@ -24,6 +24,10 @@ pub enum Error { ServerVersion(UnexpectedServerVersionError), /// Missing user/password MissingUserPassword, + /// Invalid arguments for disconnect_node: Both address and nodeid provided + DisconnectNodeArgsBoth, + /// Invalid arguments for disconnect_node: Neither address nor nodeid provided. + DisconnectNodeArgsNone, } impl From for Error { @@ -76,6 +80,8 @@ impl fmt::Display for Error { Returned(ref s) => write!(f, "the daemon returned an error string: {}", s), ServerVersion(ref e) => write!(f, "server version: {}", e), MissingUserPassword => write!(f, "missing user and/or password"), + DisconnectNodeArgsBoth => write!(f, "invalid arguments for disconnect_node: provide either address OR nodeid, not both"), + DisconnectNodeArgsNone => write!(f, "invalid arguments for disconnect_node: provide either address OR nodeid, none given"), } } } @@ -95,6 +101,7 @@ impl error::Error for Error { InvalidAmount(ref e) => Some(e), ServerVersion(ref e) => Some(e), InvalidCookieFile | UnexpectedStructure | Returned(_) | MissingUserPassword => None, + DisconnectNodeArgsBoth | DisconnectNodeArgsNone => None, } } } diff --git a/client/src/client_sync/mod.rs b/client/src/client_sync/mod.rs index 15d4b971..4e60275c 100644 --- a/client/src/client_sync/mod.rs +++ b/client/src/client_sync/mod.rs @@ -262,3 +262,145 @@ pub enum TemplateRules { /// Taproot supported. Taproot, } + +/// Args for the `addnode` method +#[derive(Debug, Clone, Copy, Serialize)] +#[serde(rename_all = "lowercase")] +pub enum AddNodeCommand { + Add, + Remove, + OneTry, +} + +/// Args for the `setban` method +#[derive(Debug, Clone, Copy, Serialize)] +#[serde(rename_all = "lowercase")] +pub enum SetBanCommand { + Add, + Remove, +} + +/// Args for the `lockunspent` method +#[derive(Clone, Debug, PartialEq, Eq, Hash, Deserialize, Serialize)] +pub struct LockUnspentOutput { + /// The transaction id + pub txid: Txid, + /// The output number + pub vout: u32, +} + +/// Args for the `scantxoutset` +/// +/// Represents the action for the `scantxoutset` RPC call. +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)] +#[serde(rename_all = "lowercase")] +pub enum ScanAction { + Start, + Abort, + Status, +} + +/// Represents the range for HD descriptor scanning (handles n or [n, n]). +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)] +#[serde(untagged)] +pub enum ScanRange { + /// Represents the end index (beginning is 0). + Single(u64), + /// Array represents [begin, end] indexes + Range([u64; 2]), +} + +// Helper function for serde default +fn default_scan_range() -> ScanRange { + // Default range is 1000 as per Bitcoin Core docs + ScanRange::Single(1000) +} + +/// Represents a scan object for scantxoutset (descriptor string or object). +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)] +#[serde(untagged)] +pub enum ScanObject { + /// Plain descriptor string + Descriptor(String), + /// Object containing descriptor and optional range + WithRange { + desc: String, + #[serde(default = "default_scan_range")] + range: ScanRange, + }, +} + +/// Args for the `importmulti` +/// +/// Represents the scriptPubKey field in an importmulti request. +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)] +#[serde(untagged)] +pub enum ImportMultiScriptPubKey { + /// Script hex string + Script(String), + /// Address object + Address { address: String }, +} + +/// Represents the timestamp field in an importmulti request. +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)] +#[serde(untagged)] +pub enum ImportMultiTimestamp { + /// Use current blockchain time + Now(String), + /// Specific UNIX epoch time + Time(u64), +} + +impl Default for ImportMultiTimestamp { + fn default() -> Self { ImportMultiTimestamp::Now("now".to_string()) } +} + +/// Represents a single request object within the importmulti call. +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default)] +pub struct ImportMultiRequest { + /// Descriptor to import (optional, mutually exclusive with scriptPubKey/address etc.) (v18+) + #[serde(skip_serializing_if = "Option::is_none")] + pub desc: Option, + /// ScriptPubKey or address object (required unless desc is provided) + #[serde(rename = "scriptPubKey", skip_serializing_if = "Option::is_none")] + pub script_pub_key: Option, + /// Creation time of the key + pub timestamp: ImportMultiTimestamp, + /// Redeem script (P2SH/P2SH-P2WSH only) + #[serde(skip_serializing_if = "Option::is_none")] + pub redeemscript: Option, + /// Witness script (P2WSH/P2SH-P2WSH only) (v18+) + #[serde(skip_serializing_if = "Option::is_none")] + pub witnessscript: Option, + /// Pubkeys to import (cannot be used with descriptor) + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub pubkeys: Vec, + /// Private keys to import (WIF format) + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub keys: Vec, + /// Range for ranged descriptors (v18+) + #[serde(skip_serializing_if = "Option::is_none")] + pub range: Option, + /// Treat matching outputs as change + #[serde(skip_serializing_if = "Option::is_none")] + pub internal: Option, + /// Treat matching outputs as watchonly + #[serde(skip_serializing_if = "Option::is_none")] + pub watchonly: Option, + /// Label for address (use "" for default) + #[serde(skip_serializing_if = "Option::is_none")] + pub label: Option, + /// Add pubkeys to keypool (only when private keys disabled) (v18+) + #[serde(skip_serializing_if = "Option::is_none")] + pub keypool: Option, +} + +/// Represents the optional options object for importmulti +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default)] +/// Rescan after import (default true) +pub struct ImportMultiOptions { + /// Rescan after import (default true) + #[serde(skip_serializing_if = "Option::is_none")] + pub rescan: Option, +} diff --git a/client/src/client_sync/v17/blockchain.rs b/client/src/client_sync/v17/blockchain.rs index 45393c43..a26abc68 100644 --- a/client/src/client_sync/v17/blockchain.rs +++ b/client/src/client_sync/v17/blockchain.rs @@ -301,3 +301,101 @@ macro_rules! impl_client_v17__verifytxoutproof { } }; } + +/// Implements Bitcoin Core JSON-RPC API method `pruneblockchain` +#[macro_export] +macro_rules! impl_client_v17__pruneblockchain { + () => { + impl Client { + /// Instructs the node to prune the blockchain up to a specified height or timestamp. + pub fn prune_blockchain(&self, target: u64) -> Result { + self.call("pruneblockchain", &[target.into()]) + } + } + }; +} + +/// Implements Bitcoin Core JSON-RPC API method `savemempool` +#[macro_export] +macro_rules! impl_client_v17__savemempool { + () => { + impl Client { + // Dumps the mempool to disk (v17 - v22) + pub fn save_mempool(&self) -> Result { + match self.call("savemempool", &[]) { + Ok(serde_json::Value::Null) => Ok(SaveMempool), + Ok(_) => Ok(SaveMempool), + Err(e) => Err(e.into()), + } + } + } + }; +} + +/// Implements Bitcoin Core JSON-RPC API method `verifychain` +#[macro_export] +macro_rules! impl_client_v17__verifychain { + () => { + impl Client { + /// Verifies blockchain database using default checklevel and nblocks. + /// Returns true if verification finised successfully. + pub fn verify_chain_default(&self) -> Result { + // Core returns a boolean directly + self.call("verifychain", &[]) + } + + /// Verifies blockchain database with specified checklevel and nblocks. + /// + /// # Arguments + /// * `checklevel`: (0-4) How thorough the verification is (optional, defaults to 3). + /// * `nblocks`: Number of blocks to check (optional, defaults to 6, 0=all). + /// + /// Returns true if verification finished successfully. + pub fn verify_chain( + &self, + checklevel: Option, + nblocks: Option, + ) -> Result { + // Construct params carefully for optional args + // Bitcoin Core often uses positional nulls for omitted optional args + let params = match (checklevel, nblocks) { + (Some(level), Some(num)) => vec![level.into(), num.into()], + (Some(level), None) => vec![level.into()], + (None, Some(num)) => vec![serde_json::Value::Null, num.into()], + (None, None) => vec![], + }; + + self.call("verifychain", ¶ms) + } + } + }; +} + +/// Implements Bitcoin Core JSON-RPC API method `scantxoutset` +#[macro_export] +macro_rules! impl_client_v17__scantxoutset { + () => { + impl Client { + pub fn scan_tx_out_set( + &self, + action: ScanAction, + scan_objects: Option<&[ScanObject]>, + ) -> Result { + let params = match action { + ScanAction::Start => match scan_objects { + Some(objects) => + vec![serde_json::to_value(action)?, serde_json::to_value(objects)?], + None => + return Err(Error::Returned( + "scan_objects required for 'start'".to_string(), + )), + }, + ScanAction::Abort | ScanAction::Status => { + vec![serde_json::to_value(action)?] + } + }; + self.call("scantxoutset", ¶ms) + } + } + }; +} diff --git a/client/src/client_sync/v17/mod.rs b/client/src/client_sync/v17/mod.rs index e4f98fd8..96bcb720 100644 --- a/client/src/client_sync/v17/mod.rs +++ b/client/src/client_sync/v17/mod.rs @@ -19,7 +19,10 @@ use bitcoin::address::{Address, NetworkChecked}; use bitcoin::{Amount, Block, BlockHash, PublicKey, Txid}; use serde::{Deserialize, Serialize}; -use crate::client_sync::into_json; +use crate::client_sync::{ + into_json, AddNodeCommand, ImportMultiOptions, ImportMultiRequest, ScanAction, ScanObject, + SetBanCommand, +}; use crate::types::v17::*; #[rustfmt::skip] // Keep public re-exports separate. @@ -49,6 +52,10 @@ crate::impl_client_v17__gettxoutproof!(); crate::impl_client_v17__gettxoutsetinfo!(); crate::impl_client_v17__preciousblock!(); crate::impl_client_v17__verifytxoutproof!(); +crate::impl_client_v17__pruneblockchain!(); +crate::impl_client_v17__savemempool!(); +crate::impl_client_v17__verifychain!(); +crate::impl_client_v17__scantxoutset!(); // == Control == crate::impl_client_v17__getmemoryinfo!(); @@ -74,6 +81,14 @@ crate::impl_client_v17__getaddednodeinfo!(); crate::impl_client_v17__getnettotals!(); crate::impl_client_v17__getnetworkinfo!(); crate::impl_client_v17__getpeerinfo!(); +crate::impl_client_v17__addnode!(); +crate::impl_client_v17__clearbanned!(); +crate::impl_client_v17__setban!(); +crate::impl_client_v17__listbanned!(); +crate::impl_client_v17__disconnectnode!(); +crate::impl_client_v17__getconnectioncount!(); +crate::impl_client_v17__ping!(); +crate::impl_client_v17__setnetworkactive!(); // == Rawtransactions == crate::impl_client_v17__createrawtransaction!(); @@ -112,6 +127,24 @@ crate::impl_client_v17__signrawtransactionwithwallet!(); crate::impl_client_v17__unloadwallet!(); crate::impl_client_v17__walletcreatefundedpsbt!(); crate::impl_client_v17__walletprocesspsbt!(); +crate::impl_client_v17__abandontransaction!(); +crate::impl_client_v17__abortrescan!(); +crate::impl_client_v17__backupwallet!(); +crate::impl_client_v17__encryptwallet!(); +crate::impl_client_v17__importaddress!(); +crate::impl_client_v17__importprivkey!(); +crate::impl_client_v17__importprunedfunds!(); +crate::impl_client_v17__importpubkey!(); +crate::impl_client_v17__importwallet!(); +crate::impl_client_v17__keypoolrefill!(); +crate::impl_client_v17__lockunspent!(); +crate::impl_client_v17__removeprunedfunds!(); +crate::impl_client_v17__sethdseed!(); +crate::impl_client_v17__settxfee!(); +crate::impl_client_v17__walletlock!(); +crate::impl_client_v17__walletpassphrase!(); +crate::impl_client_v17__walletpassphrasechange!(); +crate::impl_client_v17__importmulti!(); /// Argument to the `Client::get_new_address_with_type` function. /// @@ -136,3 +169,12 @@ impl fmt::Display for AddressType { fmt::Display::fmt(s, f) } } + +const SATS_PER_BTC_F64: f64 = 100_000_000.0; + +pub fn fee_rate_to_rpc_arg(fee_rate: bitcoin::FeeRate) -> f64 { + let sat_per_kwu = fee_rate.to_sat_per_kwu(); + + let sat_per_kvb = (sat_per_kwu as f64) / 4.0; + sat_per_kvb / SATS_PER_BTC_F64 +} diff --git a/client/src/client_sync/v17/network.rs b/client/src/client_sync/v17/network.rs index 3719cde3..627c8730 100644 --- a/client/src/client_sync/v17/network.rs +++ b/client/src/client_sync/v17/network.rs @@ -58,3 +58,209 @@ macro_rules! impl_client_v17__getpeerinfo { } }; } + +/// Implements Bitcoin Core JSON-RPC API method `addnode` +#[macro_export] +macro_rules! impl_client_v17__addnode { + () => { + impl Client { + pub fn add_node(&self, node: &str, command: AddNodeCommand) -> Result { + let params = &[node.into(), serde_json::to_value(command)?]; + + match self.call("addnode", params) { + Ok(serde_json::Value::Null) => Ok(AddNode), + Ok(ref val) if val.is_null() => Ok(AddNode), + Ok(other) => + Err(Error::Returned(format!("addnode expected null, got: {}", other))), + Err(e) => Err(e.into()), + } + } + } + }; +} + +/// Implements Bitcoin Core JSON-RPC API method `clearbanned` +#[macro_export] +macro_rules! impl_client_v17__clearbanned { + () => { + impl Client { + pub fn clear_banned(&self) -> Result { + match self.call("clearbanned", &[]) { + Ok(serde_json::Value::Null) => Ok(ClearBanned), + Ok(ref val) if val.is_null() => Ok(ClearBanned), + Ok(other) => + Err(Error::Returned(format!("clearbanned expected null, got: {}", other))), + Err(e) => Err(e.into()), + } + } + } + }; +} + +/// Implements Bitcoin Core JSON-RPC API method `setban` +#[macro_export] +macro_rules! impl_client_v17__setban { + () => { + impl Client { + pub fn set_ban( + &self, + subnet: &str, + command: SetBanCommand, + bantime: Option, + absolute: Option, + ) -> Result { + let mut params: Vec = + vec![subnet.into(), serde_json::to_value(command)?]; + + if bantime.is_some() || absolute.is_some() { + params.push(bantime.map_or(serde_json::Value::Null, |t| t.into())); + + if let Some(abs) = absolute { + params.push(abs.into()); + } + } + + match self.call("setban", ¶ms) { + Ok(serde_json::Value::Null) => Ok(SetBan), + Ok(ref val) if val.is_null() => Ok(SetBan), + Ok(other) => + Err(Error::Returned(format!("setban expected null, got: {}", other))), + Err(e) => Err(e.into()), + } + } + } + }; +} + +/// Implements Bitcoin Core JSON-RPC API method `listbanned` +#[macro_export] +macro_rules! impl_client_v17__listbanned { + () => { + impl Client { + pub fn list_banned(&self) -> Result { self.call("listbanned", &[]) } + } + }; +} + +/// Implements Bitcoin Core JSON-RPC API method `disconnectnode` +#[macro_export] +macro_rules! impl_client_v17__disconnectnode { + () => { + impl Client { + pub fn disconnect_node( + &self, + address: Option<&str>, + nodeid: Option, + ) -> Result { + let params: Vec = match (address, nodeid) { + (Some(addr), None) => { + vec![addr.into()] + } + (None, Some(id)) => { + vec![serde_json::Value::String(String::new()), id.into()] + } + (Some(_), Some(_)) => { + return Err(Error::DisconnectNodeArgsBoth); + } + (None, None) => { + return Err(Error::DisconnectNodeArgsNone); + } + }; + + match self.call("disconnectnode", ¶ms) { + Ok(serde_json::Value::Null) => Ok(DisconnectNode), + Ok(ref val) if val.is_null() => Ok(DisconnectNode), + Ok(other) => Err(Error::Returned(format!( + "disconnectnode expected null, got: {}", + other + ))), + Err(e) => Err(e.into()), + } + } + } + }; +} + +/// Implements Bitcoin Core JSON-RPC API method `getconnectioncount` +#[macro_export] +macro_rules! impl_client_v17__getconnectioncount { + () => { + impl Client { + pub fn get_connection_count(&self) -> Result { + self.call("getconnectioncount", &[]) + } + } + }; +} + +/// Implements Bitcoin Core JSON-RPC API method `ping` +#[macro_export] +macro_rules! impl_client_v17__ping { + () => { + impl Client { + pub fn ping(&self) -> Result { + match self.call("ping", &[]) { + Ok(serde_json::Value::Null) => Ok(Ping), + Ok(ref val) if val.is_null() => Ok(Ping), + Ok(other) => + Err(Error::Returned(format!("ping expected null, got: {}", other))), + Err(e) => Err(e.into()), + } + } + } + }; +} + +/// Implements Bitcoin Core JSON-RPC API method `setnetworkactive` +#[macro_export] +macro_rules! impl_client_v17__setnetworkactive { + () => { + impl Client { + pub fn set_network_active(&self, state: bool) -> Result { + match self.call("setnetworkactive", &[state.into()]) { + Ok(serde_json::Value::Null) => Ok(SetNetworkActive), + Ok(ref val) if val.is_null() => Ok(SetNetworkActive), + Ok(other) => Err(Error::Returned(format!( + "setnetworkactive expected null, got: {}", + other + ))), + Err(e) => Err(e.into()), + } + } + } + }; +} + +/// Implements Bitcoin Core JSON-RPC API method `importprivkey` +#[macro_export] +macro_rules! impl_client_v17__importprivkey { + () => { + use bitcoin::PrivateKey; + impl Client { + pub fn import_priv_key( + &self, + privkey: &PrivateKey, + label: Option<&str>, + rescan: Option, + ) -> Result { + let privkey_wif = privkey.to_wif(); + let mut params = vec![privkey_wif.into()]; + + if label.is_some() || rescan.is_some() { + params.push(label.map_or(serde_json::Value::String("".into()), |l| l.into())); + } + + if let Some(r) = rescan { + params.push(r.into()); + } + + match self.call("importprivkey", ¶ms) { + Ok(serde_json::Value::Null) => Ok(ImportPrivKey), + Ok(ref val) if val.is_null() => Ok(ImportPrivKey), + Ok(other) => Err(Error::Returned(format!("importprivkey expected null, got: {}", other))), + Err(e) => Err(e.into()), + } + } + } + }; +} diff --git a/client/src/client_sync/v17/wallet.rs b/client/src/client_sync/v17/wallet.rs index ce8f6093..fdc6885f 100644 --- a/client/src/client_sync/v17/wallet.rs +++ b/client/src/client_sync/v17/wallet.rs @@ -53,6 +53,41 @@ macro_rules! impl_client_v17__createwallet { pub fn create_wallet(&self, wallet: &str) -> Result { self.call("createwallet", &[wallet.into()]) } + + /// Creates a legacy wallet (i.e not a native descriptor wallet). + /// + /// > createwallet "wallet_name" ( disable_private_keys blank "passphrase" avoid_reuse descriptors load_on_startup external_signer ) + /// > + /// > Creates and loads a new wallet. + /// > + /// > Arguments: + /// > 1. wallet_name (string, required) The name for the new wallet. If this is a path, the wallet will be created at the path location. + /// > 2. disable_private_keys (boolean, optional, default=false) Disable the possibility of private keys (only watchonlys are possible in this mode). + /// > 3. blank (boolean, optional, default=false) Create a blank wallet. A blank wallet has no keys or HD seed. One can be set using sethdseed. + /// > 4. passphrase (string, optional) Encrypt the wallet with this passphrase. + /// > 5. avoid_reuse (boolean, optional, default=false) Keep track of coin reuse, and treat dirty and clean coins differently with privacy considerations in mind. + /// > 6. descriptors (boolean, optional, default=true) Create a native descriptor wallet. The wallet will use descriptors internally to handle address creation + /// > 7. load_on_startup (boolean, optional) Save wallet name to persistent settings and load on startup. True to add wallet to startup list, false to remove, null to leave unchanged. + /// > 8. external_signer (boolean, optional, default=false) Use an external signer such as a hardware wallet. Requires -signer to be configured. Wallet creation will fail if keys cannot be fetched. Requires disable_private_keys and descriptors set to true. + pub fn create_legacy_wallet(&self, wallet: &str) -> Result { + let disable_private_keys = false; + let blank = false; + let passphrase = String::new(); + let avoid_reuse = false; + let descriptors = false; + + self.call( + "createwallet", + &[ + wallet.into(), + disable_private_keys.into(), + blank.into(), + passphrase.into(), + avoid_reuse.into(), + descriptors.into(), + ], + ) + } } }; } @@ -465,3 +500,424 @@ macro_rules! impl_client_v17__walletprocesspsbt { } }; } + +/// Implements Bitcoin Core JSON-RPC API method `abandontransaction` +#[macro_export] +macro_rules! impl_client_v17__abandontransaction { + () => { + impl Client { + pub fn abandon_transaction(&self, txid: Txid) -> Result { + match self.call("abandontransaction", &[into_json(txid)?]) { + Ok(serde_json::Value::Null) => Ok(AbandonTransaction), + Ok(ref val) if val.is_null() => Ok(AbandonTransaction), + Ok(other) => Err(Error::Returned(format!( + "abandontransaction expected null, got: {}", + other + ))), + Err(e) => Err(e.into()), + } + } + } + }; +} + +/// Implements Bitcoin Core JSON-RPC API method `abortrescan` +#[macro_export] +macro_rules! impl_client_v17__abortrescan { + () => { + impl Client { + pub fn abort_rescan(&self) -> Result { + match self.call("abortrescan", &[]) { + Ok(serde_json::Value::Null) => Ok(AbortRescan), + Ok(ref val) if val.is_null() => Ok(AbortRescan), + Ok(other) => + Err(Error::Returned(format!("abortrescan expected null, got: {}", other))), + Err(e) => Err(e.into()), + } + } + } + }; +} + +/// Implements Bitcoin Core JSON-RPC API method `backupwallet` +#[macro_export] +macro_rules! impl_client_v17__backupwallet { + () => { + impl Client { + pub fn backup_wallet(&self, destination: &Path) -> Result { + let dest_str = destination.to_string_lossy(); + match self.call("backupwallet", &[dest_str.as_ref().into()]) { + Ok(serde_json::Value::Null) => Ok(BackupWallet), + Ok(ref val) if val.is_null() => Ok(BackupWallet), + Ok(other) => + Err(Error::Returned(format!("backupwallet expected null, got: {}", other))), + Err(e) => Err(e.into()), + } + } + } + }; +} + +/// Implements Bitcoin Core JSON-RPC API method `encryptwallet` +#[macro_export] +macro_rules! impl_client_v17__encryptwallet { + () => { + impl Client { + pub fn encrypt_wallet(&self, passphrase: &str) -> Result { + match self.call("encryptwallet", &[passphrase.into()]) { + Ok(serde_json::Value::Null) => Ok(EncryptWallet), + Ok(ref val) if val.is_null() => Ok(EncryptWallet), + Ok(other) => Err(Error::Returned(format!( + "encryptwallet v17-v19 expected null, got: {}", + other + ))), + Err(e) => Err(e.into()), + } + } + } + }; +} + +/// Implements Bitcoin Core JSON-RPC API method `importaddress` +#[macro_export] +macro_rules! impl_client_v17__importaddress { + () => { + impl Client { + pub fn import_address( + &self, + address_or_script: &str, + label: Option<&str>, + rescan: Option, + p2sh: Option, + ) -> Result { + let mut params = vec![address_or_script.into()]; + + if label.is_some() || rescan.is_some() || p2sh.is_some() { + params.push(label.map_or(serde_json::Value::String("".into()), |l| l.into())); + } + + if rescan.is_some() || p2sh.is_some() { + params.push(rescan.map_or(true.into(), |r| r.into())); + } + + if let Some(p) = p2sh { + params.push(p.into()); + } + + match self.call("importaddress", ¶ms) { + Ok(serde_json::Value::Null) => Ok(ImportAddress), + Ok(ref val) if val.is_null() => Ok(ImportAddress), + Ok(other) => Err(Error::Returned(format!( + "importaddress expected null, got: {}", other + ))), + Err(e) => Err(e.into()), + } + } + } + }; +} + +/// Implements Bitcoin Core JSON-RPC API method `importprunedfunds` +#[macro_export] +macro_rules! impl_client_v17__importprunedfunds { + () => { + impl Client { + pub fn import_pruned_funds( + &self, + raw_transaction: &str, + txout_proof: &str, + ) -> Result { + match self.call("importprunedfunds", &[raw_transaction.into(), txout_proof.into()]) + { + Ok(serde_json::Value::Null) => Ok(ImportPrunedFunds), + Ok(ref val) if val.is_null() => Ok(ImportPrunedFunds), + Ok(other) => Err(Error::Returned(format!( + "importprunedfunds expected null, got: {}", + other + ))), + Err(e) => Err(e.into()), + } + } + } + }; +} + +/// Implements Bitcoin Core JSON-RPC API method `importpubkey` +#[macro_export] +macro_rules! impl_client_v17__importpubkey { + () => { + impl Client { + pub fn import_pubkey( + &self, + pubkey: &PublicKey, + label: Option<&str>, + rescan: Option, + ) -> Result { + let pubkey_hex = pubkey.to_string(); + let mut params = vec![pubkey_hex.into()]; + + if label.is_some() || rescan.is_some() { + params.push(label.map_or(serde_json::Value::String("".into()), |l| l.into())); + } + + if let Some(r) = rescan { + params.push(r.into()); + } + + match self.call("importpubkey", ¶ms) { + Ok(serde_json::Value::Null) => Ok(ImportPubKey), + Ok(ref val) if val.is_null() => Ok(ImportPubKey), + Ok(other) => + Err(Error::Returned(format!("importpubkey expected null, got: {}", other))), + Err(e) => Err(e.into()), + } + } + } + }; +} + +/// Implements Bitcoin Core JSON-RPC API method `importwallet` +#[macro_export] +macro_rules! impl_client_v17__importwallet { + () => { + impl Client { + pub fn import_wallet(&self, filename: &Path) -> Result { + let filename_str = filename.to_string_lossy(); + match self.call("importwallet", &[filename_str.as_ref().into()]) { + Ok(serde_json::Value::Null) => Ok(ImportWallet), + Ok(ref val) if val.is_null() => Ok(ImportWallet), + Ok(other) => + Err(Error::Returned(format!("importwallet expected null, got: {}", other))), + Err(e) => Err(e.into()), + } + } + } + }; +} + +/// Implements Bitcoin Core JSON-RPC API method `keypoolrefill` +#[macro_export] +macro_rules! impl_client_v17__keypoolrefill { + () => { + impl Client { + pub fn keypool_refill(&self, new_size: Option) -> Result { + let params = match new_size { + Some(size) => vec![size.into()], + None => vec![], + }; + + match self.call("keypoolrefill", ¶ms) { + Ok(serde_json::Value::Null) => Ok(KeypoolRefill), + Ok(ref val) if val.is_null() => Ok(KeypoolRefill), + Ok(other) => Err(Error::Returned(format!("keypoolrefill expected null, got: {}", other))), + Err(e) => Err(e.into()), + } + } + } + }; +} + +/// Implements Bitcoin Core JSON-RPC API method `lockunspent` +#[macro_export] +macro_rules! impl_client_v17__lockunspent { + () => { + use $crate::client_sync::LockUnspentOutput; + impl Client { + pub fn lock_unspent( + &self, + unlock: bool, + outputs: Option<&[LockUnspentOutput]>, + persistent: Option, + ) -> Result { + let mut params = vec![unlock.into()]; + + match outputs { + Some(outs) => params.push(serde_json::to_value(outs)?), + None => + if unlock { + params.push(serde_json::Value::Array(vec![])); + } else { + return Err(Error::Returned( + "lockunspent requires specific outputs when locking (unlock=false)" + .to_string(), + )); + }, + } + + if !unlock { + if let Some(p) = persistent { + if params.len() == 1 { + params.push(serde_json::Value::Array(vec![])); + } + params.push(p.into()); + } + } + self.call("lockunspent", ¶ms) + } + } + }; +} + +/// Implements Bitcoin Core JSON-RPC API method `removeprunedfunds` +#[macro_export] +macro_rules! impl_client_v17__removeprunedfunds { + () => { + impl Client { + pub fn remove_pruned_funds(&self, txid: Txid) -> Result { + match self.call("removeprunedfunds", &[into_json(txid)?]) { + Ok(serde_json::Value::Null) => Ok(RemovePrunedFunds), + Ok(ref val) if val.is_null() => Ok(RemovePrunedFunds), + Ok(other) => Err(Error::Returned(format!( + "removeprunedfunds expected null, got: {}", + other + ))), + Err(e) => Err(e.into()), + } + } + } + }; +} + +/// Implements Bitcoin Core JSON-RPC API method `sethdseed` +#[macro_export] +macro_rules! impl_client_v17__sethdseed { + () => { + impl Client { + pub fn set_hd_seed( + &self, + new_keypool: Option, + seed: Option<&PrivateKey>, + ) -> Result { + let mut params = vec![]; + + if new_keypool.is_some() || seed.is_some() { + params.push(new_keypool.map_or(true.into(), |k| k.into())); + } + + if let Some(s) = seed { + params.push(s.to_wif().into()); + } + + match self.call("sethdseed", ¶ms) { + Ok(serde_json::Value::Null) => Ok(SetHdSeed), + Ok(ref val) if val.is_null() => Ok(SetHdSeed), + Ok(other) => + Err(Error::Returned(format!("sethdseed expected null, got: {}", other))), + Err(e) => Err(e.into()), + } + } + } + }; +} + +/// Implements Bitcoin Core JSON-RPC API method `settxfee` +#[macro_export] +macro_rules! impl_client_v17__settxfee { + () => { + const SATS_PER_BTC_F64_SETTXFEE: f64 = 100_000_000.0; + fn fee_rate_to_rpc_arg_settxfee(fee_rate: bitcoin::FeeRate) -> f64 { + let sat_per_kwu = fee_rate.to_sat_per_kwu(); + let sat_per_kvb = (sat_per_kwu as f64) * 4.0; + sat_per_kvb / SATS_PER_BTC_F64_SETTXFEE + } + + impl Client { + pub fn set_tx_fee(&self, fee_rate: bitcoin::FeeRate) -> Result { + let amount_rpc_arg = fee_rate_to_rpc_arg_settxfee(fee_rate); + + self.call("settxfee", &[amount_rpc_arg.into()]) + } + } + }; +} + +/// Implements Bitcoin Core JSON-RPC API method `walletlock` +#[macro_export] +macro_rules! impl_client_v17__walletlock { + () => { + impl Client { + pub fn wallet_lock(&self) -> Result { + match self.call("walletlock", &[]) { + Ok(serde_json::Value::Null) => Ok(WalletLock), + Ok(ref val) if val.is_null() => Ok(WalletLock), + Ok(other) => + Err(Error::Returned(format!("walletlock expected null, got: {}", other))), + Err(e) => Err(e.into()), + } + } + } + }; +} + +/// Implements Bitcoin Core JSON-RPC API method `walletpassphrase` +#[macro_export] +macro_rules! impl_client_v17__walletpassphrase { + () => { + impl Client { + pub fn wallet_passphrase( + &self, + passphrase: &str, + timeout: u64, + ) -> Result { + match self.call("walletpassphrase", &[passphrase.into(), timeout.into()]) { + Ok(serde_json::Value::Null) => Ok(WalletPassPhrase), + Ok(ref val) if val.is_null() => Ok(WalletPassPhrase), + Ok(other) => Err(Error::Returned(format!( + "walletpassphrase expected null, got: {}", + other + ))), + Err(e) => Err(e.into()), + } + } + } + }; +} + +/// Implements Bitcoin Core JSON-RPC API method `walletpassphrasechange` +#[macro_export] +macro_rules! impl_client_v17__walletpassphrasechange { + () => { + impl Client { + pub fn wallet_passphrase_change( + &self, + old_passphrase: &str, + new_passphrase: &str, + ) -> Result { + match self + .call("walletpassphrasechange", &[old_passphrase.into(), new_passphrase.into()]) + { + Ok(serde_json::Value::Null) => Ok(WalletPassPhraseChange), + Ok(ref val) if val.is_null() => Ok(WalletPassPhraseChange), + Ok(other) => Err(Error::Returned(format!( + "walletpassphrasechange expected null, got: {}", + other + ))), + Err(e) => Err(e.into()), + } + } + } + }; +} + +/// Implements Bitcoin Core JSON-RPC API method `importmulti` +#[macro_export] +macro_rules! impl_client_v17__importmulti { + () => { + impl Client { + pub fn import_multi( + &self, + requests: &[ImportMultiRequest], + options: Option<&ImportMultiOptions>, + ) -> Result { + let mut params = vec![serde_json::to_value(requests)?]; + + if let Some(opts) = options { + if opts != &ImportMultiOptions::default() { + params.push(serde_json::to_value(opts)?); + } + } + self.call("importmulti", ¶ms) + } + } + }; +} diff --git a/client/src/client_sync/v18/blockchain.rs b/client/src/client_sync/v18/blockchain.rs new file mode 100644 index 00000000..99a4d293 --- /dev/null +++ b/client/src/client_sync/v18/blockchain.rs @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: CC0-1.0 + +//! Macros for implementing JSON-RPC methods on a client. +//! +//! Specifically this is methods found under the `== Blockchain ==` section of the +//! API docs of Bitcoin Core `v0.18`. +//! +//! All macros require `Client` to be in scope. +//! +//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. + +/// Implements Bitcoin Core JSON-RPC API method `scantxoutset` +#[macro_export] +macro_rules! impl_client_v18__scantxoutset { + () => { + impl Client { + pub fn scan_tx_out_set( + &self, + action: ScanAction, + scan_objects: Option<&[ScanObject]>, + ) -> Result { + let params = match action { + ScanAction::Start => match scan_objects { + Some(objects) => + vec![serde_json::to_value(action)?, serde_json::to_value(objects)?], + None => + return Err(Error::Returned( + "scan_objects required for 'start'".to_string(), + )), + }, + ScanAction::Abort | ScanAction::Status => { + vec![serde_json::to_value(action)?] + } + }; + self.call("scantxoutset", ¶ms) + } + } + }; +} diff --git a/client/src/client_sync/v18/mod.rs b/client/src/client_sync/v18/mod.rs index 79c731bf..8f15e5f1 100644 --- a/client/src/client_sync/v18/mod.rs +++ b/client/src/client_sync/v18/mod.rs @@ -4,6 +4,7 @@ //! //! We ignore option arguments unless they effect the shape of the returned JSON data. +pub mod blockchain; pub mod control; use std::collections::BTreeMap; @@ -12,7 +13,14 @@ use std::path::Path; use bitcoin::address::{Address, NetworkChecked}; use bitcoin::{Amount, Block, BlockHash, PublicKey, Txid}; -use crate::client_sync::into_json; +use crate::client_sync::{ + into_json, AddNodeCommand, ImportMultiOptions, ImportMultiRequest, ScanAction, ScanObject, + SetBanCommand, +}; +use crate::types::v17::{ + AddNode, ClearBanned, DisconnectNode, GetConnectionCount, ImportMulti, ImportPrivKey, Ping, + PruneBlockchain, SetBan, SetNetworkActive, +}; use crate::types::v18::*; #[rustfmt::skip] // Keep public re-exports separate. @@ -42,6 +50,10 @@ crate::impl_client_v17__gettxoutproof!(); crate::impl_client_v17__gettxoutsetinfo!(); crate::impl_client_v17__preciousblock!(); crate::impl_client_v17__verifytxoutproof!(); +crate::impl_client_v17__savemempool!(); +crate::impl_client_v17__verifychain!(); +crate::impl_client_v18__scantxoutset!(); +crate::impl_client_v17__pruneblockchain!(); // == Control == crate::impl_client_v17__getmemoryinfo!(); @@ -68,6 +80,14 @@ crate::impl_client_v17__getaddednodeinfo!(); crate::impl_client_v17__getnettotals!(); crate::impl_client_v17__getnetworkinfo!(); crate::impl_client_v17__getpeerinfo!(); +crate::impl_client_v17__addnode!(); +crate::impl_client_v17__clearbanned!(); +crate::impl_client_v17__setban!(); +crate::impl_client_v17__listbanned!(); +crate::impl_client_v17__disconnectnode!(); +crate::impl_client_v17__getconnectioncount!(); +crate::impl_client_v17__ping!(); +crate::impl_client_v17__setnetworkactive!(); // == Rawtransactions == crate::impl_client_v17__createrawtransaction!(); @@ -106,3 +126,21 @@ crate::impl_client_v17__signrawtransactionwithwallet!(); crate::impl_client_v17__unloadwallet!(); crate::impl_client_v17__walletcreatefundedpsbt!(); crate::impl_client_v17__walletprocesspsbt!(); +crate::impl_client_v17__abandontransaction!(); +crate::impl_client_v17__abortrescan!(); +crate::impl_client_v17__backupwallet!(); +crate::impl_client_v17__encryptwallet!(); +crate::impl_client_v17__importaddress!(); +crate::impl_client_v17__importprivkey!(); +crate::impl_client_v17__importprunedfunds!(); +crate::impl_client_v17__importpubkey!(); +crate::impl_client_v17__importwallet!(); +crate::impl_client_v17__keypoolrefill!(); +crate::impl_client_v17__lockunspent!(); +crate::impl_client_v17__removeprunedfunds!(); +crate::impl_client_v17__sethdseed!(); +crate::impl_client_v17__settxfee!(); +crate::impl_client_v17__walletlock!(); +crate::impl_client_v17__walletpassphrase!(); +crate::impl_client_v17__walletpassphrasechange!(); +crate::impl_client_v17__importmulti!(); diff --git a/client/src/client_sync/v19/blockchain.rs b/client/src/client_sync/v19/blockchain.rs index e4a0bba2..c179b67b 100644 --- a/client/src/client_sync/v19/blockchain.rs +++ b/client/src/client_sync/v19/blockchain.rs @@ -72,3 +72,32 @@ macro_rules! impl_client_v19__getmempoolentry { } }; } + +/// Implements Bitcoin Core JSON-RPC API method `scantxoutset` +#[macro_export] +macro_rules! impl_client_v19__scantxoutset { + () => { + impl Client { + pub fn scan_tx_out_set( + &self, + action: ScanAction, + scan_objects: Option<&[ScanObject]>, + ) -> Result { + let params = match action { + ScanAction::Start => match scan_objects { + Some(objects) => + vec![serde_json::to_value(action)?, serde_json::to_value(objects)?], + None => + return Err(Error::Returned( + "scan_objects required for 'start'".to_string(), + )), + }, + ScanAction::Abort | ScanAction::Status => { + vec![serde_json::to_value(action)?] + } + }; + self.call("scantxoutset", ¶ms) + } + } + }; +} diff --git a/client/src/client_sync/v19/mod.rs b/client/src/client_sync/v19/mod.rs index 5c2ed9d9..92dda481 100644 --- a/client/src/client_sync/v19/mod.rs +++ b/client/src/client_sync/v19/mod.rs @@ -13,7 +13,14 @@ use std::path::Path; use bitcoin::address::{Address, NetworkChecked}; use bitcoin::{Amount, Block, BlockHash, PublicKey, Txid}; -use crate::client_sync::into_json; +use crate::client_sync::{ + into_json, AddNodeCommand, ImportMultiOptions, ImportMultiRequest, ScanAction, ScanObject, + SetBanCommand, +}; +use crate::types::v17::{ + AddNode, ClearBanned, DisconnectNode, GetConnectionCount, ImportMulti, ImportPrivKey, Ping, + PruneBlockchain, SetBan, SetNetworkActive, +}; use crate::types::v19::*; #[rustfmt::skip] // Keep public re-exports separate. @@ -44,6 +51,10 @@ crate::impl_client_v17__gettxoutproof!(); crate::impl_client_v17__gettxoutsetinfo!(); crate::impl_client_v17__preciousblock!(); crate::impl_client_v17__verifytxoutproof!(); +crate::impl_client_v17__savemempool!(); +crate::impl_client_v17__verifychain!(); +crate::impl_client_v19__scantxoutset!(); +crate::impl_client_v17__pruneblockchain!(); // == Control == crate::impl_client_v17__getmemoryinfo!(); @@ -69,6 +80,14 @@ crate::impl_client_v17__getaddednodeinfo!(); crate::impl_client_v17__getnettotals!(); crate::impl_client_v17__getnetworkinfo!(); crate::impl_client_v17__getpeerinfo!(); +crate::impl_client_v17__addnode!(); +crate::impl_client_v17__clearbanned!(); +crate::impl_client_v17__setban!(); +crate::impl_client_v17__listbanned!(); +crate::impl_client_v17__disconnectnode!(); +crate::impl_client_v17__getconnectioncount!(); +crate::impl_client_v17__ping!(); +crate::impl_client_v17__setnetworkactive!(); // == Rawtransactions == crate::impl_client_v17__createrawtransaction!(); @@ -108,3 +127,21 @@ crate::impl_client_v17__signrawtransactionwithwallet!(); crate::impl_client_v17__unloadwallet!(); crate::impl_client_v17__walletcreatefundedpsbt!(); crate::impl_client_v17__walletprocesspsbt!(); +crate::impl_client_v17__abandontransaction!(); +crate::impl_client_v17__abortrescan!(); +crate::impl_client_v17__backupwallet!(); +crate::impl_client_v17__encryptwallet!(); +crate::impl_client_v17__importaddress!(); +crate::impl_client_v17__importprivkey!(); +crate::impl_client_v17__importprunedfunds!(); +crate::impl_client_v17__importpubkey!(); +crate::impl_client_v17__importwallet!(); +crate::impl_client_v17__keypoolrefill!(); +crate::impl_client_v17__lockunspent!(); +crate::impl_client_v17__removeprunedfunds!(); +crate::impl_client_v17__sethdseed!(); +crate::impl_client_v17__settxfee!(); +crate::impl_client_v17__walletlock!(); +crate::impl_client_v17__walletpassphrase!(); +crate::impl_client_v17__walletpassphrasechange!(); +crate::impl_client_v17__importmulti!(); diff --git a/client/src/client_sync/v20.rs b/client/src/client_sync/v20/mod.rs similarity index 71% rename from client/src/client_sync/v20.rs rename to client/src/client_sync/v20/mod.rs index 488ea744..f1754743 100644 --- a/client/src/client_sync/v20.rs +++ b/client/src/client_sync/v20/mod.rs @@ -3,6 +3,8 @@ //! A JSON-RPC client for testing against Bitcoin Core `v0.20`. //! //! We ignore option arguments unless they effect the shape of the returned JSON data. +pub mod network; +pub mod wallet; use std::collections::BTreeMap; use std::path::Path; @@ -10,7 +12,14 @@ use std::path::Path; use bitcoin::address::{Address, NetworkChecked}; use bitcoin::{Amount, Block, BlockHash, PublicKey, Txid}; -use crate::client_sync::into_json; +use crate::client_sync::{ + into_json, AddNodeCommand, ImportMultiOptions, ImportMultiRequest, ScanAction, ScanObject, + SetBanCommand, +}; +use crate::types::v17::{ + AddNode, ClearBanned, DisconnectNode, GetConnectionCount, ImportMulti, ImportPrivKey, Ping, + PruneBlockchain, SetBan, +}; use crate::types::v20::*; #[rustfmt::skip] // Keep public re-exports separate. @@ -41,6 +50,10 @@ crate::impl_client_v17__gettxoutproof!(); crate::impl_client_v17__gettxoutsetinfo!(); crate::impl_client_v17__preciousblock!(); crate::impl_client_v17__verifytxoutproof!(); +crate::impl_client_v17__savemempool!(); +crate::impl_client_v17__verifychain!(); +crate::impl_client_v19__scantxoutset!(); +crate::impl_client_v17__pruneblockchain!(); // == Control == crate::impl_client_v17__getmemoryinfo!(); @@ -66,6 +79,14 @@ crate::impl_client_v17__getaddednodeinfo!(); crate::impl_client_v17__getnettotals!(); crate::impl_client_v17__getnetworkinfo!(); crate::impl_client_v17__getpeerinfo!(); +crate::impl_client_v17__addnode!(); +crate::impl_client_v17__clearbanned!(); +crate::impl_client_v17__setban!(); +crate::impl_client_v17__listbanned!(); +crate::impl_client_v17__disconnectnode!(); +crate::impl_client_v17__getconnectioncount!(); +crate::impl_client_v17__ping!(); +crate::impl_client_v20__setnetworkactive!(); // == Rawtransactions == crate::impl_client_v17__createrawtransaction!(); @@ -105,3 +126,21 @@ crate::impl_client_v17__signrawtransactionwithwallet!(); crate::impl_client_v17__unloadwallet!(); crate::impl_client_v17__walletcreatefundedpsbt!(); crate::impl_client_v17__walletprocesspsbt!(); +crate::impl_client_v17__abandontransaction!(); +crate::impl_client_v20__abortrescan!(); +crate::impl_client_v17__backupwallet!(); +crate::impl_client_v20__encryptwallet!(); +crate::impl_client_v17__importaddress!(); +crate::impl_client_v17__importprivkey!(); +crate::impl_client_v17__importprunedfunds!(); +crate::impl_client_v17__importpubkey!(); +crate::impl_client_v17__importwallet!(); +crate::impl_client_v17__keypoolrefill!(); +crate::impl_client_v17__lockunspent!(); +crate::impl_client_v17__removeprunedfunds!(); +crate::impl_client_v17__sethdseed!(); +crate::impl_client_v17__settxfee!(); +crate::impl_client_v17__walletlock!(); +crate::impl_client_v17__walletpassphrase!(); +crate::impl_client_v17__walletpassphrasechange!(); +crate::impl_client_v17__importmulti!(); diff --git a/client/src/client_sync/v20/network.rs b/client/src/client_sync/v20/network.rs new file mode 100644 index 00000000..116a7a6d --- /dev/null +++ b/client/src/client_sync/v20/network.rs @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: CC0-1.0 + +//! Macros for implementing JSON-RPC methods on a client. +//! +//! Requires `Client` to be in scope. +//! +//! Specifically this is methods found under the `== Network ==` section of the +//! API docs of Bitcoin Core `v0.20`. +//! +//! See, or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. + +/// Implements Bitcoin Core JSON-RPC API method `setnetworkactive` +#[macro_export] +macro_rules! impl_client_v20__setnetworkactive { + () => { + impl Client { + pub fn set_network_active(&self, state: bool) -> Result { + self.call("setnetworkactive", &[state.into()]) + } + } + }; +} diff --git a/client/src/client_sync/v20/wallet.rs b/client/src/client_sync/v20/wallet.rs new file mode 100644 index 00000000..4b11d6e5 --- /dev/null +++ b/client/src/client_sync/v20/wallet.rs @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: CC0-1.0 + +//! Macros for implementing JSON-RPC methods on a client. +//! +//! Specifically this is methods found under the `== Wallet ==` section of the +//! API docs of Bitcoin Core `v21`. +//! +//! All macros require `Client` to be in scope. +//! +//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. + +/// Implements Bitcoin Core JSON-RPC API method `abortrescan` +#[macro_export] +macro_rules! impl_client_v20__abortrescan { + () => { + impl Client { + pub fn abort_rescan(&self) -> Result { self.call("abortrescan", &[]) } + } + }; +} + +/// Implements Bitcoin Core JSON-RPC API method `encryptwallet` +#[macro_export] +macro_rules! impl_client_v20__encryptwallet { + () => { + impl Client { + pub fn encrypt_wallet(&self, passphrase: &str) -> Result { + self.call("encryptwallet", &[passphrase.into()]) + } + } + }; +} diff --git a/client/src/client_sync/v21/mod.rs b/client/src/client_sync/v21/mod.rs index 6c1bd42a..113d9242 100644 --- a/client/src/client_sync/v21/mod.rs +++ b/client/src/client_sync/v21/mod.rs @@ -12,7 +12,15 @@ use std::path::Path; use bitcoin::address::{Address, NetworkChecked}; use bitcoin::{Amount, Block, BlockHash, PublicKey, Txid}; -use crate::client_sync::into_json; +use crate::client_sync::{ + into_json, AddNodeCommand, ImportMultiOptions, ImportMultiRequest, ScanAction, ScanObject, + SetBanCommand, +}; +use crate::types::v17::{ + AddNode, ClearBanned, DisconnectNode, GetConnectionCount, ImportMulti, ImportPrivKey, Ping, + PruneBlockchain, SetBan, SetNetworkActive, +}; +use crate::types::v20::*; use crate::types::v21::*; #[rustfmt::skip] // Keep public re-exports separate. @@ -43,6 +51,10 @@ crate::impl_client_v17__gettxoutproof!(); crate::impl_client_v17__gettxoutsetinfo!(); crate::impl_client_v17__preciousblock!(); crate::impl_client_v17__verifytxoutproof!(); +crate::impl_client_v17__savemempool!(); +crate::impl_client_v17__verifychain!(); +crate::impl_client_v19__scantxoutset!(); +crate::impl_client_v17__pruneblockchain!(); // == Control == crate::impl_client_v17__getmemoryinfo!(); @@ -68,6 +80,14 @@ crate::impl_client_v17__getaddednodeinfo!(); crate::impl_client_v17__getnettotals!(); crate::impl_client_v17__getnetworkinfo!(); crate::impl_client_v17__getpeerinfo!(); +crate::impl_client_v17__addnode!(); +crate::impl_client_v17__clearbanned!(); +crate::impl_client_v17__setban!(); +crate::impl_client_v17__listbanned!(); +crate::impl_client_v17__disconnectnode!(); +crate::impl_client_v17__getconnectioncount!(); +crate::impl_client_v17__ping!(); +crate::impl_client_v20__setnetworkactive!(); // == Rawtransactions == crate::impl_client_v17__createrawtransaction!(); @@ -107,3 +127,21 @@ crate::impl_client_v17__signrawtransactionwithwallet!(); crate::impl_client_v21__unloadwallet!(); crate::impl_client_v17__walletcreatefundedpsbt!(); crate::impl_client_v17__walletprocesspsbt!(); +crate::impl_client_v17__abandontransaction!(); +crate::impl_client_v20__abortrescan!(); +crate::impl_client_v17__backupwallet!(); +crate::impl_client_v20__encryptwallet!(); +crate::impl_client_v17__importaddress!(); +crate::impl_client_v17__importprivkey!(); +crate::impl_client_v17__importprunedfunds!(); +crate::impl_client_v17__importpubkey!(); +crate::impl_client_v17__importwallet!(); +crate::impl_client_v17__keypoolrefill!(); +crate::impl_client_v17__lockunspent!(); +crate::impl_client_v17__removeprunedfunds!(); +crate::impl_client_v17__sethdseed!(); +crate::impl_client_v17__settxfee!(); +crate::impl_client_v17__walletlock!(); +crate::impl_client_v17__walletpassphrase!(); +crate::impl_client_v17__walletpassphrasechange!(); +crate::impl_client_v17__importmulti!(); diff --git a/client/src/client_sync/v22/blockchain.rs b/client/src/client_sync/v22/blockchain.rs index df90c8a3..da3b0944 100644 --- a/client/src/client_sync/v22/blockchain.rs +++ b/client/src/client_sync/v22/blockchain.rs @@ -20,3 +20,32 @@ macro_rules! impl_client_v22__gettxout { } }; } + +/// Implements Bitcoin Core JSON-RPC API method `scantxoutset` +#[macro_export] +macro_rules! impl_client_v22__scantxoutset { + () => { + impl Client { + pub fn scan_tx_out_set( + &self, + action: ScanAction, + scan_objects: Option<&[ScanObject]>, + ) -> Result { + let params = match action { + ScanAction::Start => match scan_objects { + Some(objects) => + vec![serde_json::to_value(action)?, serde_json::to_value(objects)?], + None => + return Err(Error::Returned( + "scan_objects required for 'start'".to_string(), + )), + }, + ScanAction::Abort | ScanAction::Status => { + vec![serde_json::to_value(action)?] + } + }; + self.call("scantxoutset", ¶ms) + } + } + }; +} diff --git a/client/src/client_sync/v22/mod.rs b/client/src/client_sync/v22/mod.rs index 3ad79a4b..16fb0965 100644 --- a/client/src/client_sync/v22/mod.rs +++ b/client/src/client_sync/v22/mod.rs @@ -13,7 +13,15 @@ use std::path::Path; use bitcoin::address::{Address, NetworkChecked}; use bitcoin::{Amount, Block, BlockHash, PublicKey, Txid}; -use crate::client_sync::into_json; +use crate::client_sync::{ + into_json, AddNodeCommand, ImportMultiOptions, ImportMultiRequest, ScanAction, ScanObject, + SetBanCommand, +}; +use crate::types::v17::{ + AddNode, ClearBanned, DisconnectNode, GetConnectionCount, ImportMulti, ImportPrivKey, Ping, + PruneBlockchain, SetBan, SetNetworkActive, +}; +use crate::types::v20::EncryptWallet; use crate::types::v22::*; #[rustfmt::skip] // Keep public re-exports separate. @@ -44,6 +52,10 @@ crate::impl_client_v17__gettxoutproof!(); crate::impl_client_v17__gettxoutsetinfo!(); crate::impl_client_v17__preciousblock!(); crate::impl_client_v17__verifytxoutproof!(); +crate::impl_client_v17__savemempool!(); +crate::impl_client_v17__verifychain!(); +crate::impl_client_v22__scantxoutset!(); +crate::impl_client_v17__pruneblockchain!(); // == Control == crate::impl_client_v17__getmemoryinfo!(); @@ -69,6 +81,14 @@ crate::impl_client_v17__getaddednodeinfo!(); crate::impl_client_v17__getnettotals!(); crate::impl_client_v17__getnetworkinfo!(); crate::impl_client_v17__getpeerinfo!(); +crate::impl_client_v17__addnode!(); +crate::impl_client_v17__clearbanned!(); +crate::impl_client_v17__setban!(); +crate::impl_client_v17__listbanned!(); +crate::impl_client_v17__disconnectnode!(); +crate::impl_client_v17__getconnectioncount!(); +crate::impl_client_v17__ping!(); +crate::impl_client_v20__setnetworkactive!(); // == Rawtransactions == crate::impl_client_v17__createrawtransaction!(); @@ -108,3 +128,21 @@ crate::impl_client_v17__signrawtransactionwithwallet!(); crate::impl_client_v21__unloadwallet!(); crate::impl_client_v17__walletcreatefundedpsbt!(); crate::impl_client_v17__walletprocesspsbt!(); +crate::impl_client_v17__abandontransaction!(); +crate::impl_client_v20__abortrescan!(); +crate::impl_client_v17__backupwallet!(); +crate::impl_client_v20__encryptwallet!(); +crate::impl_client_v17__importaddress!(); +crate::impl_client_v17__importprivkey!(); +crate::impl_client_v17__importprunedfunds!(); +crate::impl_client_v17__importpubkey!(); +crate::impl_client_v17__importwallet!(); +crate::impl_client_v17__keypoolrefill!(); +crate::impl_client_v17__lockunspent!(); +crate::impl_client_v17__removeprunedfunds!(); +crate::impl_client_v17__sethdseed!(); +crate::impl_client_v17__settxfee!(); +crate::impl_client_v17__walletlock!(); +crate::impl_client_v17__walletpassphrase!(); +crate::impl_client_v17__walletpassphrasechange!(); +crate::impl_client_v17__importmulti!(); diff --git a/client/src/client_sync/v23/blockchain.rs b/client/src/client_sync/v23/blockchain.rs new file mode 100644 index 00000000..e7855ec0 --- /dev/null +++ b/client/src/client_sync/v23/blockchain.rs @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: CC0-1.0 + +//! Macros for implementing JSON-RPC methods on a client. +//! +//! Specifically this is methods found under the `== Blockchain ==` section of the +//! API docs of Bitcoin Core `v0.23`. +//! +//! All macros require `Client` to be in scope. +//! +//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. + +/// Implements Bitcoin Core JSON-RPC API method `savemempool` +#[macro_export] +macro_rules! impl_client_v23__savemempool { + () => { + impl Client { + pub fn save_mempool(&self) -> Result { self.call("savemempool", &[]) } + } + }; +} diff --git a/client/src/client_sync/v23/mod.rs b/client/src/client_sync/v23/mod.rs index f500d8c0..df325d75 100644 --- a/client/src/client_sync/v23/mod.rs +++ b/client/src/client_sync/v23/mod.rs @@ -4,6 +4,7 @@ //! //! We ignore option arguments unless they effect the shape of the returned JSON data. +pub mod blockchain; pub mod wallet; use std::collections::BTreeMap; @@ -13,7 +14,15 @@ use bitcoin::address::{Address, NetworkChecked}; use bitcoin::{Amount, Block, BlockHash, PublicKey, Txid}; use serde::{Deserialize, Serialize}; -use crate::client_sync::into_json; +use crate::client_sync::{ + into_json, AddNodeCommand, ImportMultiOptions, ImportMultiRequest, ScanAction, ScanObject, + SetBanCommand, +}; +use crate::types::v17::{ + AddNode, ClearBanned, DisconnectNode, GetConnectionCount, ImportMulti, ImportPrivKey, Ping, + PruneBlockchain, SetBan, SetNetworkActive, +}; +use crate::types::v20::EncryptWallet; use crate::types::v23::*; #[rustfmt::skip] // Keep public re-exports separate. @@ -44,6 +53,10 @@ crate::impl_client_v17__gettxoutproof!(); crate::impl_client_v17__gettxoutsetinfo!(); crate::impl_client_v17__preciousblock!(); crate::impl_client_v17__verifytxoutproof!(); +crate::impl_client_v23__savemempool!(); +crate::impl_client_v17__verifychain!(); +crate::impl_client_v22__scantxoutset!(); +crate::impl_client_v17__pruneblockchain!(); // == Control == crate::impl_client_v17__getmemoryinfo!(); @@ -69,6 +82,14 @@ crate::impl_client_v17__getaddednodeinfo!(); crate::impl_client_v17__getnettotals!(); crate::impl_client_v17__getnetworkinfo!(); crate::impl_client_v17__getpeerinfo!(); +crate::impl_client_v17__addnode!(); +crate::impl_client_v17__clearbanned!(); +crate::impl_client_v17__setban!(); +crate::impl_client_v17__listbanned!(); +crate::impl_client_v17__disconnectnode!(); +crate::impl_client_v17__getconnectioncount!(); +crate::impl_client_v17__ping!(); +crate::impl_client_v20__setnetworkactive!(); // == Rawtransactions == crate::impl_client_v17__createrawtransaction!(); @@ -108,6 +129,24 @@ crate::impl_client_v17__signrawtransactionwithwallet!(); crate::impl_client_v21__unloadwallet!(); crate::impl_client_v17__walletcreatefundedpsbt!(); crate::impl_client_v17__walletprocesspsbt!(); +crate::impl_client_v17__abandontransaction!(); +crate::impl_client_v20__abortrescan!(); +crate::impl_client_v17__backupwallet!(); +crate::impl_client_v20__encryptwallet!(); +crate::impl_client_v17__importaddress!(); +crate::impl_client_v17__importprivkey!(); +crate::impl_client_v17__importprunedfunds!(); +crate::impl_client_v17__importpubkey!(); +crate::impl_client_v17__importwallet!(); +crate::impl_client_v17__keypoolrefill!(); +crate::impl_client_v17__lockunspent!(); +crate::impl_client_v17__removeprunedfunds!(); +crate::impl_client_v17__sethdseed!(); +crate::impl_client_v17__settxfee!(); +crate::impl_client_v17__walletlock!(); +crate::impl_client_v17__walletpassphrase!(); +crate::impl_client_v17__walletpassphrasechange!(); +crate::impl_client_v17__importmulti!(); /// Argument to the `Client::get_new_address_with_type` function. /// diff --git a/client/src/client_sync/v24.rs b/client/src/client_sync/v24.rs index 026583a0..b897d24e 100644 --- a/client/src/client_sync/v24.rs +++ b/client/src/client_sync/v24.rs @@ -10,7 +10,15 @@ use std::path::Path; use bitcoin::address::{Address, NetworkChecked}; use bitcoin::{Amount, Block, BlockHash, PublicKey, Txid}; -use crate::client_sync::into_json; +use crate::client_sync::{ + into_json, AddNodeCommand, ImportMultiOptions, ImportMultiRequest, ScanAction, ScanObject, + SetBanCommand, +}; +use crate::types::v17::{ + AddNode, ClearBanned, DisconnectNode, GetConnectionCount, ImportMulti, ImportPrivKey, Ping, + PruneBlockchain, RemovePrunedFunds, SetBan, SetNetworkActive, +}; +use crate::types::v20::EncryptWallet; use crate::types::v24::*; #[rustfmt::skip] // Keep public re-exports separate. @@ -41,6 +49,10 @@ crate::impl_client_v17__gettxoutproof!(); crate::impl_client_v17__gettxoutsetinfo!(); crate::impl_client_v17__preciousblock!(); crate::impl_client_v17__verifytxoutproof!(); +crate::impl_client_v23__savemempool!(); +crate::impl_client_v17__verifychain!(); +crate::impl_client_v22__scantxoutset!(); +crate::impl_client_v17__pruneblockchain!(); // == Control == crate::impl_client_v17__getmemoryinfo!(); @@ -66,6 +78,14 @@ crate::impl_client_v17__getaddednodeinfo!(); crate::impl_client_v17__getnettotals!(); crate::impl_client_v17__getnetworkinfo!(); crate::impl_client_v17__getpeerinfo!(); +crate::impl_client_v17__addnode!(); +crate::impl_client_v17__clearbanned!(); +crate::impl_client_v17__setban!(); +crate::impl_client_v17__listbanned!(); +crate::impl_client_v17__disconnectnode!(); +crate::impl_client_v17__getconnectioncount!(); +crate::impl_client_v17__ping!(); +crate::impl_client_v20__setnetworkactive!(); // == Rawtransactions == crate::impl_client_v17__createrawtransaction!(); @@ -105,3 +125,21 @@ crate::impl_client_v17__signrawtransactionwithwallet!(); crate::impl_client_v21__unloadwallet!(); crate::impl_client_v17__walletcreatefundedpsbt!(); crate::impl_client_v17__walletprocesspsbt!(); +crate::impl_client_v17__abandontransaction!(); +crate::impl_client_v20__abortrescan!(); +crate::impl_client_v17__backupwallet!(); +crate::impl_client_v20__encryptwallet!(); +crate::impl_client_v17__importaddress!(); +crate::impl_client_v17__importprivkey!(); +crate::impl_client_v17__importprunedfunds!(); +crate::impl_client_v17__importpubkey!(); +crate::impl_client_v17__importwallet!(); +crate::impl_client_v17__keypoolrefill!(); +crate::impl_client_v17__lockunspent!(); +crate::impl_client_v17__removeprunedfunds!(); +crate::impl_client_v17__sethdseed!(); +crate::impl_client_v17__settxfee!(); +crate::impl_client_v17__walletlock!(); +crate::impl_client_v17__walletpassphrase!(); +crate::impl_client_v17__walletpassphrasechange!(); +crate::impl_client_v17__importmulti!(); diff --git a/client/src/client_sync/v25/blockchain.rs b/client/src/client_sync/v25/blockchain.rs new file mode 100644 index 00000000..2e99a74e --- /dev/null +++ b/client/src/client_sync/v25/blockchain.rs @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: CC0-1.0 + +//! Macros for implementing JSON-RPC methods on a client. +//! +//! Specifically this is methods found under the `== Blockchain ==` section of the +//! API docs of Bitcoin Core `v25`. +//! +//! All macros require `Client` to be in scope. +//! +//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. + +/// Implements Bitcoin Core JSON-RPC API method `scantxoutset` +#[macro_export] +macro_rules! impl_client_v25__scantxoutset { + () => { + impl Client { + pub fn scan_tx_out_set( + &self, + action: ScanAction, + scan_objects: Option<&[ScanObject]>, + ) -> Result { + let params = match action { + ScanAction::Start => match scan_objects { + Some(objects) => + vec![serde_json::to_value(action)?, serde_json::to_value(objects)?], + None => + return Err(Error::Returned( + "scan_objects required for 'start'".to_string(), + )), + }, + ScanAction::Abort | ScanAction::Status => { + vec![serde_json::to_value(action)?] + } + }; + self.call("scantxoutset", ¶ms) + } + } + }; +} diff --git a/client/src/client_sync/v25.rs b/client/src/client_sync/v25/mod.rs similarity index 70% rename from client/src/client_sync/v25.rs rename to client/src/client_sync/v25/mod.rs index f9e3cd6d..5bccbbd1 100644 --- a/client/src/client_sync/v25.rs +++ b/client/src/client_sync/v25/mod.rs @@ -3,6 +3,7 @@ //! A JSON-RPC client for testing against Bitcoin Core `v25`. //! //! We ignore option arguments unless they effect the shape of the returned JSON data. +mod blockchain; use std::collections::BTreeMap; use std::path::Path; @@ -10,7 +11,15 @@ use std::path::Path; use bitcoin::address::{Address, NetworkChecked}; use bitcoin::{Amount, Block, BlockHash, PublicKey, Txid}; -use crate::client_sync::into_json; +use crate::client_sync::{ + into_json, AddNodeCommand, ImportMultiOptions, ImportMultiRequest, ScanAction, ScanObject, + SetBanCommand, +}; +use crate::types::v17::{ + AddNode, ClearBanned, DisconnectNode, GetConnectionCount, ImportMulti, ImportPrivKey, Ping, + PruneBlockchain, SetBan, SetNetworkActive, +}; +use crate::types::v20::EncryptWallet; use crate::types::v25::*; #[rustfmt::skip] // Keep public re-exports separate. @@ -41,6 +50,10 @@ crate::impl_client_v17__gettxoutproof!(); crate::impl_client_v17__gettxoutsetinfo!(); crate::impl_client_v17__preciousblock!(); crate::impl_client_v17__verifytxoutproof!(); +crate::impl_client_v23__savemempool!(); +crate::impl_client_v17__verifychain!(); +crate::impl_client_v25__scantxoutset!(); +crate::impl_client_v17__pruneblockchain!(); // == Control == crate::impl_client_v17__getmemoryinfo!(); @@ -66,6 +79,14 @@ crate::impl_client_v17__getaddednodeinfo!(); crate::impl_client_v17__getnettotals!(); crate::impl_client_v17__getnetworkinfo!(); crate::impl_client_v17__getpeerinfo!(); +crate::impl_client_v17__addnode!(); +crate::impl_client_v17__clearbanned!(); +crate::impl_client_v17__setban!(); +crate::impl_client_v17__listbanned!(); +crate::impl_client_v17__disconnectnode!(); +crate::impl_client_v17__getconnectioncount!(); +crate::impl_client_v17__ping!(); +crate::impl_client_v20__setnetworkactive!(); // == Rawtransactions == crate::impl_client_v17__createrawtransaction!(); @@ -105,3 +126,21 @@ crate::impl_client_v17__signrawtransactionwithwallet!(); crate::impl_client_v21__unloadwallet!(); crate::impl_client_v17__walletcreatefundedpsbt!(); crate::impl_client_v17__walletprocesspsbt!(); +crate::impl_client_v17__abandontransaction!(); +crate::impl_client_v20__abortrescan!(); +crate::impl_client_v17__backupwallet!(); +crate::impl_client_v20__encryptwallet!(); +crate::impl_client_v17__importaddress!(); +crate::impl_client_v17__importprivkey!(); +crate::impl_client_v17__importprunedfunds!(); +crate::impl_client_v17__importpubkey!(); +crate::impl_client_v17__importwallet!(); +crate::impl_client_v17__keypoolrefill!(); +crate::impl_client_v17__lockunspent!(); +crate::impl_client_v17__removeprunedfunds!(); +crate::impl_client_v17__sethdseed!(); +crate::impl_client_v17__settxfee!(); +crate::impl_client_v17__walletlock!(); +crate::impl_client_v17__walletpassphrase!(); +crate::impl_client_v17__walletpassphrasechange!(); +crate::impl_client_v17__importmulti!(); diff --git a/client/src/client_sync/v26/mod.rs b/client/src/client_sync/v26/mod.rs index b0c5e2c0..85589cde 100644 --- a/client/src/client_sync/v26/mod.rs +++ b/client/src/client_sync/v26/mod.rs @@ -6,6 +6,7 @@ pub mod blockchain; pub mod mining; +pub mod network; use std::collections::BTreeMap; use std::path::Path; @@ -13,7 +14,15 @@ use std::path::Path; use bitcoin::address::{Address, NetworkChecked}; use bitcoin::{Amount, Block, BlockHash, PublicKey, Txid}; -use crate::client_sync::into_json; +use crate::client_sync::{ + into_json, AddNodeCommand, ImportMultiOptions, ImportMultiRequest, ScanAction, ScanObject, + SetBanCommand, +}; +use crate::types::v17::{ + AddNode, ClearBanned, DisconnectNode, GetConnectionCount, ImportMulti, ImportPrivKey, Ping, + PruneBlockchain, SetBan, SetNetworkActive, +}; +use crate::types::v20::EncryptWallet; use crate::types::v26::*; #[rustfmt::skip] // Keep public re-exports separate. @@ -44,6 +53,10 @@ crate::impl_client_v17__gettxoutproof!(); crate::impl_client_v26__gettxoutsetinfo!(); crate::impl_client_v17__preciousblock!(); crate::impl_client_v17__verifytxoutproof!(); +crate::impl_client_v23__savemempool!(); +crate::impl_client_v17__verifychain!(); +crate::impl_client_v25__scantxoutset!(); +crate::impl_client_v17__pruneblockchain!(); // == Control == crate::impl_client_v17__getmemoryinfo!(); @@ -70,6 +83,14 @@ crate::impl_client_v17__getaddednodeinfo!(); crate::impl_client_v17__getnettotals!(); crate::impl_client_v17__getnetworkinfo!(); crate::impl_client_v17__getpeerinfo!(); +crate::impl_client_v26__addnode!(); +crate::impl_client_v17__clearbanned!(); +crate::impl_client_v17__setban!(); +crate::impl_client_v17__listbanned!(); +crate::impl_client_v17__disconnectnode!(); +crate::impl_client_v17__getconnectioncount!(); +crate::impl_client_v17__ping!(); +crate::impl_client_v20__setnetworkactive!(); // == Rawtransactions == crate::impl_client_v17__createrawtransaction!(); @@ -109,3 +130,21 @@ crate::impl_client_v17__signrawtransactionwithwallet!(); crate::impl_client_v21__unloadwallet!(); crate::impl_client_v17__walletcreatefundedpsbt!(); crate::impl_client_v17__walletprocesspsbt!(); +crate::impl_client_v17__abandontransaction!(); +crate::impl_client_v20__abortrescan!(); +crate::impl_client_v17__backupwallet!(); +crate::impl_client_v20__encryptwallet!(); +crate::impl_client_v17__importaddress!(); +crate::impl_client_v17__importprivkey!(); +crate::impl_client_v17__importprunedfunds!(); +crate::impl_client_v17__importpubkey!(); +crate::impl_client_v17__importwallet!(); +crate::impl_client_v17__keypoolrefill!(); +crate::impl_client_v17__lockunspent!(); +crate::impl_client_v17__removeprunedfunds!(); +crate::impl_client_v17__sethdseed!(); +crate::impl_client_v17__settxfee!(); +crate::impl_client_v17__walletlock!(); +crate::impl_client_v17__walletpassphrase!(); +crate::impl_client_v17__walletpassphrasechange!(); +crate::impl_client_v17__importmulti!(); diff --git a/client/src/client_sync/v26/network.rs b/client/src/client_sync/v26/network.rs new file mode 100644 index 00000000..aabe9efc --- /dev/null +++ b/client/src/client_sync/v26/network.rs @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: CC0-1.0 + +//! Macros for implementing JSON-RPC methods on a client. +//! +//! Requires `Client` to be in scope. +//! +//! Specifically this is methods found under the `== Network ==` section of the +//! API docs of Bitcoin Core `v26`. +//! +//! See, or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. + +/// Implements Bitcoin Core JSON-RPC API method `addnode` +#[macro_export] +macro_rules! impl_client_v26__addnode { + () => { + impl Client { + pub fn add_node( + &self, + node: &str, + command: AddNodeCommand, + v2transport: Option, + ) -> Result { + let mut params = vec![node.into(), serde_json::to_value(command)?]; + + if let Some(v2) = v2transport { + params.push(v2.into()); + } + + match self.call("addnode", ¶ms) { + Ok(serde_json::Value::Null) => Ok(AddNode), + Ok(ref val) if val.is_null() => Ok(AddNode), + Ok(other) => + Err(Error::Returned(format!("addnode expected null, got: {}", other))), + Err(e) => Err(e.into()), + } + } + } + }; +} diff --git a/client/src/client_sync/v27.rs b/client/src/client_sync/v27.rs index d9901e72..29b73c8a 100644 --- a/client/src/client_sync/v27.rs +++ b/client/src/client_sync/v27.rs @@ -10,7 +10,15 @@ use std::path::Path; use bitcoin::address::{Address, NetworkChecked}; use bitcoin::{Amount, Block, BlockHash, PublicKey, Txid}; -use crate::client_sync::into_json; +use crate::client_sync::{ + into_json, AddNodeCommand, ImportMultiOptions, ImportMultiRequest, ScanAction, ScanObject, + SetBanCommand, +}; +use crate::types::v17::{ + AddNode, ClearBanned, DisconnectNode, GetConnectionCount, ImportMulti, ImportPrivKey, Ping, + PruneBlockchain, SetBan, SetNetworkActive, +}; +use crate::types::v20::EncryptWallet; use crate::types::v27::*; #[rustfmt::skip] // Keep public re-exports separate. @@ -41,6 +49,10 @@ crate::impl_client_v17__gettxoutproof!(); crate::impl_client_v26__gettxoutsetinfo!(); crate::impl_client_v17__preciousblock!(); crate::impl_client_v17__verifytxoutproof!(); +crate::impl_client_v23__savemempool!(); +crate::impl_client_v17__verifychain!(); +crate::impl_client_v25__scantxoutset!(); +crate::impl_client_v17__pruneblockchain!(); // == Control == crate::impl_client_v17__getmemoryinfo!(); @@ -67,6 +79,14 @@ crate::impl_client_v17__getaddednodeinfo!(); crate::impl_client_v17__getnettotals!(); crate::impl_client_v17__getnetworkinfo!(); crate::impl_client_v17__getpeerinfo!(); +crate::impl_client_v26__addnode!(); +crate::impl_client_v17__clearbanned!(); +crate::impl_client_v17__setban!(); +crate::impl_client_v17__listbanned!(); +crate::impl_client_v17__disconnectnode!(); +crate::impl_client_v17__getconnectioncount!(); +crate::impl_client_v17__ping!(); +crate::impl_client_v20__setnetworkactive!(); // == Rawtransactions == crate::impl_client_v17__createrawtransaction!(); @@ -106,3 +126,21 @@ crate::impl_client_v17__signrawtransactionwithwallet!(); crate::impl_client_v21__unloadwallet!(); crate::impl_client_v17__walletcreatefundedpsbt!(); crate::impl_client_v17__walletprocesspsbt!(); +crate::impl_client_v17__abandontransaction!(); +crate::impl_client_v20__abortrescan!(); +crate::impl_client_v17__backupwallet!(); +crate::impl_client_v20__encryptwallet!(); +crate::impl_client_v17__importaddress!(); +crate::impl_client_v17__importprivkey!(); +crate::impl_client_v17__importprunedfunds!(); +crate::impl_client_v17__importpubkey!(); +crate::impl_client_v17__importwallet!(); +crate::impl_client_v17__keypoolrefill!(); +crate::impl_client_v17__lockunspent!(); +crate::impl_client_v17__removeprunedfunds!(); +crate::impl_client_v17__sethdseed!(); +crate::impl_client_v17__settxfee!(); +crate::impl_client_v17__walletlock!(); +crate::impl_client_v17__walletpassphrase!(); +crate::impl_client_v17__walletpassphrasechange!(); +crate::impl_client_v17__importmulti!(); diff --git a/client/src/client_sync/v28/blockchain.rs b/client/src/client_sync/v28/blockchain.rs new file mode 100644 index 00000000..637926ca --- /dev/null +++ b/client/src/client_sync/v28/blockchain.rs @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: CC0-1.0 + +//! Macros for implementing JSON-RPC methods on a client. +//! +//! Specifically this is methods found under the `== Blockchain ==` section of the +//! API docs of Bitcoin Core `v28`. +//! +//! All macros require `Client` to be in scope. +//! +//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. + +/// Implements Bitcoin Core JSON-RPC API method `scantxoutset` +#[macro_export] +macro_rules! impl_client_v28__scantxoutset { + () => { + impl Client { + pub fn scan_tx_out_set( + &self, + action: ScanAction, + scan_objects: Option<&[ScanObject]>, + ) -> Result { + let params = match action { + ScanAction::Start => match scan_objects { + Some(objects) => + vec![serde_json::to_value(action)?, serde_json::to_value(objects)?], + None => + return Err(Error::Returned( + "scan_objects required for 'start'".to_string(), + )), + }, + ScanAction::Abort | ScanAction::Status => { + vec![serde_json::to_value(action)?] + } + }; + self.call("scantxoutset", ¶ms) + } + } + }; +} diff --git a/client/src/client_sync/v28/mod.rs b/client/src/client_sync/v28/mod.rs index ce8ce37f..95439a67 100644 --- a/client/src/client_sync/v28/mod.rs +++ b/client/src/client_sync/v28/mod.rs @@ -3,7 +3,7 @@ //! A JSON-RPC client for testing against Bitcoin Core `v28`. //! //! We ignore option arguments unless they effect the shape of the returned JSON data. - +pub mod blockchain; pub mod raw_transactions; use std::collections::BTreeMap; @@ -12,7 +12,15 @@ use std::path::Path; use bitcoin::address::{Address, NetworkChecked}; use bitcoin::{Amount, Block, BlockHash, PublicKey, Txid}; -use crate::client_sync::into_json; +use crate::client_sync::{ + into_json, AddNodeCommand, ImportMultiOptions, ImportMultiRequest, ScanAction, ScanObject, + SetBanCommand, +}; +use crate::types::v17::{ + AddNode, ClearBanned, DisconnectNode, GenerateToAddress, GetConnectionCount, ImportMulti, + ImportPrivKey, Ping, SetBan, +}; +use crate::types::v20::{EncryptWallet, SetNetworkActive}; use crate::types::v28::*; #[rustfmt::skip] // Keep public re-exports separate. @@ -43,6 +51,10 @@ crate::impl_client_v17__gettxoutproof!(); crate::impl_client_v26__gettxoutsetinfo!(); crate::impl_client_v17__preciousblock!(); crate::impl_client_v17__verifytxoutproof!(); +crate::impl_client_v17__pruneblockchain!(); +crate::impl_client_v23__savemempool!(); +crate::impl_client_v17__verifychain!(); +crate::impl_client_v28__scantxoutset!(); // == Control == crate::impl_client_v17__getmemoryinfo!(); @@ -69,6 +81,14 @@ crate::impl_client_v17__getaddednodeinfo!(); crate::impl_client_v17__getnettotals!(); crate::impl_client_v17__getnetworkinfo!(); crate::impl_client_v17__getpeerinfo!(); +crate::impl_client_v26__addnode!(); +crate::impl_client_v17__clearbanned!(); +crate::impl_client_v17__setban!(); +crate::impl_client_v17__listbanned!(); +crate::impl_client_v17__disconnectnode!(); +crate::impl_client_v17__getconnectioncount!(); +crate::impl_client_v17__ping!(); +crate::impl_client_v20__setnetworkactive!(); // == Rawtransactions == crate::impl_client_v17__createrawtransaction!(); @@ -109,3 +129,21 @@ crate::impl_client_v17__signrawtransactionwithwallet!(); crate::impl_client_v21__unloadwallet!(); crate::impl_client_v17__walletcreatefundedpsbt!(); crate::impl_client_v17__walletprocesspsbt!(); +crate::impl_client_v17__abandontransaction!(); +crate::impl_client_v20__abortrescan!(); +crate::impl_client_v17__backupwallet!(); +crate::impl_client_v20__encryptwallet!(); +crate::impl_client_v17__importaddress!(); +crate::impl_client_v17__importprivkey!(); +crate::impl_client_v17__importprunedfunds!(); +crate::impl_client_v17__importpubkey!(); +crate::impl_client_v17__importwallet!(); +crate::impl_client_v17__keypoolrefill!(); +crate::impl_client_v17__lockunspent!(); +crate::impl_client_v17__removeprunedfunds!(); +crate::impl_client_v17__sethdseed!(); +crate::impl_client_v17__settxfee!(); +crate::impl_client_v17__walletlock!(); +crate::impl_client_v17__walletpassphrase!(); +crate::impl_client_v17__walletpassphrasechange!(); +crate::impl_client_v17__importmulti!(); diff --git a/integration_test/Cargo.toml b/integration_test/Cargo.toml index 41f3541a..dddc09a1 100644 --- a/integration_test/Cargo.toml +++ b/integration_test/Cargo.toml @@ -49,8 +49,9 @@ v17 = [] TODO = [] # This is a dirty hack while writing the tests. [dependencies] -bitcoin = { version = "0.32.0", default-features = false, features = ["std", "serde"] } +bitcoin = { version = "0.32.0", default-features = false, features = ["std", "serde", "rand"] } node = { package = "corepc-node", version = "0.7.0", default-features = false, features = ["download"] } +client = { package = "corepc-client", version = "0.7.0", default-features = false, features = ["client-sync"] } rand = "0.8.5" env_logger = "0.9.0" diff --git a/integration_test/src/lib.rs b/integration_test/src/lib.rs index ec969884..726d8810 100644 --- a/integration_test/src/lib.rs +++ b/integration_test/src/lib.rs @@ -8,6 +8,7 @@ use rand::Rng; #[rustfmt::skip] // Keep public re-exports separate. pub use node::Node; // Re-export this to make test imports more terse. +pub use client::client_sync::{AddNodeCommand, SetBanCommand, LockUnspentOutput}; /// Initialize a logger (configure with `RUST_LOG=trace cargo test`). #[allow(dead_code)] // Not all tests use this function. diff --git a/integration_test/tests/blockchain.rs b/integration_test/tests/blockchain.rs index 28c90bbf..4ac2af2b 100644 --- a/integration_test/tests/blockchain.rs +++ b/integration_test/tests/blockchain.rs @@ -290,3 +290,136 @@ fn verify_tx_out_proof(node: &Node) -> Result<(), client_sync::Error> { Ok(()) } + +#[test] +fn blockchain__prune_blockchain() { + const NBLOCKS: usize = 1; + + let node = Node::with_wallet(Wallet::Default, &["-prune=550"]); + let address = node.client.new_address().expect("Failed to get new address"); + + let gen_result = node.client.generate_to_address(NBLOCKS, &address).expect("generate_to_address RPC call failed"); + assert_eq!(gen_result.0.len(), NBLOCKS, "generate_to_address did not return the expected number of block hashes"); + + let target_height: u64 = 500; + + let _ = node.client.prune_blockchain(target_height); +} + +#[test] +fn blockchain__savemempool() { + let node = Node::with_wallet(Wallet::Default, &[]); + + node.fund_wallet(); + let (_addr, _txid) = node.create_mempool_transaction(); + + // Give node a moment to process mempool tx + std::thread::sleep(std::time::Duration::from_millis(200)); + + let result = node.client.save_mempool(); + + // Assert based on version feature flag active during test run + #[cfg(any( + feature = "0_17_2", + feature = "0_18_1", + feature = "0_19_1", + feature = "0_20_2", + feature = "0_21_2", + feature = "22_1" + ))] { + result.expect("savemempool RPC call failed (v17 - v22"); + } + + #[cfg(any( + feature = "23_2", + feature = "24_2", + feature = "25_2", + feature = "26_2", + feature = "27_2", + feature = "28_0" + ))] { + let save_result = result.expect("savemempool RPC call failed (v23 - v28)"); + assert!(!save_result.filename.is_empty(), "Filename returned by savemempool should not be empty (v23 - v28)"); + } +} + +#[test] +fn blockchain__verify_chain() { + let node = Node::with_wallet(Wallet::None, &[]); + + // Test with default parameters + let result_default = node.client.verify_chain_default().expect("veifychain with defaults failed"); + let result_default_value = result_default.0; + assert!(result_default_value, "verifychain with defaults should return true on a clean chain"); + + // Test with specific parameters (e.g., check first 2 blocks thoroughly) + let checklevel = Some(4u32); + let nblocks = Some(2u32); + let result_specific = node.client.verify_chain(checklevel, nblocks).expect("verifychain with specific args failed"); + let result_specific_value = result_specific.0; + assert!(result_specific_value, "verifychain with specific args should return true on a clean chain"); + + // Test with only nblocks (requires null for checklevel) + let result_nblocks_only = node.client.verify_chain(None, Some(1)).expect("verifychain with nblocks only failed"); + let result_nblocks_only_value = result_nblocks_only.0; + assert!(result_nblocks_only_value, "verifychain with nblocks only should return true"); +} + +#[cfg(not(any(feature = "v17", feature = "v18", feature = "v19", feature = "v20", feature = "v21")))] +#[test] +fn blockchain__scantxoutset_modelled() { + let node = Node::with_wallet(Wallet::None, &["-coinstatsindex=1"]); + + + let dummy_pubkey_hex = "0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"; + let scan_desc = format!("pkh({})", dummy_pubkey_hex); + + let scan_objects = [client_sync::ScanObject::Descriptor(scan_desc)]; + let action = client_sync::ScanAction::Start; + + let result = node.client.scan_tx_out_set(action, Some(&scan_objects)); + + #[cfg(feature = "v17")] + { + let _: ScanTxOutSet = result.expect("scantxoutset(Start) failed (v17)"); + } + #[cfg(feature = "v18")] + { + let _: ScanTxOutSet = result.expect("scantxoutset(Start) failed (v18)"); + } + #[cfg(all(feature = "v19", not(feature = "v22")))] + { + let res: ScanTxOutSet = result.expect("scantxoutset(Start) failed (v19-v21)"); + assert!(res.success == true || res.success == false); + } + #[cfg(all(feature = "v22", not(feature = "v25")))] + { + let res: ScanTxOutSet = result.expect("scantxoutset(Start) failed (v22-v24)"); + match res { + ScanTxOutSet::Start(start_res) => { + assert!(start_res.success == true || start_res.success == false); + }, + _ => panic!("Expected Start variant result for scantxoutset (v22-v24)"), + } + } + #[cfg(all(feature = "v25", not(feature = "v28")))] + { + let res: ScanTxOutSet = result.expect("scantxoutset(Start) failed (v25-v27)"); + match res { + ScanTxOutSet::Start(start_res) => { + assert!(start_res.success == true || start_res.success == false); + }, + _ => panic!("Expected Start variant result for scantxoutset (v25-v27)"), + } + } + #[cfg(any(feature = "v28"))] + { + let res: ScanTxOutSet = result.expect("scantxoutset(Start) failed (v28+)"); + match res { + ScanTxOutSet::Start(start_res) => { + assert!(start_res.success == true || start_res.success == false); + }, + _ => panic!("Expected Start variant result for scantxoutset (v28+)"), + } + } +} diff --git a/integration_test/tests/network.rs b/integration_test/tests/network.rs index c0ba298b..1479a9a4 100644 --- a/integration_test/tests/network.rs +++ b/integration_test/tests/network.rs @@ -4,6 +4,7 @@ #![allow(non_snake_case)] // Test names intentionally use double underscore. +use integration_test::{AddNodeCommand, SetBanCommand}; use integration_test::{Node, NodeExt as _, Wallet}; use node::vtype::*; // All the version specific types. use node::mtype; @@ -56,3 +57,244 @@ fn get_peer_info_three_node_network() { assert!(node2.peers_connected() >= 1); assert!(node3.peers_connected() >= 1); } + +#[test] +fn network__add_node() { + let node_args: &[&str] = { + #[cfg(any(feature = "v26", feature = "v27", feature = "v28"))] + { &["-v2transport"] } + + #[cfg(not(any(feature = "v26", feature = "v27", feature = "v28")))] + { &[] } + }; + + let node = Node::with_wallet(Wallet::None, node_args); + + let dummy_peer = "192.0.2.1:8333"; + + #[cfg(any( + feature = "v17", + feature = "v18", + feature = "v19", + feature = "v20", + feature = "v21", + feature = "v22", + feature = "v23", + feature = "v24", + feature = "v25" + ))] { + node.client.add_node(dummy_peer, AddNodeCommand::OneTry).expect("addnode onetry failed (v17-v25)"); + + node.client.add_node(dummy_peer, AddNodeCommand::Add).expect("addnode add failed (v17-v25"); + + node.client.add_node(dummy_peer, AddNodeCommand::Remove).expect("addnode remove failed (v17-v25"); + } + + #[cfg(any( + feature = "v26", + feature = "v27", + feature = "v28" + ))] { + node.client.add_node(dummy_peer, AddNodeCommand::OneTry, None).expect("addnode onetry failed (v26+, v2transport=None)"); + node.client.add_node(dummy_peer, AddNodeCommand::Add, Some(false)).expect("addone add failed (v26+, v2transport=false)"); + node.client.add_node(dummy_peer, AddNodeCommand::Remove, Some(true)).expect("addnode remove failed (v26+, v2transport=true)"); + } +} + +#[test] +fn network__clear_banned() { + let node = Node::with_wallet(Wallet::None, &[]); + + let dummy_ip = "192.0.2.2"; + + node.client.set_ban(dummy_ip, SetBanCommand::Add, Some(60), None).expect(&format!("set_ban failed for setup for IP: {}", dummy_ip)); + + node.client.clear_banned().expect("clearbanned RPC call failed"); + + let banned_list = node.client.list_banned().expect("list_banned failed during verification after clear"); + assert!(banned_list.0.is_empty(), "Banned list should be empty after clearbanned"); +} + +#[test] +fn network__set_ban() { + let node = Node::with_wallet(Wallet::None, &[]); + let subnet1 = "192.0.2.3"; + let subnet2 = "192.0.2.0/24"; + + // Test Case 1: Add subnet1 with default bantime + node.client.set_ban(subnet1, SetBanCommand::Add, None, None).expect("setban add default time failed"); + + // Test Case 2: Add subnet2 with specific duration (e.g., 10 minutes) + node.client.set_ban(subnet2, SetBanCommand::Add, Some(600), None).expect("setban add specific duration failed"); + + // Test Case 3: Add subnet1 to use absolute time + node.client.set_ban(subnet1, SetBanCommand::Remove, None, None).expect("setban remove failed for subnet1"); + node.client.set_ban(subnet2, SetBanCommand::Remove, None, None).expect("setban remove failed for subnet2"); + + // Verify removal using list_banned + let list_after_removals = node.client.list_banned().expect("list_banned after both removes failed"); + assert!(list_after_removals.0.is_empty(), "Ban list should be empty after removing both"); + + // Re-add subnet1 with absolute time + let future_timestamp = (std::time::SystemTime::now() + std::time::Duration::from_secs(3600)) + .duration_since(std::time::UNIX_EPOCH).expect("Time went backwards").as_secs(); + node.client.set_ban(subnet1, SetBanCommand::Add, Some(future_timestamp as i64), Some(true)).expect("setban re-add absolute time failed after removing both"); + + // Test Case 4: Remove the absolute ban for subnet1 + node.client.set_ban(subnet1, SetBanCommand::Remove, None, None).expect("setban remove failed for subnet1 (after absolute ban)"); + + // Test Case 6: Attempt to remove subnet2 again (it was already removed) + // This should fail as it's not currently banned. + let remove_subnet2_again_result = node.client.set_ban(subnet2, SetBanCommand::Remove, None, None); + assert!( + remove_subnet2_again_result.is_err(), + "Removing subnet2 again should fail (it's not banned)" + ); + + if let Err(e) = remove_subnet2_again_result { + println!(" Verified removing {} again fails as expected: {:?}", subnet2, e); + } + + // Verify final state is empty + let final_list = node.client.list_banned().expect("Final list_banned call failed"); + assert!(final_list.0.is_empty(), "Final ban list should be empty"); +} + +#[test] +fn network__list_banned() { + let node = Node::with_wallet(Wallet::None, &[]); + let subnet1 = "192.0.2.6"; + + let ban_duration_secs = 300i64; + + let initial_list = node.client.list_banned().expect("Initial listbanned call failed"); + assert!(initial_list.0.is_empty(), "Initial banned list should be empty"); + + node.client.set_ban(subnet1, SetBanCommand::Add, Some(ban_duration_secs), None).expect("set_ban call failed during setup"); + + let banned_list = node.client.list_banned().expect("Second listbanned call failed"); + + assert!(!banned_list.0.is_empty(), "Banned list should not be empty after setban"); + + let _ = banned_list.0.iter().find(|entry| entry.address == subnet1 || entry.address.starts_with(&format!("{}/", subnet1))).expect(&format!("Did not find banned subnet {} or {}/32 in list", subnet1, subnet1)); +} + +#[test] +fn network__disconnect_node_error_cases() { + let node = Node::with_wallet(Wallet::None, &[]); + + // Test providing both - expect specific error + let result_both = node.client.disconnect_node(Some("127.0.0.1:1"), Some(1)); + assert!(result_both.is_err(), "Expected disconnect_node to return Err when both args are provided"); + + // Test providing none - expect specific error + let result_none = node.client.disconnect_node(None, None); + assert!(result_none.is_err(), "Expected disconnect_node to return Err when no args are provided"); +} + +#[test] +fn network__disconnect_node_success_cases() { + // Setup 3 connected nodes + let (node1, node2, _node3) = integration_test::three_node_network(); + println!("Node network setup complete."); + + // Get Peer Info + let node1_peers = node1.client.get_peer_info().expect("Node1 getpeerinfo failed"); + + assert_eq!(node1_peers.0.len(), 1, "Node1 should have exactly one peer (Node2)"); + let node2_info = &node1_peers.0[0]; // Get the first (only) peer info + let node2_id = node2_info.id; + + let node2_addr_str = &node2_info.address; + + let node2_peers = node2.client.get_peer_info().expect("Node2 getpeerinfo failed"); + + let node3_info = node2_peers.0.iter() + .find(|p| p.id != node1.client.get_network_info().expect("getnetworkinfo").local_addresses.get(0).map_or(0, |a| a.port as u32)) + .or_else(|| node2_peers.0.get(1)) + .expect("Node2 should see Node3"); + + let node3_id = node3_info.id; + + // Test Disconnect by Address + node1.client.disconnect_node(Some(node2_addr_str), None) // Pass &String here + .expect("disconnect_node by address failed"); + + // Verify disconnection + std::thread::sleep(std::time::Duration::from_millis(500)); + let node1_peers_after_addr_disconnect = node1.client.get_peer_info() + .expect("Node1 getpeerinfo after addr disconnect failed"); + assert!( + node1_peers_after_addr_disconnect.0.iter().find(|p| p.id == node2_id).is_none(), + "Node2 should be disconnected from Node1 after disconnect by address" + ); + + // Test Disconnect by Node ID + node2.client.disconnect_node(None, Some(node3_id.into())) + .expect("disconnect_node by nodeid failed"); + + // Verify disconnection + std::thread::sleep(std::time::Duration::from_millis(500)); + let node2_peers_after_id_disconnect = node2.client.get_peer_info() + .expect("Node2 getpeerinfo after id disconnect failed"); + assert!( + node2_peers_after_id_disconnect.0.iter().find(|p| p.id == node3_id).is_none(), + "Node3 should be disconnected from Node2 after disconnect by nodeid" + ); +} + +#[test] +fn network__get_connection_count() { + let node_single = Node::with_wallet(Wallet::None, &[]); + let count_single = node_single.client.get_connection_count().expect("getconnectioncount failed for single node"); + let count_single_value = count_single.0; + + assert_eq!(count_single_value, 0, "Single node should have 0 connections"); + + let (node1, node2, node3) = integration_test::three_node_network(); + + // Allow time for connection for establish fully + std::thread::sleep(std::time::Duration::from_millis(500)); + + let count1 = node1.client.get_connection_count().expect("getconnectioncount failed for node1"); + let count1_value = count1.0; + assert!(count1_value >= 1, "Node1 should have at least 1 connection"); + + let count2 = node2.client.get_connection_count().expect("getconnectioncount failed for node2"); + let count2_value = count2.0; + assert!(count2_value >= 1, "Node2 should have at least 1 connection"); + + let count3 = node3.client.get_connection_count().expect("getconnectioncount failed for node3"); + let count3_value = count3.0; + assert!(count3_value >= 1, "Node3 should have at least 1 connection"); +} + +#[test] +fn network__ping() { + let node_single = Node::with_wallet(Wallet::None, &[]); + node_single.client.ping().expect("ping failed for single node"); + + let (node1, node2, _node3) = integration_test::three_node_network(); + + // Allow time for connections to establish fully + std::thread::sleep(std::time::Duration::from_millis(500)); + + node1.client.ping().expect("ping failed for node1 (3-node)"); + node2.client.ping().expect("ping failed for node2 (3-node)"); +} + +#[test] +fn network__set_network_active() { + let (node1, _node2, _node3) = integration_test::three_node_network(); + + // Allow time for initial connections + std::thread::sleep(std::time::Duration::from_millis(1000)); + // Call set_network_active(false) + let _ = node1.client.set_network_active(false); + + // Wait and verify network is inactive + std::thread::sleep(std::time::Duration::from_millis(1000)); + + // Call set_network_active(true) + let _ = node1.client.set_network_active(true); +} diff --git a/integration_test/tests/wallet.rs b/integration_test/tests/wallet.rs index 59182219..cd9abc3a 100644 --- a/integration_test/tests/wallet.rs +++ b/integration_test/tests/wallet.rs @@ -6,11 +6,20 @@ #[cfg(feature = "TODO")] use bitcoin::address::{Address, NetworkChecked}; -use bitcoin::Amount; -use integration_test::{Node, NodeExt as _, Wallet}; +use bitcoin::{Amount, Txid}; +use integration_test::{Node, NodeExt as _, Wallet, LockUnspentOutput}; use node::AddressType; use node::vtype::*; // All the version specific types. use node::mtype; +use std::fs; + +use bitcoin::{ + Address, + FeeRate, + Network, + secp256k1::{SecretKey, PublicKey}, + key::{CompressedPublicKey, Secp256k1, PrivateKey} +}; #[test] #[cfg(feature = "TODO")] @@ -282,3 +291,436 @@ fn create_load_unload_wallet() { let _: LoadWallet = node.client.load_wallet(&wallet).expect("loadwallet"); } + +#[test] +fn wallet__abandon_transaction() { + let node = Node::with_wallet(Wallet::Default, &[]); + // node.fund_wallet(); // Fails due to timeout, needs fixing + let address = node.client.new_address().expect("failed to get new address"); + + for _ in 0..=11 { + node.client.generate_to_address(10, &address).expect("failed to generate to address"); + } + + let (_, txid) = node.create_mempool_transaction(); + let _ = node.client.abandon_transaction(txid); +} + + +#[test] +fn wallet__abort_rescan() { + let node = Node::with_wallet(Wallet::Default, &[]); + let _ = node.client.abort_rescan(); +} + +#[test] +fn wallet__backup_wallet() { + let node = Node::with_wallet(Wallet::Default, &[]); + let backup_dest = integration_test::random_tmp_file(); + + if backup_dest.exists() { + fs::remove_file(&backup_dest).expect("Failed to remove pre-existing temp file"); + } + + node.client.backup_wallet(&backup_dest).expect("backupwallet RPC call failed"); + assert!(backup_dest.exists(), "Backup file should exist at destination"); + assert!(backup_dest.is_file(), "Backup destination should be a file"); + + fs::remove_file(&backup_dest).expect("Failed to remove backup file during cleanup"); +} + +#[test] +fn wallet__encrypt_wallet() { + let wallet_name = format!("test_encrypt_{}", rand::random::()); + let node = Node::with_wallet(Wallet::None, &[]); + let _ = node.client.create_wallet(&wallet_name); + + let passphrase = "my_secret_test_passphrase"; + let _ = node.client.encrypt_wallet(passphrase); +} + +#[cfg(not(any( + feature = "v17", + feature = "v18", + feature = "v19", + feature = "v20", + feature = "v21", + feature = "v22", +)))] +#[test] +fn wallet__import_address() { + let node = Node::with_wallet(Wallet::None, &["-deprecatedrpc=create_bdb"]); + let wallet_name = format!("legacy_import_{}", rand::random::()); + node.client.create_legacy_wallet(&wallet_name).expect("Failed to create legacy wallet for v20+ test"); + + let secp = Secp256k1::new(); + let mut rng = rand::thread_rng(); + + // Test Case 1: Import with default label and rescan + let secret_key = SecretKey::new(&mut rng); + let public_key = PublicKey::from_secret_key(&secp, &secret_key); + let compressed_public_key = CompressedPublicKey(public_key); + + let ext_addr = Address::p2wpkh(&compressed_public_key, Network::Regtest); + let ext_addr_str = ext_addr.to_string(); + + node.client.import_address(&ext_addr_str, None, None, None).expect("importaddress with defaults failed"); + + // Test Case 2" Import with label, no rescan, no p2sh + let secret_key2 = SecretKey::new(&mut rng); + let public_key2 = PublicKey::from_secret_key(&secp, &secret_key2); + let compressed_public_key2 = CompressedPublicKey(public_key2); + + let ext_addr2 = Address::p2wpkh(&compressed_public_key2, Network::Regtest); + let ext_addr_str2 = ext_addr2.to_string(); + let label = "imported_watchonly"; + + node.client.import_address(&ext_addr_str2, Some(label), Some(false), Some(false)).expect("importaddress with options failed"); +} + +#[cfg(not(any( + feature = "v17", + feature = "v18", + feature = "v19", + feature = "v20", + feature = "v21", + feature = "v22", +)))] +#[test] +fn wallet__import_priv_key() { + let node = { + #[cfg(any( + feature = "v17", + feature = "v18", + feature = "v19", + ))] { + Node::with_wallet(Wallet::Default, &[]) + } + + #[cfg(not(any( + feature = "v17", + feature = "v18", + feature = "v19", + )))] { + let node = Node::with_wallet(Wallet::None, &["-deprecatedrpc=create_bdb"]); + let wallet_name = format!("legacy_importprivkey_{}", rand::random::()); + node.client.create_legacy_wallet(&wallet_name).expect("Failed to create legacy wallet for v20+ test"); + node + } + }; + + let mut rng = rand::thread_rng(); + + // Test Case 1: Import key with label, no rescan + let secret_key = SecretKey::new(&mut rng); + let private_key = PrivateKey::new(secret_key, Network::Regtest); + + let label = "imported_privkey"; + let _ = node.client.import_priv_key(&private_key, Some(label), Some(false)).expect("importprivkey failed"); +} + +#[cfg(not(any( + feature = "v17", + feature = "v18", + feature = "v19", + feature = "v20", + feature = "v21", + feature = "v22", +)))] +#[test] +fn wallet__import_pruned_funds() { + let node = { + #[cfg(any( + feature = "v17", + feature = "v18", + feature = "v19", + ))] { + Node::with_wallet(Wallet::Default, &[]) + } + + #[cfg(not(any( + feature = "v17", + feature = "v18", + feature = "v19", + )))] { + let node = Node::with_wallet(Wallet::None, &["-deprecatedrpc=create_bdb"]); + let wallet_name = format!("legacy_pruned_{}", rand::random::()); + node.client.create_legacy_wallet(&wallet_name).expect("Failed to create legacy wallet for v20+ test"); + + node + } + }; + + let dummy_raw_tx = "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff01e8030000000000001976a914000000000000000000000000000000000000000088ac00000000"; + let dummy_tx_proof = "00"; + + let _ = node.client.import_pruned_funds(dummy_raw_tx, dummy_tx_proof); +} + +#[cfg(not(any( + feature = "v17", + feature = "v18", + feature = "v19", + feature = "v20", + feature = "v21", + feature = "v22", +)))] +#[test] +fn wallet__import_pubkey() { + let node = { + #[cfg(any( + feature = "v17", + feature = "v18", + feature = "v19", + ))] { + Node::with_wallet(Wallet::Default, &[]) + } + + #[cfg(not(any( + feature = "v17", + feature = "v18", + feature = "v19", + )))] { + let node = Node::with_wallet(Wallet::None, &["-deprecatedrpc=create_bdb"]); + let wallet_name = format!("legacy_importpubkey_{}", rand::random::()); + node.client.create_legacy_wallet(&wallet_name).expect("Failed to create legacy wallet for v20+"); + node + } + }; + + let secp = Secp256k1::new(); + let mut rng = rand::thread_rng(); + + let secret_key = SecretKey::new(&mut rng); + let public_key = PublicKey::from_secret_key(&secp, &secret_key); + let pub_key = bitcoin::PublicKey::new(public_key); + + // Test Case 1: Import with default label and rescan + let label = "imported_pubkey"; + node.client.import_pubkey(&pub_key, Some(label), Some(false)).expect("importpubkey failed"); +} + +#[cfg(not(any(feature = "v17", feature = "v18", feature = "v19", feature = "v20")))] +#[test] +fn wallet__import_wallet() { + + let node = Node::with_wallet(Wallet::None, &["-deprecatedrpc=create_bdb"]); + let wallet_name = format!("legacy_source_dump_{}", rand::random::()); + node.client.create_legacy_wallet(&wallet_name).expect("Failed to create legacy source wallet"); + + node.client.new_address().expect("Failed to generate address before dump"); + + let dump_file_path = integration_test::random_tmp_file(); + + node.client.dump_wallet(&dump_file_path).expect("dump_wallet failed"); + assert!(dump_file_path.exists(), "Dump file should exist after dumpwallet"); + + node.client.import_wallet(&dump_file_path).expect("importwallet RPC call failed"); +} + +#[test] +fn wallet__keypool_refill() { + let node = Node::with_wallet(Wallet::Default, &[]); + + // Test Case 1: Refill with default size + node.client.keypool_refill(None).expect("keypool_refill (default) failed"); + + // Test Case 2: Refill with specific size + let specific_size = 50usize; + node.client.keypool_refill(Some(specific_size)).expect("keypool_refill (specific) failed"); +} + +#[cfg(feature = "v28")] +#[test] +fn wallet__lock_unspent() { + let node = Node::with_wallet(Wallet::Default, &[]); + node.fund_wallet(); // Fails due to timeout, needs fixing + // let address = node.client.new_address().expect("failed to get new address"); + + // for _ in 0..=11 { + // node.client.generate_to_address(10, &address).expect("failed to generate to address"); + // } + + let unspent_list = node.client.list_unspent().expect("listunspent failed during setup"); + + let utxo_to_lock = unspent_list.0.get(0).expect("Wallet should have at least one UTXO after funding"); + + let lock_target = LockUnspentOutput { + txid: { + #[cfg(feature = "28_0")] + { utxo_to_lock.txid } + #[cfg(not(feature = "28_0"))] + { utxo_to_lock.txid.parse::().expect("Failed to parse Txid string") } + }, + vout: u32::try_from(utxo_to_lock.vout).expect("Failed to convert vout i64 to u32 (was negative?)"), + }; + + let lock_result = node.client.lock_unspent(false, Some(&[lock_target.clone()]), None).expect("lock_unspent(false) call failed"); + assert!(lock_result.0, "lock_unspent(false) should return true for success"); +} + +#[cfg(feature = "v28")] +#[test] +fn wallet__remove_pruned_funds() { + let node = { + #[cfg(any( + feature = "v17", + feature = "v18", + feature = "v19", + ))] { + Node::with_wallet(Wallet::Default, &[]) + } + + #[cfg(not(any( + feature = "v17", + feature = "v18", + feature = "v19", + )))] { + let node = Node::with_wallet(Wallet::None, &["-deprecatedrpc=create_bdb"]); + let wallet_name = format!("legacy_removepruned_{}", rand::random::()); + node.client.create_legacy_wallet(&wallet_name).expect("Failed to create legacy wallet for v20+ test"); + node + } + }; + node.fund_wallet(); + + let tx_list = node.client.list_transactions().expect("listtransactions failed during setup"); + println!("tx list: {:#?}", tx_list); + let tx_to_remove = tx_list.0.get(0).expect("Wallet should have at least one transaction"); + + let txid_to_remove = { + #[cfg(feature = "28_0")] + { tx_to_remove.txid } + + #[cfg(not(feature = "28_0"))] + { tx_to_remove.txid.parse::().expect("Failed to parse Txid string") } + }; + + let _ = node.client.remove_pruned_funds(txid_to_remove); +} + +#[cfg(not(any(feature = "v17", feature = "v18", feature = "v19", feature = "v20")))] +#[test] +fn wallet__set_hd_seed() { + let node = Node::with_wallet(Wallet::None, &["-deprecatedrpc=create_bdb"]); + let wallet_name = format!("legacy_sethdseed_{}", rand::random::()); + node.client.create_legacy_wallet(&wallet_name).expect("Failed to create legacy wallet for v20+ test"); + // Test Case 1: Set new random seed, default newkeypool (true) + node.client.set_hd_seed(None, None).expect("sethdseed with defaults failed"); + + // Test Case 2: Set new random seed, newkeypool=false + node.client.set_hd_seed(Some(false), None).expect("sethdseed with newkeypool=false failed"); + + // Test Case 3: Set specific seed, newkeypool=true + let mut rng = rand::thread_rng(); + let secret_key = SecretKey::new(&mut rng); + let private_key = PrivateKey::new(secret_key, Network::Regtest); + + node.client.set_hd_seed(Some(true), Some(&private_key)).expect("sethdseed with specific seed failed"); +} + +#[test] +fn wallet__set_tx_fee() { + // Requires a wallet loaded + let node = Node::with_wallet(Wallet::Default, &[]); + + // Test Case 1: Set a specific fee rate >= min relay fee + // Min relay fee is 1 sat/vB (0.00001 BTC/kvB). Let's set 2 sat/vB. + let target_fee_rate = FeeRate::from_sat_per_vb(2).expect("Valid fee rate"); // 2 sat/vB + + let result1 = node.client.set_tx_fee(target_fee_rate) + .expect("settxfee with specific rate failed"); // This should now pass + assert!(result1.0, "settxfee should return true for success"); + + // Test Case 2: Disable custom fee (set to 0) + // Setting to 0 is always allowed. + let zero_fee_rate = FeeRate::ZERO; + + let result2 = node.client.set_tx_fee(zero_fee_rate) + .expect("settxfee with zero rate failed"); + assert!(result2.0, "settxfee(0) should return true for success"); +} + +#[cfg(not(any(feature = "v17", feature = "v18", feature = "v19", feature = "v20")))] +#[test] +fn wallet__wallet_lock() { + let passphrase = "test_lock_passphrase"; + let wallet_name = format!("test_lock_{}", rand::random::()); + let node = Node::with_wallet(Wallet::None, &[]); + + // Create Wallet + node.client.create_wallet(&wallet_name).expect("Failed to create wallet"); + // Encrypt Wallet + node.client.encrypt_wallet(passphrase).expect("encryptwallet RPC call failed"); + // Test walletlock + node.client.wallet_lock().expect("walletlock RPC call failed"); +} + +#[cfg(not(any(feature = "v17", feature = "v18", feature = "v19", feature = "v20")))] +#[test] +fn wallet__wallet_passphrase_and_lock() { + let passphrase = "test_passphrase_passphrase"; + let wallet_name = format!("test_passphrase_{}", rand::random::()); + let node = Node::with_wallet(Wallet::None, &[]); + + node.client.create_wallet(&wallet_name).expect("Failed to create a wallet"); + + let _ = node.client.encrypt_wallet(passphrase); + + // walletpassphrase + let unlock_duration = 60u64; + node.client.wallet_passphrase(passphrase, unlock_duration) + .expect("walletpassphrase RPC call failed"); + + // Verify Unlocked + node.client.new_address().expect("Verification failed for wallet unlocked"); + node.client.wallet_lock().expect("walletlock RPC call failed"); +} + +#[cfg(not(any(feature = "v17", feature = "v18", feature = "v19", feature = "v20")))] +#[test] +fn wallet__wallet_passphrase_change() { + let initial_passphrase = "initial_secret_for_change"; + let new_passphrase = "new_secret_after_change"; + let wallet_name = format!("test_pwchange_{}", rand::random::()); + + let node = Node::with_wallet(Wallet::None, &[]); + + // Create Wallet & Encrypt Wallet + node.client.create_wallet(&wallet_name).expect("Unable to create wallet"); + node.client.encrypt_wallet(initial_passphrase).expect("Unable to encrypt wallet"); + // Test walletpassphrasechange + node.client.wallet_passphrase_change(initial_passphrase, new_passphrase) + .expect("walletpassphrasechange RPC call failed"); + // Try unlocking with the NEW passphrase (should succeed) + node.client.wallet_passphrase(new_passphrase, 60) + .expect("walletpassphrase failed with NEW passphrase"); +} + +#[test] +fn wallet__import_multi_modelled() { + use client::client_sync::*; + let node = Node::with_wallet(Wallet::Default, &[]); + + let wallet_name = format!("legacy_importmulti_min_{}", rand::random::()); + node.client.create_wallet(&wallet_name) + .expect("Failed to create legacy wallet for v20+ minimal test"); + + let dummy_script_hex = "76a914aabbccddeeff00112233445566778899aabbccdd88ac"; + + let request = ImportMultiRequest { + script_pub_key: Some(ImportMultiScriptPubKey::Script(dummy_script_hex.to_string())), + timestamp: ImportMultiTimestamp::Now("now".to_string()), + watchonly: Some(true), + ..Default::default() + }; + + use node::serde_json; + let _ = serde_json::to_string(&[request.clone()]).unwrap(); + + let options = ImportMultiOptions { + rescan: Some(false), + }; + + let _ = node.client.import_multi(&[request], Some(&options)); +} diff --git a/types/src/v17/blockchain/mod.rs b/types/src/v17/blockchain/mod.rs index 81056d10..616c719f 100644 --- a/types/src/v17/blockchain/mod.rs +++ b/types/src/v17/blockchain/mod.rs @@ -660,9 +660,93 @@ pub struct GetTxOutSetInfo { /// > Verifies that a proof points to a transaction in a block, returning the transaction it commits to /// > and throwing an RPC error if the block is not in our best chain /// > +/// > Returns null (json null) /// > Arguments: /// > 1. "proof" (string, required) The hex-encoded proof generated by gettxoutproof /// /// Inner field is the txid(s) which the proof commits to, or empty array if the proof can not be validated. #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] pub struct VerifyTxOutProof(pub Vec); + +/// Result of JSON-RPC method `pruneblockchain`. +/// +/// > pruneblockchain height +/// > +/// > Arguments: +/// > 1. "height" (numeric, required) The block height to prune up to. May be set to a discrete height, or a unix timestamp +/// > to prune blocks whose block time is at least 2 hours older than the provided timestamp. +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +pub struct PruneBlockchain( + /// The height of the last block pruned. + pub i64, +); + +/// Result of JSON-RPC method `savemempool`. +/// +/// > savemempool +/// > +/// > Arguments: +/// > 1. "height" (numeric, required) The block height to prune up to. May be set to a discrete height, or a unix timestamp +/// > to prune blocks whose block time is at least 2 hours older than the provided timestamp. +/// > Returns null (json null) +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +pub struct SaveMempool; + +/// Result of JSON-RPC method `verifychain`. +/// +/// > verifychain +/// > +/// > Arguments: +/// > 1. checklevel (numeric, optional, default=3, range=0-4) How thorough the block verification is: +/// - level 0 reads the blocks from disk +/// - level 1 verifies block validity +/// - level 2 verifies undo data +/// - level 3 checks disconnection of tip blocks +/// - level 4 tries to reconnect the blocks +/// - each level includes the checks of the previous levels +/// > 2. nblocks (numeric, optional, default=6, 0=all) The number of blocks to check. +/// > +/// > Returns true|false (boolean) Verification finished successfully. If false, check debug.log for reason. +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +pub struct VerifyChain(pub bool); + +/// Result of JSON-RPC method `scantxoutset`. +/// +/// > scantxoutset "action" ( [scanobjects,...] ) +/// > +/// > Arguments: +/// > 1. "action" (string, required) The action to execute +/// > "start" for starting a scan +/// > "abort" for aborting the current scan (returns true when abort was successful) +/// > "status" for progress report (in %) of the current scan +/// > 2. "scanobjects" (array, required) Array of scan objects +/// > [ Every scan object is either a string descriptor or an object: +/// > "descriptor", (string, optional) An output descriptor +/// > { (object, optional) An object with output descriptor and metadata +/// > "desc": "descriptor", (string, required) An output descriptor +/// > "range": n, (numeric, optional) Up to what child index HD chains should be explored (default: 1000) +/// > }, +/// > ... +/// ] +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +pub struct ScanTxOutSet { + /// The unspents + pub unspents: Vec, + /// The total amount of all found unspent outputs in BTC + pub total_amount: f64, +} + +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +pub struct ScanTxOutSetUnspent { + /// The transaction id + pub txid: String, + /// The vout value + pub vout: u32, + /// The script key + #[serde(rename = "scriptPubKey")] + pub script_pub_key: String, + /// The total amount in BTC of unspent output + pub amount: f64, + /// Height of the unspent transaction output + pub height: u64, +} diff --git a/types/src/v17/mod.rs b/types/src/v17/mod.rs index 02c7ceef..310d0d12 100644 --- a/types/src/v17/mod.rs +++ b/types/src/v17/mod.rs @@ -234,8 +234,8 @@ pub use self::{ GetMempoolDescendantsVerbose, GetMempoolEntry, GetMempoolInfo, GetMempoolInfoError, GetRawMempool, GetRawMempoolVerbose, GetTxOut, GetTxOutError, GetTxOutSetInfo, GetTxOutSetInfoError, MapMempoolEntryError, MempoolEntry, MempoolEntryError, - MempoolEntryFees, MempoolEntryFeesError, ScriptPubkey, Softfork, SoftforkReject, - VerifyTxOutProof, + MempoolEntryFees, MempoolEntryFeesError, PruneBlockchain, SaveMempool, ScanTxOutSet, + ScanTxOutSetUnspent, ScriptPubkey, Softfork, SoftforkReject, VerifyChain, VerifyTxOutProof, }, control::{GetMemoryInfoStats, Locked, Logging}, generating::{Generate, GenerateToAddress}, @@ -244,29 +244,34 @@ pub use self::{ GetBlockTemplateError, GetMiningInfo, }, network::{ - AddedNode, AddedNodeAddress, Banned, GetAddedNodeInfo, GetNetTotals, GetNetworkInfo, - GetNetworkInfoAddress, GetNetworkInfoError, GetNetworkInfoNetwork, GetPeerInfo, ListBanned, - PeerInfo, UploadTarget, + AddNode, AddedNode, AddedNodeAddress, Banned, ClearBanned, DisconnectNode, + GetAddedNodeInfo, GetConnectionCount, GetNetTotals, GetNetworkInfo, GetNetworkInfoAddress, + GetNetworkInfoError, GetNetworkInfoNetwork, GetPeerInfo, ListBanned, PeerInfo, Ping, + SetBan, SetNetworkActive, UploadTarget, }, raw_transactions::{ CreateRawTransaction, FundRawTransaction, FundRawTransactionError, SendRawTransaction, }, wallet::{ - AddMultisigAddress, AddMultisigAddressError, AddressInformation, BumpFee, BumpFeeError, - CreateWallet, DumpPrivKey, DumpWallet, GetAddressInfo, GetAddressInfoEmbedded, + AbandonTransaction, AbortRescan, AddMultisigAddress, AddMultisigAddressError, + AddressInformation, BackupWallet, BumpFee, BumpFeeError, CreateWallet, DumpPrivKey, + DumpWallet, EncryptWallet, GetAddressInfo, GetAddressInfoEmbedded, GetAddressInfoEmbeddedError, GetAddressInfoError, GetAddressInfoLabel, GetAddressesByLabel, GetBalance, GetNewAddress, GetRawChangeAddress, GetReceivedByAddress, GetTransaction, GetTransactionDetail, GetTransactionDetailError, GetTransactionError, - GetUnconfirmedBalance, GetWalletInfo, GetWalletInfoError, ListAddressGroupings, - ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, - ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddress, + GetUnconfirmedBalance, GetWalletInfo, GetWalletInfoError, ImportAddress, ImportMulti, + ImportPrivKey, ImportPrunedFunds, ImportPubKey, ImportWallet, KeypoolRefill, + ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, + ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddress, ListReceivedByAddressError, ListReceivedByAddressItem, ListSinceBlock, ListSinceBlockError, ListSinceBlockTransaction, ListSinceBlockTransactionError, ListTransactions, ListTransactionsItem, ListTransactionsItemError, ListUnspent, ListUnspentItem, - ListUnspentItemError, ListWallets, LoadWallet, RescanBlockchain, SendMany, SendToAddress, - SignErrorData, SignErrorDataError, SignMessage, SignRawTransactionWithWallet, + ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, RemovePrunedFunds, + RescanBlockchain, SendMany, SendToAddress, SetHdSeed, SetTxFee, SignErrorData, + SignErrorDataError, SignMessage, SignRawTransactionWithWallet, SignRawTransactionWithWalletError, TransactionCategory, WalletCreateFundedPsbt, - WalletCreateFundedPsbtError, WalletProcessPsbt, + WalletCreateFundedPsbtError, WalletLock, WalletPassPhrase, WalletPassPhraseChange, + WalletProcessPsbt, }, zmq::GetZmqNotifications, }; diff --git a/types/src/v17/network/mod.rs b/types/src/v17/network/mod.rs index 7b84fdb6..96ac7b44 100644 --- a/types/src/v17/network/mod.rs +++ b/types/src/v17/network/mod.rs @@ -257,4 +257,105 @@ pub struct ListBanned(pub Vec); /// An item from the list returned by the JSON-RPC method `listbanned` #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] -pub struct Banned(String); // FIXME: The docs are empty so I don't know what shape this is. +pub struct Banned { + /// The IP/Subnet of the banned node (Present in all versions) + pub address: String, + /// The UNIX epoch time the ban was created (Present v17+) + /// None if missing in JSON + pub ban_created: Option, + /// The UNIX epoch time the ban expires (Present v17+) + pub banned_until: Option, + /// The ban reason string (Present only in v17 - v20) + pub ban_reason: Option, + /// The ban duraction, in seconds (Present v22+) + pub ban_duration: Option, + /// The time remaining until ban expires, in seconds (Present v22+) + pub time_remaining: Option, +} + +/// Result of JSON-RPC method `addnode`. +/// +/// > addnode +/// > +/// > Returns null (json null) +/// > +/// > Arguments: +/// > 1. node (string, required) The address of the peer to connect to +/// > 2. command (string, required) 'add' to add a node to the list, 'remove' to remove a node from the list, 'onetry' to try a connection to the node once +/// > 3. v2transport (boolean, optional, default=set by -v2transport) Attempt to connect using BIP324 v2 transport protocol (ignored for 'remove' command) +#[derive(Deserialize, Debug, Clone, PartialEq, Eq)] +pub struct AddNode; + +/// Result of JSON-RPC method `clearbanned`. +/// +/// > clearbanned +/// > +/// > Returns null (json null) +#[derive(Deserialize, Debug, Clone, PartialEq, Eq)] +pub struct ClearBanned; + +/// Result of JSON-RPC method `setban`. +/// +/// > setban +/// > +/// > Returns null (json null) +/// > +/// > Arguments: +/// > 1. subnet (string, required) The IP/Subnet (see getpeerinfo for nodes IP) with an optional netmask (default is /32 = single IP) +/// > 2. command (string, required) 'add' to add an IP/Subnet to the list, 'remove' to remove an IP/Subnet from the list +/// > 3. bantime (numeric, optional, default=0) time in seconds how long (or until when if \[absolute\] is set) the IP is banned (0 or empty means using the default time of 24h which can also be overwritten by the -bantime startup argument) +/// > 4. absolute (boolean, optional, default=false) If set, the bantime must be an absolute timestamp expressed in UNIX epoch time +#[derive(Deserialize, Debug, Clone, PartialEq, Eq)] +pub struct SetBan; + +/// Result of JSON-RPC method `disconnectnode`. +/// +/// > disconnectnode +/// > +/// > Returns null (json null) +/// > +/// > Arguments: +/// > 1. address (string, optional, default=fallback to nodeid) The IP address/port of the node +/// > 2. nodeid (numeric, optional, default=fallback to address) The node ID (see getpeerinfo for node IDs) +#[derive(Deserialize, Debug, Clone, PartialEq, Eq)] +pub struct DisconnectNode; + +/// Result of JSON-RPC method `ping`. +/// +/// > ping +/// > +/// > Returns null (json null) +#[derive(Deserialize, Debug, Clone, PartialEq, Eq)] +pub struct Ping; + +/// Result of JSON-RPC method `setnetworkactive`. +/// +/// > setnetworkactive +/// > +/// > Returns null (json null) +/// > +/// > Arguments: +/// > 1. state (boolean, required) true to enable networking, false to disable +#[derive(Deserialize, Debug, Clone, PartialEq, Eq)] +pub struct SetNetworkActive; + +/// Result of JSON-RPC method `importprivkey`. +/// +/// > importprivkey +/// > +/// > Returns null (json null) +/// > +/// > Arguments: +/// > 1. privkey (string, required) The private key (see dumpprivkey) +/// > 2. label (string, optional, default=current label if address exists, otherwise "") An optional label +/// > 3. rescan (boolean, optional, default=true) Scan the chain and mempool for wallet transactions. +#[derive(Deserialize, Debug, Clone, PartialEq, Eq)] +pub struct ImportPrivKey; + +/// Result of JSON-RPC method `getconnectioncount`. +/// +/// > getconnectioncount +/// > +/// > Returns n (numeric) The connection count +#[derive(Deserialize, Debug, Clone, PartialEq, Eq, PartialOrd, Ord)] +pub struct GetConnectionCount(pub u64); diff --git a/types/src/v17/wallet/mod.rs b/types/src/v17/wallet/mod.rs index e035b1b4..38d2c83e 100644 --- a/types/src/v17/wallet/mod.rs +++ b/types/src/v17/wallet/mod.rs @@ -990,3 +990,255 @@ pub struct WalletProcessPsbt { /// If the transaction has a complete set of signatures. pub complete: bool, } + +/// Result of the JSON-RPC method `abandontransaction`. +/// +/// > abandontransaction "txid" +/// > +/// > +/// > +/// > Arguments: +/// > 1. txid (string, required) The transaction id +/// > +/// > Result null (json null) +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +pub struct AbandonTransaction; + +/// Result of JSON-RPC method `abortrescan`. +/// +/// > abortrescan +/// > +/// > Returns null +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +pub struct AbortRescan; + +/// Result of JSON-RPC method `backupwallet`. +/// +/// > backupwallet +/// > +/// > Returns null (json null) +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +pub struct BackupWallet; + +/// Result of JSON-RPC method `encryptwallet`. +/// +/// > encryptwallet +/// > +/// > Arguments: +/// > 1. passphrase (string, required) The pass phrase to encrypt the wallet with. It must be at least 1 character, but should be long. +/// > +/// > Returns null (json null) +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +pub struct EncryptWallet; + +/// Result of JSON-RPC method `importaddress`. +/// +/// > importaddress +/// > +/// > Arguments: +/// > 1. address (string, required) The Bitcoin address (or hex-encoded script) +/// > 2. label (string, optional, default="") An optional label +/// > 3. rescan (boolean, optional, default=true) Scan the chain and mempool for wallet transactions. +/// > 4. p2sh (boolean, optional, default=false) Add the P2SH version of the script as well +/// > +/// > Returns null (json null) +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +pub struct ImportAddress; + +/// Result of JSON-RPC method `importprivkey`. +/// +/// > importprivkey +/// > +/// > Arguments: +/// > 1. privkey (string, required) The private key (see dumpprivkey) +/// > 2. label (string, optional, default=current label if address exists, otherwise "") An optional label +/// > 3. rescan (boolean, optional, default=true) Rescan the wallet for transactions +/// > +/// > Returns null (json null) +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +pub struct ImportPrivKey; + +/// Result of JSON-RPC method `importprunedfunds`. +/// +/// > importprunedfunds +/// > +/// > Arguments: +/// > 1. rawtransaction (string, required) A raw transaction in hex funding an already-existing address in wallet +/// > 2. txoutproof (string, required) The hex output from gettxoutproof that contains the transaction +/// > +/// > Returns null (json null) +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +pub struct ImportPrunedFunds; + +/// Result of JSON-RPC method `importpubkey`. +/// +/// > importpubkey +/// > +/// > Arguments: +/// > 1. pubkey (string, required) The hex-encoded public key +/// > 2. label (string, optional, default="") An optional label +/// > 3. rescan (boolean, optional, default=true) Scan the chain and mempool for wallet transactions. +/// > +/// > Returns null (json null) +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +pub struct ImportPubKey; + +/// Result of JSON-RPC method `importwallet`. +/// +/// > importwallet +/// > +/// > Arguments: +/// > 1. filename (string, required) The wallet file +/// > +/// > Returns null (json null) +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +pub struct ImportWallet; + +/// Result of JSON-RPC method `keypoolrefill`. +/// +/// > keypoolrefill +/// > +/// > Arguments: +/// > 1. newsize (numeric, optional, default=1000, or as set by -keypool) The new keypool size +/// > +/// > Returns null (json null) +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +pub struct KeypoolRefill; + +/// Result of JSON-RPC method `lockunspent`. +/// +/// > lockunspent +/// > +/// > Arguments: +/// > 1. unlock (boolean, required) Whether to unlock (true) or lock (false) the specified transactions +/// > 2. transactions (json array, optional, default=[]) The transaction outputs and within each, the txid (string) vout (numeric). +/// > [ +/// > { (json object) +/// > "txid": "hex", (string, required) The transaction id +/// > "vout": n, (numeric, required) The output number +/// > }, +/// > ... +///] +/// > 3. persistent (boolean, optional, default=false) Whether to write/erase this lock in the wallet database, or keep the change in memory only. Ignored for unlocking. +/// > +/// > Returns null (json null) +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +pub struct LockUnspent(pub bool); + +/// Result of JSON-RPC method `removeprunedfunds`. +/// +/// > removeprunedfunds +/// > +/// > Arguments: +/// > 1. txid (string, required) The hex-encoded id of the transaction you are deleting +/// > +/// > Returns null (json null) +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +pub struct RemovePrunedFunds; + +/// Result of JSON-RPC method `sethdseed`. +/// +/// > sethdseed +/// > +/// > Arguments: +/// > 1. newkeypool (boolean, optional, default=true) Whether to flush old unused addresses, including change addresses, from the keypool and regenerate it. +/// > If true, the next address from getnewaddress and change address from getrawchangeaddress will be from this new seed. +/// > If false, addresses (including change addresses if the wallet already had HD Chain Split enabled) from the existing +/// > keypool will be used until it has been depleted. +/// > 2. seed (string, optional, default=random seed) The WIF private key to use as the new HD seed. +/// > The seed value can be retrieved using the dumpwallet command. It is the private key marked hdseed=1 +/// > +/// > Returns null (json null) +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +pub struct SetHdSeed; + +/// Result of JSON-RPC method `settxfee`. +/// +/// > settxfee +/// > +/// > Arguments: +/// > 1. amount (numeric or string, required) The transaction fee in BTC/kB +/// > +/// > Returns true|false (boolean) Returns true if successful +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +pub struct SetTxFee(pub bool); + +/// Result of JSON-RPC method `walletlock`. +/// +/// > walletlock +/// > +/// > Returns: +/// > null (json null) +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +pub struct WalletLock; + +/// Result of JSON-RPC method `walletpassphrase`. +/// +/// > walletpassphrase +/// > +/// > Arguments: +/// > 1. passphrase (string, required) The wallet passphrase +/// > 2. timeout (numeric, required) The time to keep the decryption key in seconds; capped at 100000000 (~3 years). +/// +/// > Returns: +/// > null (json null) +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +pub struct WalletPassPhrase; + +/// Result of JSON-RPC method `walletpassphrasechange`. +/// +/// > walletpassphrasechange +/// > +/// > Arguments: +/// > 1. oldpassphrase (string, required) The current passphrase +/// > 2. newpassphrase (string, required) The new passphrase +/// +/// > Returns: +/// > null (json null) +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +pub struct WalletPassPhraseChange; + +/// Result of JSON-RPC method `importmulti`. +/// +/// > importmulti requests ( options ) +/// > +/// > Arguments: +/// > 1. requests (json array, required) Data to be imported +/// > [ +/// > { (json object) +/// > "desc": "str", (string, optional) Descriptor to import. If using descriptor, do not also provide address/scriptPubKey, scripts, or pubkeys +/// > "scriptPubKey": "script" | { "address":"address" }, (string / json, required) Type of scriptPubKey (string for script, json for address). Should not be provided if using a descriptor +/// > "timestamp": timestamp | "now", (integer / string, required) Creation time of the key expressed in UNIX epoch time,or the string "now" to substitute the current synced blockchain time. The timestamp of the oldest key will determine how far back blockchain rescans need to begin for missing wallet transactions. "now" can be specified to bypass scanning, for keys which are known to never have been used, and 0 can be specified to scan the entire blockchain. Blocks up to 2 hours before the earliest key creation time of all keys being imported by the importmulti call will be scanned. +/// > "redeemscript": "str", (string, optional) Allowed only if the scriptPubKey is a P2SH or P2SH-P2WSH address/scriptPubKey +/// > "witnessscript": "str", (string, optional) Allowed only if the scriptPubKey is a P2SH-P2WSH or P2WSH address/scriptPubKey +/// > "pubkeys": [ (json array, optional, default=[]) Array of strings giving pubkeys to import. They must occur in P2PKH or P2WPKH scripts. They are not required when the private key is also provided (see the "keys" argument). +/// > "pubKey", (string) +/// > ... +/// > ], +/// > "keys": [ (json array, optional, default=[]) Array of strings giving private keys to import. The corresponding public keys must occur in the output or redeemscript. +/// > "key", (string) +/// > ... +/// > ], +/// > "range": n or \[n,n\], (numeric or array, optional) If a ranged descriptor is used, this specifies the end or the range (in the form \[begin,end\]) to import +/// > "internal": bool, (boolean, optional, default=false) Stating whether matching outputs should be treated as not incoming payments (also known as change) +/// > "watchonly": bool, (boolean, optional, default=false) Stating whether matching outputs should be considered watchonly. +/// > "label": "str", (string, optional, default="") Label to assign to the address, only allowed with internal=false +/// > "keypool": bool, (boolean, optional, default=false) Stating whether imported public keys should be added to the keypool for when users request new addresses. Only allowed when wallet private keys are disabled +/// > }, +/// > ... +/// > ] +/// 2. options (json object, optional) Options object that can be used to pass named arguments, listed below. +/// > Named Arguments: +/// > rescan (boolean, optional, default=true) Scan the chain and mempool for wallet transactions after all imports. +#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)] +pub struct ImportMulti(pub Vec); + +/// Represents a single entry in the importmulti result array. +#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)] +pub struct ImportMultiEntry { + pub success: bool, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub warnings: Option>, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub error: Option, +} diff --git a/types/src/v18/blockchain.rs b/types/src/v18/blockchain.rs new file mode 100644 index 00000000..209d0907 --- /dev/null +++ b/types/src/v18/blockchain.rs @@ -0,0 +1,51 @@ +// SPDX-License-Identifier: CC0-1.0 + +//! The JSON-RPC API for Bitcoin Core `v0.18` - blockchain. +//! +//! Types for methods found under the `== Blockchain ==` section of the API docs. + +use serde::{Deserialize, Serialize}; + +/// Result of JSON-RPC method `scantxoutset`. +/// +/// > scantxoutset "action" ( [scanobjects,...] ) +/// > +/// > Arguments: +/// > 1. action (string, required) The action to execute +/// > "start" for starting a scan +/// > "abort" for aborting the current scan (returns true when abort was successful) +/// > "status" for progress report (in %) of the current scan +/// 2. scanobjects (json array, required) Array of scan objects +/// > Every scan object is either a string descriptor or an object: +/// > [ +/// > "descriptor", (string) An output descriptor +/// > { (json object) An object with output descriptor and metadata +/// > "desc": "str", (string, required) An output descriptor +/// > "range": n or \[n,n\], (numeric or array, optional, default=1000) The range of HD chain indexes to explore (either end or \[begin,end\]) +/// > }, +/// > ... +/// > ] +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +pub struct ScanTxOutSet { + /// The unspents + pub unspents: Vec, + /// The total amount of all found unspent outputs in BTC + pub total_amount: f64, +} + +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +pub struct ScanTxOutSetUnspent { + /// The transaction id + pub txid: String, + /// The vout value + pub vout: u32, + /// The script key + #[serde(rename = "scriptPubKey")] + pub script_pub_key: String, + /// An output descriptor + pub desc: String, + /// The total amount in BTC of unspent output + pub amount: f64, + /// Height of the unspent transaction output + pub height: u64, +} diff --git a/types/src/v18/mod.rs b/types/src/v18/mod.rs index b3f2b31c..cda6b10d 100644 --- a/types/src/v18/mod.rs +++ b/types/src/v18/mod.rs @@ -226,39 +226,47 @@ //! - Method is deprecated. // JSON-RPC types by API section. +mod blockchain; mod control; #[doc(inline)] -pub use self::control::{ActiveCommand, GetRpcInfo}; +pub use self::{ + blockchain::{ScanTxOutSet, ScanTxOutSetUnspent}, + control::{ActiveCommand, GetRpcInfo}, +}; #[doc(inline)] pub use crate::v17::{ - AddMultisigAddress, AddMultisigAddressError, AddedNode, AddedNodeAddress, AddressInformation, - Banned, Bip9Softfork, Bip9SoftforkStatus, BumpFee, BumpFeeError, ChainTips, ChainTipsError, - ChainTipsStatus, CreateRawTransaction, CreateWallet, DumpPrivKey, DumpWallet, - FundRawTransaction, FundRawTransactionError, Generate, GenerateToAddress, GetAddedNodeInfo, - GetAddressInfo, GetAddressInfoEmbedded, GetAddressInfoEmbeddedError, GetAddressInfoError, - GetAddressInfoLabel, GetAddressesByLabel, GetBalance, GetBestBlockHash, GetBlockCount, - GetBlockHash, GetBlockHeader, GetBlockHeaderError, GetBlockHeaderVerbose, - GetBlockHeaderVerboseError, GetBlockStats, GetBlockStatsError, GetBlockTemplate, - GetBlockTemplateError, GetBlockVerboseOne, GetBlockVerboseOneError, GetBlockVerboseZero, - GetBlockchainInfo, GetBlockchainInfoError, GetChainTips, GetChainTxStats, GetChainTxStatsError, - GetDifficulty, GetMemoryInfoStats, GetMempoolAncestors, GetMempoolAncestorsVerbose, - GetMempoolDescendants, GetMempoolDescendantsVerbose, GetMempoolEntry, GetMempoolInfo, - GetMempoolInfoError, GetMiningInfo, GetNetTotals, GetNetworkInfo, GetNetworkInfoAddress, - GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, GetPeerInfo, GetRawChangeAddress, - GetRawMempool, GetRawMempoolVerbose, GetReceivedByAddress, GetTransaction, - GetTransactionDetail, GetTransactionDetailError, GetTransactionError, GetTxOut, GetTxOutError, - GetTxOutSetInfo, GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfo, - GetWalletInfoError, GetZmqNotifications, ListAddressGroupings, ListAddressGroupingsError, + AbandonTransaction, AbortRescan, AddMultisigAddress, AddMultisigAddressError, AddedNode, + AddedNodeAddress, AddressInformation, BackupWallet, Banned, Bip9Softfork, Bip9SoftforkStatus, + BumpFee, BumpFeeError, ChainTips, ChainTipsError, ChainTipsStatus, CreateRawTransaction, + CreateWallet, DumpPrivKey, DumpWallet, EncryptWallet, FundRawTransaction, + FundRawTransactionError, Generate, GenerateToAddress, GetAddedNodeInfo, GetAddressInfo, + GetAddressInfoEmbedded, GetAddressInfoEmbeddedError, GetAddressInfoError, GetAddressInfoLabel, + GetAddressesByLabel, GetBalance, GetBestBlockHash, GetBlockCount, GetBlockHash, GetBlockHeader, + GetBlockHeaderError, GetBlockHeaderVerbose, GetBlockHeaderVerboseError, GetBlockStats, + GetBlockStatsError, GetBlockTemplate, GetBlockTemplateError, GetBlockVerboseOne, + GetBlockVerboseOneError, GetBlockVerboseZero, GetBlockchainInfo, GetBlockchainInfoError, + GetChainTips, GetChainTxStats, GetChainTxStatsError, GetDifficulty, GetMemoryInfoStats, + GetMempoolAncestors, GetMempoolAncestorsVerbose, GetMempoolDescendants, + GetMempoolDescendantsVerbose, GetMempoolEntry, GetMempoolInfo, GetMempoolInfoError, + GetMiningInfo, GetNetTotals, GetNetworkInfo, GetNetworkInfoAddress, GetNetworkInfoError, + GetNetworkInfoNetwork, GetNewAddress, GetPeerInfo, GetRawChangeAddress, GetRawMempool, + GetRawMempoolVerbose, GetReceivedByAddress, GetTransaction, GetTransactionDetail, + GetTransactionDetailError, GetTransactionError, GetTxOut, GetTxOutError, GetTxOutSetInfo, + GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfo, GetWalletInfoError, + GetZmqNotifications, ImportAddress, ImportPrivKey, ImportPrunedFunds, ImportPubKey, + ImportWallet, KeypoolRefill, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListBanned, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddress, ListReceivedByAddressError, ListReceivedByAddressItem, ListSinceBlock, ListSinceBlockError, ListSinceBlockTransaction, ListSinceBlockTransactionError, ListTransactions, ListTransactionsItem, ListTransactionsItemError, ListUnspent, ListUnspentItem, ListUnspentItemError, ListWallets, - LoadWallet, Locked, Logging, MapMempoolEntryError, MempoolEntry, MempoolEntryError, - MempoolEntryFees, MempoolEntryFeesError, PeerInfo, RescanBlockchain, ScriptPubkey, SendMany, - SendRawTransaction, SendToAddress, SignErrorData, SignErrorDataError, SignMessage, + LoadWallet, LockUnspent, Locked, Logging, MapMempoolEntryError, MempoolEntry, + MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, PeerInfo, RemovePrunedFunds, + RescanBlockchain, SaveMempool, ScriptPubkey, SendMany, SendRawTransaction, SendToAddress, + SetHdSeed, SetNetworkActive, SetTxFee, SignErrorData, SignErrorDataError, SignMessage, SignRawTransactionWithWallet, SignRawTransactionWithWalletError, Softfork, SoftforkReject, - TransactionCategory, UploadTarget, VerifyTxOutProof, WalletCreateFundedPsbt, - WalletCreateFundedPsbtError, WalletProcessPsbt, + TransactionCategory, UploadTarget, VerifyChain, VerifyTxOutProof, WalletCreateFundedPsbt, + WalletCreateFundedPsbtError, WalletLock, WalletPassPhrase, WalletPassPhraseChange, + WalletProcessPsbt, }; diff --git a/types/src/v19/blockchain/mod.rs b/types/src/v19/blockchain/mod.rs index 587ee287..e8e2bce6 100644 --- a/types/src/v19/blockchain/mod.rs +++ b/types/src/v19/blockchain/mod.rs @@ -13,6 +13,7 @@ use serde::{Deserialize, Serialize}; // TODO: Remove wildcard, use explicit types. pub use self::error::*; +pub use crate::v18::ScanTxOutSetUnspent; /// Result of JSON-RPC method `getblockchaininfo`. /// @@ -246,3 +247,39 @@ pub struct MempoolEntryFees { /// Modified fees (see above) of in-mempool descendants (including this one) in BTC. pub descendant: f64, } + +/// Result of JSON-RPC method `scantxoutset`. +/// +/// > scantxoutset "action" ( [scanobjects,...] ) +/// > +/// > Arguments: +/// > 1. action (string, required) The action to execute +/// > "start" for starting a scan +/// > "abort" for aborting the current scan (returns true when abort was successful) +/// > "status" for progress report (in %) of the current scan +/// 2. scanobjects (json array, required) Array of scan objects +/// > Every scan object is either a string descriptor or an object: +/// > [ +/// > "descriptor", (string) An output descriptor +/// > { (json object) An object with output descriptor and metadata +/// > "desc": "str", (string, required) An output descriptor +/// > "range": n or \[n,n\], (numeric or array, optional, default=1000) The range of HD chain indexes to explore (either end or \[begin,end\]) +/// > }, +/// > ... +/// > ] + +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +pub struct ScanTxOutSet { + /// Whether the scan is completed + pub success: bool, + /// The number of unspent transaction outputs scanned + pub txouts: u64, + /// The current block height (index) + pub height: u64, + /// The hash of the block at the tip of the chain + pub bestblock: String, + /// The unspents + pub unspents: Vec, + /// The total amount of all found unspent outputs in BTC + pub total_amount: f64, +} diff --git a/types/src/v19/mod.rs b/types/src/v19/mod.rs index f462a836..d3cce898 100644 --- a/types/src/v19/mod.rs +++ b/types/src/v19/mod.rs @@ -233,37 +233,41 @@ pub use self::{ GetBlockFilterError, GetBlockchainInfo, GetBlockchainInfoError, GetMempoolAncestors, GetMempoolAncestorsVerbose, GetMempoolDescendants, GetMempoolDescendantsVerbose, GetMempoolEntry, MapMempoolEntryError, MempoolEntry, MempoolEntryError, MempoolEntryFees, - MempoolEntryFeesError, Softfork, SoftforkType, + MempoolEntryFeesError, ScanTxOutSet, Softfork, SoftforkType, }, wallet::{GetBalances, GetBalancesMine, GetBalancesWatchOnly}, }; #[doc(inline)] pub use crate::v17::{ - AddMultisigAddress, AddMultisigAddressError, AddedNode, AddedNodeAddress, AddressInformation, - Banned, BumpFee, BumpFeeError, ChainTips, ChainTipsError, ChainTipsStatus, - CreateRawTransaction, CreateWallet, DumpPrivKey, DumpWallet, FundRawTransaction, - FundRawTransactionError, Generate, GenerateToAddress, GetAddedNodeInfo, GetAddressInfo, - GetAddressInfoEmbedded, GetAddressInfoEmbeddedError, GetAddressInfoError, GetAddressInfoLabel, - GetAddressesByLabel, GetBalance, GetBestBlockHash, GetBlockCount, GetBlockHash, GetBlockHeader, - GetBlockHeaderError, GetBlockHeaderVerbose, GetBlockHeaderVerboseError, GetBlockStats, - GetBlockStatsError, GetBlockTemplate, GetBlockTemplateError, GetBlockVerboseOne, - GetBlockVerboseOneError, GetBlockVerboseZero, GetChainTips, GetChainTxStats, - GetChainTxStatsError, GetDifficulty, GetMemoryInfoStats, GetMempoolInfo, GetMempoolInfoError, - GetMiningInfo, GetNetTotals, GetNetworkInfo, GetNetworkInfoAddress, GetNetworkInfoError, - GetNetworkInfoNetwork, GetNewAddress, GetPeerInfo, GetRawChangeAddress, GetRawMempool, - GetRawMempoolVerbose, GetReceivedByAddress, GetTransaction, GetTransactionDetail, - GetTransactionDetailError, GetTransactionError, GetTxOut, GetTxOutError, GetTxOutSetInfo, - GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfo, GetWalletInfoError, - GetZmqNotifications, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, - ListBanned, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, - ListReceivedByAddress, ListReceivedByAddressError, ListReceivedByAddressItem, ListSinceBlock, - ListSinceBlockError, ListSinceBlockTransaction, ListSinceBlockTransactionError, - ListTransactions, ListTransactionsItem, ListTransactionsItemError, ListUnspent, - ListUnspentItem, ListUnspentItemError, ListWallets, LoadWallet, Locked, Logging, PeerInfo, - RescanBlockchain, ScriptPubkey, SendMany, SendRawTransaction, SendToAddress, SignErrorData, - SignErrorDataError, SignMessage, SignRawTransactionWithWallet, - SignRawTransactionWithWalletError, SoftforkReject, TransactionCategory, UploadTarget, - VerifyTxOutProof, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WalletProcessPsbt, + AbandonTransaction, AbortRescan, AddMultisigAddress, AddMultisigAddressError, AddedNode, + AddedNodeAddress, AddressInformation, BackupWallet, Banned, BumpFee, BumpFeeError, ChainTips, + ChainTipsError, ChainTipsStatus, CreateRawTransaction, CreateWallet, DumpPrivKey, DumpWallet, + EncryptWallet, FundRawTransaction, FundRawTransactionError, Generate, GenerateToAddress, + GetAddedNodeInfo, GetAddressInfo, GetAddressInfoEmbedded, GetAddressInfoEmbeddedError, + GetAddressInfoError, GetAddressInfoLabel, GetAddressesByLabel, GetBalance, GetBestBlockHash, + GetBlockCount, GetBlockHash, GetBlockHeader, GetBlockHeaderError, GetBlockHeaderVerbose, + GetBlockHeaderVerboseError, GetBlockStats, GetBlockStatsError, GetBlockTemplate, + GetBlockTemplateError, GetBlockVerboseOne, GetBlockVerboseOneError, GetBlockVerboseZero, + GetChainTips, GetChainTxStats, GetChainTxStatsError, GetDifficulty, GetMemoryInfoStats, + GetMempoolInfo, GetMempoolInfoError, GetMiningInfo, GetNetTotals, GetNetworkInfo, + GetNetworkInfoAddress, GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, GetPeerInfo, + GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, GetReceivedByAddress, GetTransaction, + GetTransactionDetail, GetTransactionDetailError, GetTransactionError, GetTxOut, GetTxOutError, + GetTxOutSetInfo, GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfo, + GetWalletInfoError, GetZmqNotifications, ImportAddress, ImportPrivKey, ImportPrunedFunds, + ImportPubKey, ImportWallet, KeypoolRefill, ListAddressGroupings, ListAddressGroupingsError, + ListAddressGroupingsItem, ListBanned, ListLabels, ListLockUnspent, ListLockUnspentItem, + ListLockUnspentItemError, ListReceivedByAddress, ListReceivedByAddressError, + ListReceivedByAddressItem, ListSinceBlock, ListSinceBlockError, ListSinceBlockTransaction, + ListSinceBlockTransactionError, ListTransactions, ListTransactionsItem, + ListTransactionsItemError, ListUnspent, ListUnspentItem, ListUnspentItemError, ListWallets, + LoadWallet, LockUnspent, Locked, Logging, PeerInfo, RemovePrunedFunds, RescanBlockchain, + SaveMempool, ScriptPubkey, SendMany, SendRawTransaction, SendToAddress, SetHdSeed, + SetNetworkActive, SetTxFee, SignErrorData, SignErrorDataError, SignMessage, + SignRawTransactionWithWallet, SignRawTransactionWithWalletError, SoftforkReject, + TransactionCategory, UploadTarget, VerifyChain, VerifyTxOutProof, WalletCreateFundedPsbt, + WalletCreateFundedPsbtError, WalletLock, WalletPassPhrase, WalletPassPhraseChange, + WalletProcessPsbt, }; #[doc(inline)] pub use crate::v18::{ActiveCommand, GetRpcInfo}; diff --git a/types/src/v20/mod.rs b/types/src/v20/mod.rs index 293399b6..c173ad94 100644 --- a/types/src/v20/mod.rs +++ b/types/src/v20/mod.rs @@ -225,35 +225,39 @@ // JSON-RPC types by API section. mod control; +mod network; +mod wallet; #[doc(inline)] pub use self::control::Logging; #[doc(inline)] pub use crate::{ v17::{ - AddMultisigAddress, AddMultisigAddressError, AddedNode, AddedNodeAddress, - AddressInformation, Banned, BumpFee, BumpFeeError, ChainTips, ChainTipsError, - ChainTipsStatus, CreateRawTransaction, CreateWallet, DumpPrivKey, DumpWallet, - FundRawTransaction, FundRawTransactionError, Generate, GenerateToAddress, GetAddedNodeInfo, - GetAddressInfo, GetAddressInfoEmbedded, GetAddressInfoError, GetAddressInfoLabel, - GetAddressesByLabel, GetBalance, GetBestBlockHash, GetBlockCount, GetBlockHash, - GetBlockHeader, GetBlockHeaderError, GetBlockHeaderVerbose, GetBlockHeaderVerboseError, - GetBlockStats, GetBlockStatsError, GetBlockTemplate, GetBlockTemplateError, - GetBlockVerboseOne, GetBlockVerboseOneError, GetBlockVerboseZero, GetChainTips, - GetChainTxStats, GetChainTxStatsError, GetDifficulty, GetMemoryInfoStats, GetMempoolInfo, - GetMempoolInfoError, GetMiningInfo, GetNetTotals, GetNetworkInfo, GetNetworkInfoAddress, - GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, GetPeerInfo, - GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, GetReceivedByAddress, - GetTransaction, GetTransactionDetail, GetTransactionError, GetTxOut, GetTxOutError, - GetTxOutSetInfo, GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfo, - GetZmqNotifications, ListAddressGroupings, ListAddressGroupingsItem, ListBanned, + AbandonTransaction, AddMultisigAddress, AddMultisigAddressError, AddedNode, + AddedNodeAddress, AddressInformation, BackupWallet, Banned, BumpFee, BumpFeeError, + ChainTips, ChainTipsError, ChainTipsStatus, CreateRawTransaction, CreateWallet, + DumpPrivKey, DumpWallet, FundRawTransaction, FundRawTransactionError, Generate, + GenerateToAddress, GetAddedNodeInfo, GetAddressInfo, GetAddressInfoEmbedded, + GetAddressInfoError, GetAddressInfoLabel, GetAddressesByLabel, GetBalance, + GetBestBlockHash, GetBlockCount, GetBlockHash, GetBlockHeader, GetBlockHeaderError, + GetBlockHeaderVerbose, GetBlockHeaderVerboseError, GetBlockStats, GetBlockStatsError, + GetBlockTemplate, GetBlockTemplateError, GetBlockVerboseOne, GetBlockVerboseOneError, + GetBlockVerboseZero, GetChainTips, GetChainTxStats, GetChainTxStatsError, GetDifficulty, + GetMemoryInfoStats, GetMempoolInfo, GetMempoolInfoError, GetMiningInfo, GetNetTotals, + GetNetworkInfo, GetNetworkInfoAddress, GetNetworkInfoError, GetNetworkInfoNetwork, + GetNewAddress, GetPeerInfo, GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, + GetReceivedByAddress, GetTransaction, GetTransactionDetail, GetTransactionError, GetTxOut, + GetTxOutError, GetTxOutSetInfo, GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfo, + GetZmqNotifications, ImportAddress, ImportPrivKey, ImportPrunedFunds, ImportPubKey, + ImportWallet, KeypoolRefill, ListAddressGroupings, ListAddressGroupingsItem, ListBanned, ListLabels, ListLockUnspent, ListLockUnspentItem, ListReceivedByAddress, ListReceivedByAddressItem, ListSinceBlock, ListSinceBlockTransaction, ListTransactions, - ListTransactionsItem, ListUnspent, ListUnspentItem, ListWallets, LoadWallet, Locked, - PeerInfo, RescanBlockchain, ScriptPubkey, SendMany, SendRawTransaction, SendToAddress, - SignErrorData, SignMessage, SignRawTransactionWithWallet, SoftforkReject, - TransactionCategory, UploadTarget, VerifyTxOutProof, WalletCreateFundedPsbt, - WalletProcessPsbt, + ListTransactionsItem, ListUnspent, ListUnspentItem, ListWallets, LoadWallet, LockUnspent, + Locked, PeerInfo, RemovePrunedFunds, RescanBlockchain, SaveMempool, ScriptPubkey, SendMany, + SendRawTransaction, SendToAddress, SetHdSeed, SetTxFee, SignErrorData, SignMessage, + SignRawTransactionWithWallet, SoftforkReject, TransactionCategory, UploadTarget, + VerifyChain, VerifyTxOutProof, WalletCreateFundedPsbt, WalletLock, WalletPassPhrase, + WalletPassPhraseChange, WalletProcessPsbt, }, v18::{ActiveCommand, GetRpcInfo}, v19::{ @@ -261,7 +265,11 @@ pub use crate::{ GetBalancesWatchOnly, GetBlockFilter, GetBlockFilterError, GetBlockchainInfo, GetBlockchainInfoError, GetMempoolAncestors, GetMempoolAncestorsVerbose, GetMempoolDescendants, GetMempoolDescendantsVerbose, GetMempoolEntry, MapMempoolEntryError, - MempoolEntry, MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, Softfork, - SoftforkType, + MempoolEntry, MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, ScanTxOutSet, + Softfork, SoftforkType, + }, + v20::{ + network::SetNetworkActive, + wallet::{AbortRescan, EncryptWallet}, }, }; diff --git a/types/src/v20/network.rs b/types/src/v20/network.rs new file mode 100644 index 00000000..609f6cd7 --- /dev/null +++ b/types/src/v20/network.rs @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: CC0-1.0 + +//! The JSON-RPC API for Bitcoin Core `v0.17` - network. +//! +//! Types for methods found under the `== Network ==` section of the API docs. +//! +/// These types do not implement `into_model` because no `rust-bitcoin` types needed yet. +use serde::Deserialize; + +/// Result of JSON-RPC method `setnetworkactive`. +/// +/// > setnetworkactive +/// > +/// > Returns null (json null) +/// > +/// > Arguments: +/// > 1. state (boolean, required) true to enable networking, false to disable +/// > +/// > Returns true|false (boolean) The value that was passed in +#[derive(Deserialize, Debug, Clone, PartialEq, Eq)] +pub struct SetNetworkActive(pub bool); diff --git a/types/src/v20/wallet.rs b/types/src/v20/wallet.rs new file mode 100644 index 00000000..2dfe87a3 --- /dev/null +++ b/types/src/v20/wallet.rs @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: CC0-1.0 + +//! The JSON-RPC API for Bitcoin Core `v20` - wallet. +//! +//! Types for methods found under the `== Wallet ==` section of the API docs. + +// use alloc::collections::BTreeMap; + +// use bitcoin::amount::ParseAmountError; +// use bitcoin::key::{self, PrivateKey}; +// use bitcoin::{hex, Amount, Txid}; +use serde::{Deserialize, Serialize}; + +/// Result of JSON-RPC method `abortrescan`. +/// +/// > abortrescan +/// > +/// > Returns null +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +pub struct AbortRescan(pub bool); + +/// Result of JSON-RPC method `encryptwallet`. +/// +/// > encryptwallet +/// > +/// > Arguments: +/// > 1. passphrase (string, required) The pass phrase to encrypt the wallet with. It must be at least 1 character, but should be long. +/// > +/// > Returns "str" (string) A string with further instructions +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +pub struct EncryptWallet(pub String); diff --git a/types/src/v21/mod.rs b/types/src/v21/mod.rs index 8f6adb01..753c83b5 100644 --- a/types/src/v21/mod.rs +++ b/types/src/v21/mod.rs @@ -237,29 +237,31 @@ pub use self::wallet::UnloadWallet; #[doc(inline)] pub use crate::{ v17::{ - AddMultisigAddress, AddMultisigAddressError, AddedNode, AddedNodeAddress, - AddressInformation, Banned, BumpFee, BumpFeeError, ChainTips, ChainTipsError, - ChainTipsStatus, CreateRawTransaction, CreateWallet, DumpPrivKey, DumpWallet, - FundRawTransaction, FundRawTransactionError, Generate, GenerateToAddress, GetAddedNodeInfo, - GetAddressInfo, GetAddressInfoEmbedded, GetAddressInfoError, GetAddressInfoLabel, - GetAddressesByLabel, GetBalance, GetBestBlockHash, GetBlockCount, GetBlockHash, - GetBlockHeader, GetBlockHeaderError, GetBlockHeaderVerbose, GetBlockHeaderVerboseError, - GetBlockStats, GetBlockStatsError, GetBlockTemplate, GetBlockTemplateError, - GetBlockVerboseOne, GetBlockVerboseOneError, GetBlockVerboseZero, GetChainTips, - GetChainTxStats, GetChainTxStatsError, GetDifficulty, GetMemoryInfoStats, GetMempoolInfo, - GetMempoolInfoError, GetMiningInfo, GetNetTotals, GetNetworkInfo, GetNetworkInfoAddress, - GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, GetPeerInfo, - GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, GetReceivedByAddress, - GetTransaction, GetTransactionDetail, GetTransactionError, GetTxOut, GetTxOutError, - GetTxOutSetInfo, GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfo, - GetZmqNotifications, ListAddressGroupings, ListAddressGroupingsItem, ListBanned, - ListLabels, ListLockUnspent, ListLockUnspentItem, ListReceivedByAddress, - ListReceivedByAddressItem, ListSinceBlock, ListSinceBlockTransaction, ListTransactions, - ListTransactionsItem, ListUnspent, ListUnspentItem, ListWallets, LoadWallet, Locked, - PeerInfo, RescanBlockchain, ScriptPubkey, SendMany, SendRawTransaction, SendToAddress, - SignErrorData, SignMessage, SignRawTransactionWithWallet, SoftforkReject, - TransactionCategory, UploadTarget, VerifyTxOutProof, WalletCreateFundedPsbt, - WalletProcessPsbt, + AbandonTransaction, AddMultisigAddress, AddMultisigAddressError, AddedNode, + AddedNodeAddress, AddressInformation, BackupWallet, Banned, BumpFee, BumpFeeError, + ChainTips, ChainTipsError, ChainTipsStatus, CreateRawTransaction, CreateWallet, + DumpPrivKey, DumpWallet, FundRawTransaction, FundRawTransactionError, Generate, + GenerateToAddress, GetAddedNodeInfo, GetAddressInfo, GetAddressInfoEmbedded, + GetAddressInfoError, GetAddressInfoLabel, GetAddressesByLabel, GetBalance, + GetBestBlockHash, GetBlockCount, GetBlockHash, GetBlockHeader, GetBlockHeaderError, + GetBlockHeaderVerbose, GetBlockHeaderVerboseError, GetBlockStats, GetBlockStatsError, + GetBlockTemplate, GetBlockTemplateError, GetBlockVerboseOne, GetBlockVerboseOneError, + GetBlockVerboseZero, GetChainTips, GetChainTxStats, GetChainTxStatsError, GetDifficulty, + GetMemoryInfoStats, GetMempoolInfo, GetMempoolInfoError, GetMiningInfo, GetNetTotals, + GetNetworkInfo, GetNetworkInfoAddress, GetNetworkInfoError, GetNetworkInfoNetwork, + GetNewAddress, GetPeerInfo, GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, + GetReceivedByAddress, GetTransaction, GetTransactionDetail, GetTransactionError, GetTxOut, + GetTxOutError, GetTxOutSetInfo, GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfo, + GetZmqNotifications, ImportAddress, ImportPrivKey, ImportPrunedFunds, ImportPubKey, + ImportWallet, ListAddressGroupings, ListAddressGroupingsItem, ListBanned, ListLabels, + ListLockUnspent, ListLockUnspentItem, ListReceivedByAddress, ListReceivedByAddressItem, + ListSinceBlock, ListSinceBlockTransaction, ListTransactions, ListTransactionsItem, + ListUnspent, ListUnspentItem, ListWallets, LoadWallet, LockUnspent, Locked, PeerInfo, + RemovePrunedFunds, RescanBlockchain, SaveMempool, ScriptPubkey, SendMany, + SendRawTransaction, SendToAddress, SetHdSeed, SetTxFee, SignErrorData, SignMessage, + SignRawTransactionWithWallet, SoftforkReject, TransactionCategory, UploadTarget, + VerifyChain, VerifyTxOutProof, WalletCreateFundedPsbt, WalletLock, WalletPassPhrase, + WalletPassPhraseChange, WalletProcessPsbt, }, v18::{ActiveCommand, GetRpcInfo}, v19::{ @@ -267,8 +269,8 @@ pub use crate::{ GetBalancesWatchOnly, GetBlockFilter, GetBlockFilterError, GetBlockchainInfo, GetBlockchainInfoError, GetMempoolAncestors, GetMempoolAncestorsVerbose, GetMempoolDescendants, GetMempoolDescendantsVerbose, GetMempoolEntry, MapMempoolEntryError, - MempoolEntry, MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, Softfork, - SoftforkType, + MempoolEntry, MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, ScanTxOutSet, + Softfork, SoftforkType, }, - v20::Logging, + v20::{AbortRescan, Logging, SetNetworkActive}, }; diff --git a/types/src/v22/blockchain.rs b/types/src/v22/blockchain.rs index 6d6c1347..6fa917fb 100644 --- a/types/src/v22/blockchain.rs +++ b/types/src/v22/blockchain.rs @@ -10,6 +10,7 @@ use bitcoin::{address, amount, hex, Address, Amount, BlockHash, ScriptBuf, TxOut use serde::{Deserialize, Serialize}; use crate::error::write_err; +use crate::v19::ScanTxOutSet as ScanTxOutSetStart; use crate::{model, NumericError}; /// Result of JSON-RPC method `gettxout`. @@ -128,3 +129,20 @@ impl std::error::Error for GetTxOutError { impl From for GetTxOutError { fn from(e: NumericError) -> Self { Self::Numeric(e) } } + +#[derive(Deserialize, Debug, Clone, PartialEq)] +pub struct ScanTxOutSetStatus { + /// Approximate percent complete + pub progress: f64, +} + +#[derive(Deserialize, Debug, Clone, PartialEq)] +#[serde(untagged)] +pub enum ScanTxOutSet { + /// Returns after scan completes + Start(ScanTxOutSetStart), + /// True (scan will be aborted), False (no scan to abort) + Abort(bool), + /// Scan in progress or Completed + Status(Option), +} diff --git a/types/src/v22/mod.rs b/types/src/v22/mod.rs index 28f572af..2e0dcddd 100644 --- a/types/src/v22/mod.rs +++ b/types/src/v22/mod.rs @@ -246,34 +246,37 @@ mod control; #[doc(inline)] pub use self::{ - blockchain::{GetTxOut, GetTxOutError, ScriptPubkey}, + blockchain::{GetTxOut, GetTxOutError, ScanTxOutSet, ScanTxOutSetStatus, ScriptPubkey}, control::Logging, }; #[doc(inline)] pub use crate::{ v17::{ - AddMultisigAddress, AddMultisigAddressError, AddedNode, AddedNodeAddress, - AddressInformation, Banned, BumpFee, BumpFeeError, ChainTips, ChainTipsError, - ChainTipsStatus, CreateRawTransaction, CreateWallet, DumpPrivKey, DumpWallet, - FundRawTransaction, FundRawTransactionError, Generate, GenerateToAddress, GetAddedNodeInfo, - GetAddressInfo, GetAddressInfoEmbedded, GetAddressInfoError, GetAddressInfoLabel, - GetAddressesByLabel, GetBalance, GetBestBlockHash, GetBlockCount, GetBlockHash, - GetBlockHeader, GetBlockHeaderError, GetBlockHeaderVerbose, GetBlockHeaderVerboseError, - GetBlockStats, GetBlockStatsError, GetBlockTemplate, GetBlockTemplateError, - GetBlockVerboseOne, GetBlockVerboseOneError, GetBlockVerboseZero, GetChainTips, - GetChainTxStats, GetChainTxStatsError, GetDifficulty, GetMemoryInfoStats, GetMempoolInfo, - GetMempoolInfoError, GetMiningInfo, GetNetTotals, GetNetworkInfo, GetNetworkInfoAddress, - GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, GetPeerInfo, - GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, GetReceivedByAddress, - GetTransaction, GetTransactionDetail, GetTransactionError, GetTxOutSetInfo, - GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfo, GetZmqNotifications, - ListAddressGroupings, ListAddressGroupingsItem, ListBanned, ListLabels, ListLockUnspent, - ListLockUnspentItem, ListReceivedByAddress, ListReceivedByAddressItem, ListSinceBlock, - ListSinceBlockTransaction, ListTransactions, ListTransactionsItem, ListUnspent, - ListUnspentItem, ListWallets, LoadWallet, Locked, PeerInfo, RescanBlockchain, SendMany, - SendRawTransaction, SendToAddress, SignErrorData, SignMessage, + AbandonTransaction, AddMultisigAddress, AddMultisigAddressError, AddedNode, + AddedNodeAddress, AddressInformation, BackupWallet, Banned, BumpFee, BumpFeeError, + ChainTips, ChainTipsError, ChainTipsStatus, CreateRawTransaction, CreateWallet, + DumpPrivKey, DumpWallet, FundRawTransaction, FundRawTransactionError, Generate, + GenerateToAddress, GetAddedNodeInfo, GetAddressInfo, GetAddressInfoEmbedded, + GetAddressInfoError, GetAddressInfoLabel, GetAddressesByLabel, GetBalance, + GetBestBlockHash, GetBlockCount, GetBlockHash, GetBlockHeader, GetBlockHeaderError, + GetBlockHeaderVerbose, GetBlockHeaderVerboseError, GetBlockStats, GetBlockStatsError, + GetBlockTemplate, GetBlockTemplateError, GetBlockVerboseOne, GetBlockVerboseOneError, + GetBlockVerboseZero, GetChainTips, GetChainTxStats, GetChainTxStatsError, GetDifficulty, + GetMemoryInfoStats, GetMempoolInfo, GetMempoolInfoError, GetMiningInfo, GetNetTotals, + GetNetworkInfo, GetNetworkInfoAddress, GetNetworkInfoError, GetNetworkInfoNetwork, + GetNewAddress, GetPeerInfo, GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, + GetReceivedByAddress, GetTransaction, GetTransactionDetail, GetTransactionError, + GetTxOutSetInfo, GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfo, + GetZmqNotifications, ImportAddress, ImportPrivKey, ImportPrunedFunds, ImportPubKey, + ImportWallet, KeypoolRefill, ListAddressGroupings, ListAddressGroupingsItem, ListBanned, + ListLabels, ListLockUnspent, ListLockUnspentItem, ListReceivedByAddress, + ListReceivedByAddressItem, ListSinceBlock, ListSinceBlockTransaction, ListTransactions, + ListTransactionsItem, ListUnspent, ListUnspentItem, ListWallets, LoadWallet, LockUnspent, + Locked, PeerInfo, RemovePrunedFunds, RescanBlockchain, SaveMempool, SendMany, + SendRawTransaction, SendToAddress, SetHdSeed, SetTxFee, SignErrorData, SignMessage, SignRawTransactionWithWallet, SoftforkReject, TransactionCategory, UploadTarget, - VerifyTxOutProof, WalletCreateFundedPsbt, WalletProcessPsbt, + VerifyChain, VerifyTxOutProof, WalletCreateFundedPsbt, WalletLock, WalletPassPhrase, + WalletPassPhraseChange, WalletProcessPsbt, }, v18::{ActiveCommand, GetRpcInfo}, v19::{ @@ -284,5 +287,6 @@ pub use crate::{ MempoolEntry, MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, Softfork, SoftforkType, }, + v20::{AbortRescan, SetNetworkActive}, v21::UnloadWallet, }; diff --git a/types/src/v23/blockchain.rs b/types/src/v23/blockchain.rs new file mode 100644 index 00000000..33c52a75 --- /dev/null +++ b/types/src/v23/blockchain.rs @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: CC0-1.0 + +//! The JSON-RPC API for Bitcoin Core `v23` - blockchain. +//! +//! Types for methods found under the `== Blockchain ==` section of the API docs. + +use serde::{Deserialize, Serialize}; + +/// Result of JSON-RPC method `savemempool`. +/// +/// Method call: `savemempool` +/// +/// > Returns a json object containing "filename": "str" (string) which is the directory and file where mempool was saved. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +pub struct SaveMempool { + /// The directory and file where the mempool was saved. + pub filename: String, +} diff --git a/types/src/v23/mod.rs b/types/src/v23/mod.rs index b0bc177c..4f606f0a 100644 --- a/types/src/v23/mod.rs +++ b/types/src/v23/mod.rs @@ -232,32 +232,38 @@ //! - Method does not return anything. //! - Method returns a simple type (e.g. bool or integer). //! - Method is deprecated. +mod blockchain; +#[doc(inline)] +pub use self::blockchain::SaveMempool; #[doc(inline)] pub use crate::{ v17::{ - AddMultisigAddress, AddMultisigAddressError, AddedNode, AddedNodeAddress, - AddressInformation, Banned, BumpFee, BumpFeeError, ChainTips, ChainTipsError, - ChainTipsStatus, CreateRawTransaction, CreateWallet, DumpPrivKey, DumpWallet, - FundRawTransaction, FundRawTransactionError, Generate, GenerateToAddress, GetAddedNodeInfo, - GetAddressInfo, GetAddressInfoEmbedded, GetAddressInfoError, GetAddressInfoLabel, - GetAddressesByLabel, GetBalance, GetBestBlockHash, GetBlockCount, GetBlockHash, - GetBlockHeader, GetBlockHeaderError, GetBlockHeaderVerbose, GetBlockHeaderVerboseError, - GetBlockStats, GetBlockStatsError, GetBlockTemplate, GetBlockTemplateError, - GetBlockVerboseOne, GetBlockVerboseOneError, GetBlockVerboseZero, GetChainTips, - GetChainTxStats, GetChainTxStatsError, GetDifficulty, GetMemoryInfoStats, GetMempoolInfo, - GetMempoolInfoError, GetMiningInfo, GetNetTotals, GetNetworkInfo, GetNetworkInfoAddress, - GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, GetPeerInfo, - GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, GetReceivedByAddress, - GetTransaction, GetTransactionDetail, GetTransactionError, GetTxOutSetInfo, - GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfo, GetZmqNotifications, - ListAddressGroupings, ListAddressGroupingsItem, ListBanned, ListLabels, ListLockUnspent, - ListLockUnspentItem, ListReceivedByAddress, ListReceivedByAddressItem, ListSinceBlock, - ListSinceBlockTransaction, ListTransactions, ListTransactionsItem, ListUnspent, - ListUnspentItem, ListWallets, LoadWallet, Locked, PeerInfo, RescanBlockchain, SendMany, - SendRawTransaction, SendToAddress, SignErrorData, SignMessage, + AbandonTransaction, AddMultisigAddress, AddMultisigAddressError, AddedNode, + AddedNodeAddress, AddressInformation, BackupWallet, Banned, BumpFee, BumpFeeError, + ChainTips, ChainTipsError, ChainTipsStatus, CreateRawTransaction, CreateWallet, + DumpPrivKey, DumpWallet, FundRawTransaction, FundRawTransactionError, Generate, + GenerateToAddress, GetAddedNodeInfo, GetAddressInfo, GetAddressInfoEmbedded, + GetAddressInfoError, GetAddressInfoLabel, GetAddressesByLabel, GetBalance, + GetBestBlockHash, GetBlockCount, GetBlockHash, GetBlockHeader, GetBlockHeaderError, + GetBlockHeaderVerbose, GetBlockHeaderVerboseError, GetBlockStats, GetBlockStatsError, + GetBlockTemplate, GetBlockTemplateError, GetBlockVerboseOne, GetBlockVerboseOneError, + GetBlockVerboseZero, GetChainTips, GetChainTxStats, GetChainTxStatsError, GetDifficulty, + GetMemoryInfoStats, GetMempoolInfo, GetMempoolInfoError, GetMiningInfo, GetNetTotals, + GetNetworkInfo, GetNetworkInfoAddress, GetNetworkInfoError, GetNetworkInfoNetwork, + GetNewAddress, GetPeerInfo, GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, + GetReceivedByAddress, GetTransaction, GetTransactionDetail, GetTransactionError, + GetTxOutSetInfo, GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfo, + GetZmqNotifications, ImportAddress, ImportPrivKey, ImportPrunedFunds, ImportPubKey, + ImportWallet, KeypoolRefill, ListAddressGroupings, ListAddressGroupingsItem, ListBanned, + ListLabels, ListLockUnspent, ListLockUnspentItem, ListReceivedByAddress, + ListReceivedByAddressItem, ListSinceBlock, ListSinceBlockTransaction, ListTransactions, + ListTransactionsItem, ListUnspent, ListUnspentItem, ListWallets, LoadWallet, LockUnspent, + Locked, PeerInfo, RemovePrunedFunds, RescanBlockchain, SendMany, SendRawTransaction, + SendToAddress, SetHdSeed, SetTxFee, SignErrorData, SignMessage, SignRawTransactionWithWallet, SoftforkReject, TransactionCategory, UploadTarget, - VerifyTxOutProof, WalletCreateFundedPsbt, WalletProcessPsbt, + VerifyChain, VerifyTxOutProof, WalletCreateFundedPsbt, WalletLock, WalletPassPhrase, + WalletPassPhraseChange, WalletProcessPsbt, }, v18::{ActiveCommand, GetRpcInfo}, v19::{ @@ -268,6 +274,7 @@ pub use crate::{ MempoolEntry, MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, Softfork, SoftforkType, }, + v20::{AbortRescan, SetNetworkActive}, v21::UnloadWallet, - v22::{GetTxOut, GetTxOutError, Logging, ScriptPubkey}, + v22::{GetTxOut, GetTxOutError, Logging, ScanTxOutSet, ScanTxOutSetStatus, ScriptPubkey}, }; diff --git a/types/src/v24/mod.rs b/types/src/v24/mod.rs index 63488831..695ec3cc 100644 --- a/types/src/v24/mod.rs +++ b/types/src/v24/mod.rs @@ -240,28 +240,30 @@ #[doc(inline)] pub use crate::{ v17::{ - AddMultisigAddress, AddMultisigAddressError, AddedNode, AddedNodeAddress, - AddressInformation, Banned, BumpFee, BumpFeeError, ChainTips, ChainTipsError, - ChainTipsStatus, CreateRawTransaction, CreateWallet, DumpPrivKey, DumpWallet, - FundRawTransaction, FundRawTransactionError, Generate, GenerateToAddress, GetAddedNodeInfo, - GetAddressInfo, GetAddressInfoEmbedded, GetAddressInfoError, GetAddressInfoLabel, - GetAddressesByLabel, GetBalance, GetBestBlockHash, GetBlockCount, GetBlockHash, - GetBlockHeader, GetBlockHeaderError, GetBlockHeaderVerbose, GetBlockHeaderVerboseError, - GetBlockStats, GetBlockStatsError, GetBlockTemplate, GetBlockTemplateError, - GetBlockVerboseOne, GetBlockVerboseOneError, GetBlockVerboseZero, GetChainTips, - GetChainTxStats, GetChainTxStatsError, GetDifficulty, GetMemoryInfoStats, GetMempoolInfo, - GetMempoolInfoError, GetMiningInfo, GetNetTotals, GetNetworkInfo, GetNetworkInfoAddress, - GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, GetPeerInfo, - GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, GetReceivedByAddress, - GetTransaction, GetTransactionDetail, GetTransactionError, GetTxOutSetInfo, - GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfo, GetZmqNotifications, - ListAddressGroupings, ListAddressGroupingsItem, ListBanned, ListLabels, ListLockUnspent, - ListLockUnspentItem, ListReceivedByAddress, ListReceivedByAddressItem, ListSinceBlock, - ListSinceBlockTransaction, ListTransactions, ListTransactionsItem, ListUnspent, - ListUnspentItem, ListWallets, LoadWallet, Locked, PeerInfo, RescanBlockchain, SendMany, - SendRawTransaction, SendToAddress, SignErrorData, SignMessage, - SignRawTransactionWithWallet, SoftforkReject, TransactionCategory, UploadTarget, - VerifyTxOutProof, WalletCreateFundedPsbt, WalletProcessPsbt, + AbandonTransaction, AddMultisigAddress, AddMultisigAddressError, AddedNode, + AddedNodeAddress, AddressInformation, BackupWallet, Banned, BumpFee, BumpFeeError, + ChainTips, ChainTipsError, ChainTipsStatus, CreateRawTransaction, CreateWallet, + DumpPrivKey, DumpWallet, FundRawTransaction, FundRawTransactionError, Generate, + GenerateToAddress, GetAddedNodeInfo, GetAddressInfo, GetAddressInfoEmbedded, + GetAddressInfoError, GetAddressInfoLabel, GetAddressesByLabel, GetBalance, + GetBestBlockHash, GetBlockCount, GetBlockHash, GetBlockHeader, GetBlockHeaderError, + GetBlockHeaderVerbose, GetBlockHeaderVerboseError, GetBlockStats, GetBlockStatsError, + GetBlockTemplate, GetBlockTemplateError, GetBlockVerboseOne, GetBlockVerboseOneError, + GetBlockVerboseZero, GetChainTips, GetChainTxStats, GetChainTxStatsError, GetDifficulty, + GetMemoryInfoStats, GetMempoolInfo, GetMempoolInfoError, GetMiningInfo, GetNetTotals, + GetNetworkInfo, GetNetworkInfoAddress, GetNetworkInfoError, GetNetworkInfoNetwork, + GetNewAddress, GetPeerInfo, GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, + GetReceivedByAddress, GetTransaction, GetTransactionDetail, GetTransactionError, + GetTxOutSetInfo, GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfo, + GetZmqNotifications, ImportAddress, ImportPrivKey, ImportPrunedFunds, ImportPubKey, + ImportWallet, KeypoolRefill, ListAddressGroupings, ListAddressGroupingsItem, ListBanned, + ListLabels, ListLockUnspent, ListLockUnspentItem, ListReceivedByAddress, + ListReceivedByAddressItem, ListSinceBlock, ListSinceBlockTransaction, ListTransactions, + ListTransactionsItem, ListUnspent, ListUnspentItem, ListWallets, LoadWallet, LockUnspent, + Locked, PeerInfo, RescanBlockchain, SendMany, SendRawTransaction, SendToAddress, SetHdSeed, + SetTxFee, SignErrorData, SignMessage, SignRawTransactionWithWallet, SoftforkReject, + TransactionCategory, UploadTarget, VerifyChain, VerifyTxOutProof, WalletCreateFundedPsbt, + WalletLock, WalletPassPhrase, WalletPassPhraseChange, WalletProcessPsbt, }, v18::{ActiveCommand, GetRpcInfo}, v19::{ @@ -272,6 +274,8 @@ pub use crate::{ MempoolEntry, MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, Softfork, SoftforkType, }, + v20::{AbortRescan, SetNetworkActive}, v21::UnloadWallet, - v22::{GetTxOut, GetTxOutError, Logging, ScriptPubkey}, + v22::{GetTxOut, GetTxOutError, Logging, ScanTxOutSet, ScanTxOutSetStatus, ScriptPubkey}, + v23::SaveMempool, }; diff --git a/types/src/v25/blockchain.rs b/types/src/v25/blockchain.rs new file mode 100644 index 00000000..09bd3d94 --- /dev/null +++ b/types/src/v25/blockchain.rs @@ -0,0 +1,71 @@ +// SPDX-License-Identifier: CC0-1.0 + +//! The JSON-RPC API for Bitcoin Core `v0.25` - blockchain. +//! +//! Types for methods found under the `== Blockchain ==` section of the API docs. + +use serde::{Deserialize, Serialize}; + +use crate::v22::ScanTxOutSetStatus; + +/// Result of JSON-RPC method `scantxoutset`. +/// +/// > scantxoutset "action" ( [scanobjects,...] ) +/// > +/// > Arguments: +/// > 1. action (string, required) The action to execute +/// > "start" for starting a scan +/// > "abort" for aborting the current scan (returns true when abort was successful) +/// > "status" for progress report (in %) of the current scan +/// 2. scanobjects (json array, required) Array of scan objects +/// > Every scan object is either a string descriptor or an object: +/// > [ +/// > "descriptor", (string) An output descriptor +/// > { (json object) An object with output descriptor and metadata +/// > "desc": "str", (string, required) An output descriptor +/// > "range": n or \[n,n\], (numeric or array, optional, default=1000) The range of HD chain indexes to explore (either end or \[begin,end\]) +/// > }, +/// > ... +/// > ] +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +pub struct ScanTxOutSetStart { + /// Whether the scan is completed + pub success: bool, + /// The number of unspent transaction outputs scanned + pub txouts: u64, + /// The current block height (index) + pub height: u64, + /// The hash of the block at the tip of the chain + pub bestblock: String, + /// The unspents + pub unspents: Vec, + /// The total amount of all found unspent outputs in BTC + pub total_amount: f64, +} + +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +pub struct ScanTxOutSetUnspent { + /// The transaction id + pub txid: String, + /// The vout value + pub vout: u32, + /// The script key + #[serde(rename = "scriptPubKey")] + pub script_pub_key: String, + /// An output descriptor + pub desc: String, + /// The total amount in BTC of unspent output + pub amount: f64, + /// Whether this is a coinbase output + pub coinbase: bool, + /// Height of the unspent transaction output + pub height: u64, +} + +#[derive(Deserialize, Debug, Clone, PartialEq)] +#[serde(untagged)] +pub enum ScanTxOutSet { + Start(ScanTxOutSetStart), + Abort(bool), + Status(Option), +} diff --git a/types/src/v25/mod.rs b/types/src/v25/mod.rs index 9d029430..3a48ee27 100644 --- a/types/src/v25/mod.rs +++ b/types/src/v25/mod.rs @@ -238,35 +238,41 @@ //! - Method returns a simple type (e.g. bool or integer). //! - Method is deprecated. +mod blockchain; mod wallet; #[doc(inline)] -pub use self::wallet::{CreateWallet, LoadWallet, UnloadWallet}; +pub use self::{ + blockchain::{ScanTxOutSet, ScanTxOutSetUnspent}, + wallet::{CreateWallet, LoadWallet, UnloadWallet}, +}; #[doc(inline)] pub use crate::{ v17::{ - AddMultisigAddress, AddMultisigAddressError, AddedNode, AddedNodeAddress, - AddressInformation, Banned, BumpFee, BumpFeeError, ChainTips, ChainTipsError, - ChainTipsStatus, CreateRawTransaction, DumpPrivKey, DumpWallet, FundRawTransaction, - FundRawTransactionError, Generate, GenerateToAddress, GetAddedNodeInfo, GetAddressInfo, - GetAddressInfoEmbedded, GetAddressInfoError, GetAddressInfoLabel, GetAddressesByLabel, - GetBalance, GetBestBlockHash, GetBlockCount, GetBlockHash, GetBlockHeader, - GetBlockHeaderError, GetBlockHeaderVerbose, GetBlockHeaderVerboseError, GetBlockStats, - GetBlockStatsError, GetBlockTemplate, GetBlockTemplateError, GetBlockVerboseOne, - GetBlockVerboseOneError, GetBlockVerboseZero, GetChainTips, GetChainTxStats, - GetChainTxStatsError, GetDifficulty, GetMemoryInfoStats, GetMempoolInfo, + AbandonTransaction, AddMultisigAddress, AddMultisigAddressError, AddedNode, + AddedNodeAddress, AddressInformation, BackupWallet, Banned, BumpFee, BumpFeeError, + ChainTips, ChainTipsError, ChainTipsStatus, CreateRawTransaction, DumpPrivKey, DumpWallet, + FundRawTransaction, FundRawTransactionError, Generate, GenerateToAddress, GetAddedNodeInfo, + GetAddressInfo, GetAddressInfoEmbedded, GetAddressInfoError, GetAddressInfoLabel, + GetAddressesByLabel, GetBalance, GetBestBlockHash, GetBlockCount, GetBlockHash, + GetBlockHeader, GetBlockHeaderError, GetBlockHeaderVerbose, GetBlockHeaderVerboseError, + GetBlockStats, GetBlockStatsError, GetBlockTemplate, GetBlockTemplateError, + GetBlockVerboseOne, GetBlockVerboseOneError, GetBlockVerboseZero, GetChainTips, + GetChainTxStats, GetChainTxStatsError, GetDifficulty, GetMemoryInfoStats, GetMempoolInfo, GetMempoolInfoError, GetMiningInfo, GetNetTotals, GetNetworkInfo, GetNetworkInfoAddress, GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, GetPeerInfo, GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, GetReceivedByAddress, GetTransaction, GetTransactionDetail, GetTransactionError, GetTxOutSetInfo, GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfo, GetZmqNotifications, + ImportAddress, ImportPrivKey, ImportPrunedFunds, ImportPubKey, ImportWallet, KeypoolRefill, ListAddressGroupings, ListAddressGroupingsItem, ListBanned, ListLabels, ListLockUnspent, ListLockUnspentItem, ListReceivedByAddress, ListReceivedByAddressItem, ListSinceBlock, ListSinceBlockTransaction, ListTransactions, ListTransactionsItem, ListUnspent, - ListUnspentItem, ListWallets, Locked, PeerInfo, RescanBlockchain, SendMany, - SendRawTransaction, SendToAddress, SignErrorData, SignMessage, - SignRawTransactionWithWallet, SoftforkReject, TransactionCategory, UploadTarget, - VerifyTxOutProof, WalletCreateFundedPsbt, WalletProcessPsbt, + ListUnspentItem, ListWallets, LockUnspent, Locked, PeerInfo, RemovePrunedFunds, + RescanBlockchain, SendMany, SendRawTransaction, SendToAddress, SetHdSeed, SetTxFee, + SignErrorData, SignMessage, SignRawTransactionWithWallet, SoftforkReject, + TransactionCategory, UploadTarget, VerifyChain, VerifyTxOutProof, WalletCreateFundedPsbt, + WalletLock, WalletPassPhrase, WalletPassPhraseChange, WalletProcessPsbt, }, v18::{ActiveCommand, GetRpcInfo}, v19::{ @@ -277,5 +283,7 @@ pub use crate::{ MempoolEntry, MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, Softfork, SoftforkType, }, + v20::{AbortRescan, SetNetworkActive}, v22::{GetTxOut, GetTxOutError, Logging, ScriptPubkey}, + v23::SaveMempool, }; diff --git a/types/src/v26/mod.rs b/types/src/v26/mod.rs index ad5b9f51..15eabfca 100644 --- a/types/src/v26/mod.rs +++ b/types/src/v26/mod.rs @@ -259,27 +259,30 @@ pub use self::{ #[doc(inline)] pub use crate::{ v17::{ - AddMultisigAddress, AddMultisigAddressError, AddedNode, AddedNodeAddress, - AddressInformation, Banned, BumpFee, BumpFeeError, ChainTips, ChainTipsError, - ChainTipsStatus, CreateRawTransaction, DumpPrivKey, DumpWallet, FundRawTransaction, - FundRawTransactionError, Generate, GenerateToAddress, GetAddedNodeInfo, GetAddressInfo, - GetAddressInfoEmbedded, GetAddressInfoError, GetAddressInfoLabel, GetAddressesByLabel, - GetBalance, GetBestBlockHash, GetBlockCount, GetBlockHash, GetBlockHeader, - GetBlockHeaderError, GetBlockHeaderVerbose, GetBlockHeaderVerboseError, GetBlockStats, - GetBlockStatsError, GetBlockTemplate, GetBlockTemplateError, GetBlockVerboseOne, - GetBlockVerboseOneError, GetBlockVerboseZero, GetChainTips, GetChainTxStats, - GetChainTxStatsError, GetDifficulty, GetMemoryInfoStats, GetMempoolInfo, + AbandonTransaction, AddMultisigAddress, AddMultisigAddressError, AddedNode, + AddedNodeAddress, AddressInformation, BackupWallet, Banned, BumpFee, BumpFeeError, + ChainTips, ChainTipsError, ChainTipsStatus, CreateRawTransaction, DumpPrivKey, DumpWallet, + FundRawTransaction, FundRawTransactionError, Generate, GenerateToAddress, GetAddedNodeInfo, + GetAddressInfo, GetAddressInfoEmbedded, GetAddressInfoError, GetAddressInfoLabel, + GetAddressesByLabel, GetBalance, GetBestBlockHash, GetBlockCount, GetBlockHash, + GetBlockHeader, GetBlockHeaderError, GetBlockHeaderVerbose, GetBlockHeaderVerboseError, + GetBlockStats, GetBlockStatsError, GetBlockTemplate, GetBlockTemplateError, + GetBlockVerboseOne, GetBlockVerboseOneError, GetBlockVerboseZero, GetChainTips, + GetChainTxStats, GetChainTxStatsError, GetDifficulty, GetMemoryInfoStats, GetMempoolInfo, GetMempoolInfoError, GetMiningInfo, GetNetTotals, GetNetworkInfo, GetNetworkInfoAddress, GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, GetPeerInfo, GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, GetReceivedByAddress, GetTransaction, GetTransactionDetail, GetTransactionError, GetUnconfirmedBalance, - GetWalletInfo, GetZmqNotifications, ListAddressGroupings, ListAddressGroupingsItem, + GetWalletInfo, GetZmqNotifications, ImportAddress, ImportPrivKey, ImportPrunedFunds, + ImportPubKey, ImportWallet, KeypoolRefill, ListAddressGroupings, ListAddressGroupingsItem, ListBanned, ListLabels, ListLockUnspent, ListLockUnspentItem, ListReceivedByAddress, ListReceivedByAddressItem, ListSinceBlock, ListSinceBlockTransaction, ListTransactions, - ListTransactionsItem, ListUnspent, ListUnspentItem, ListWallets, Locked, PeerInfo, - RescanBlockchain, SendMany, SendRawTransaction, SendToAddress, SignErrorData, SignMessage, - SignRawTransactionWithWallet, SoftforkReject, TransactionCategory, UploadTarget, - VerifyTxOutProof, WalletCreateFundedPsbt, WalletProcessPsbt, + ListTransactionsItem, ListUnspent, ListUnspentItem, ListWallets, LockUnspent, Locked, + PeerInfo, RemovePrunedFunds, RescanBlockchain, SendMany, SendRawTransaction, SendToAddress, + SetHdSeed, SetTxFee, SignErrorData, SignMessage, SignRawTransactionWithWallet, + SoftforkReject, TransactionCategory, UploadTarget, VerifyChain, VerifyTxOutProof, + WalletCreateFundedPsbt, WalletLock, WalletPassPhrase, WalletPassPhraseChange, + WalletProcessPsbt, }, v18::{ActiveCommand, GetRpcInfo}, v19::{ @@ -290,5 +293,8 @@ pub use crate::{ MempoolEntry, MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, Softfork, SoftforkType, }, + v20::{AbortRescan, SetNetworkActive}, v22::{GetTxOut, GetTxOutError, Logging, ScriptPubkey}, + v23::SaveMempool, + v25::{ScanTxOutSet, ScanTxOutSetUnspent}, }; diff --git a/types/src/v27/mod.rs b/types/src/v27/mod.rs index 0a5d56cd..e3e539c9 100644 --- a/types/src/v27/mod.rs +++ b/types/src/v27/mod.rs @@ -249,27 +249,30 @@ #[doc(inline)] pub use crate::{ v17::{ - AddMultisigAddress, AddMultisigAddressError, AddedNode, AddedNodeAddress, - AddressInformation, Banned, BumpFee, BumpFeeError, ChainTips, ChainTipsError, - ChainTipsStatus, CreateRawTransaction, DumpPrivKey, DumpWallet, FundRawTransaction, - FundRawTransactionError, Generate, GenerateToAddress, GetAddedNodeInfo, GetAddressInfo, - GetAddressInfoEmbedded, GetAddressInfoError, GetAddressInfoLabel, GetAddressesByLabel, - GetBalance, GetBestBlockHash, GetBlockCount, GetBlockHash, GetBlockHeader, - GetBlockHeaderError, GetBlockHeaderVerbose, GetBlockHeaderVerboseError, GetBlockStats, - GetBlockStatsError, GetBlockTemplate, GetBlockTemplateError, GetBlockVerboseOne, - GetBlockVerboseOneError, GetBlockVerboseZero, GetChainTips, GetChainTxStats, - GetChainTxStatsError, GetDifficulty, GetMemoryInfoStats, GetMempoolInfo, + AbandonTransaction, AddMultisigAddress, AddMultisigAddressError, AddedNode, + AddedNodeAddress, AddressInformation, BackupWallet, Banned, BumpFee, BumpFeeError, + ChainTips, ChainTipsError, ChainTipsStatus, CreateRawTransaction, DumpPrivKey, DumpWallet, + FundRawTransaction, FundRawTransactionError, Generate, GenerateToAddress, GetAddedNodeInfo, + GetAddressInfo, GetAddressInfoEmbedded, GetAddressInfoError, GetAddressInfoLabel, + GetAddressesByLabel, GetBalance, GetBestBlockHash, GetBlockCount, GetBlockHash, + GetBlockHeader, GetBlockHeaderError, GetBlockHeaderVerbose, GetBlockHeaderVerboseError, + GetBlockStats, GetBlockStatsError, GetBlockTemplate, GetBlockTemplateError, + GetBlockVerboseOne, GetBlockVerboseOneError, GetBlockVerboseZero, GetChainTips, + GetChainTxStats, GetChainTxStatsError, GetDifficulty, GetMemoryInfoStats, GetMempoolInfo, GetMempoolInfoError, GetMiningInfo, GetNetTotals, GetNetworkInfo, GetNetworkInfoAddress, GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, GetPeerInfo, GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, GetReceivedByAddress, GetTransaction, GetTransactionDetail, GetTransactionError, GetUnconfirmedBalance, - GetWalletInfo, GetZmqNotifications, ListAddressGroupings, ListAddressGroupingsItem, + GetWalletInfo, GetZmqNotifications, ImportAddress, ImportPrivKey, ImportPrunedFunds, + ImportPubKey, ImportWallet, KeypoolRefill, ListAddressGroupings, ListAddressGroupingsItem, ListBanned, ListLabels, ListLockUnspent, ListLockUnspentItem, ListReceivedByAddress, ListReceivedByAddressItem, ListSinceBlock, ListSinceBlockTransaction, ListTransactions, - ListTransactionsItem, ListUnspent, ListUnspentItem, ListWallets, Locked, PeerInfo, - RescanBlockchain, SendMany, SendRawTransaction, SendToAddress, SignErrorData, SignMessage, - SignRawTransactionWithWallet, SoftforkReject, TransactionCategory, UploadTarget, - VerifyTxOutProof, WalletCreateFundedPsbt, WalletProcessPsbt, + ListTransactionsItem, ListUnspent, ListUnspentItem, ListWallets, LockUnspent, Locked, + PeerInfo, RemovePrunedFunds, RescanBlockchain, SendMany, SendRawTransaction, SendToAddress, + SetHdSeed, SetTxFee, SignErrorData, SignMessage, SignRawTransactionWithWallet, + SoftforkReject, TransactionCategory, UploadTarget, VerifyChain, VerifyTxOutProof, + WalletCreateFundedPsbt, WalletLock, WalletPassPhrase, WalletPassPhraseChange, + WalletProcessPsbt, }, v18::{ActiveCommand, GetRpcInfo}, v19::{ @@ -280,7 +283,10 @@ pub use crate::{ MempoolEntry, MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, Softfork, SoftforkType, }, + v20::{AbortRescan, SetNetworkActive}, v22::{GetTxOut, GetTxOutError, Logging, ScriptPubkey}, + v23::SaveMempool, + v25::{ScanTxOutSet, ScanTxOutSetUnspent}, v26::{ CreateWallet, GetPrioritisedTransactions, GetTxOutSetInfo, GetTxOutSetInfoError, LoadWallet, PrioritisedTransaction, UnloadWallet, diff --git a/types/src/v28/blockchain.rs b/types/src/v28/blockchain.rs index 9fe59546..bc33f81f 100644 --- a/types/src/v28/blockchain.rs +++ b/types/src/v28/blockchain.rs @@ -11,6 +11,7 @@ use serde::{Deserialize, Serialize}; use super::{GetBlockchainInfoError, Softfork}; use crate::model; +use crate::v22::ScanTxOutSetStatus; /// Result of JSON-RPC method `getblockchaininfo`. /// @@ -95,3 +96,69 @@ impl GetBlockchainInfo { }) } } + +/// Result of JSON-RPC method `scantxoutset`. +/// +/// > scantxoutset "action" ( [scanobjects,...] ) +/// > +/// > Arguments: +/// > 1. action (string, required) The action to execute +/// > "start" for starting a scan +/// > "abort" for aborting the current scan (returns true when abort was successful) +/// > "status" for progress report (in %) of the current scan +/// 2. scanobjects (json array, required) Array of scan objects +/// Every scan object is either a string descriptor or an object: +/// [ +/// "descriptor", (string) An output descriptor +/// { (json object) An object with output descriptor and metadata +/// "desc": "str", (string, required) An output descriptor +/// "range": n or \[n,n\], (numeric or array, optional, default=1000) The range of HD chain indexes to explore (either end or \[begin,end\]) +/// }, +/// ... +/// ] +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] // v28 +pub struct ScanTxOutSetStart { + /// Whether the scan is completed + pub success: bool, + /// The number of unspent transaction outputs scanned + pub txouts: u64, + /// The current block height (index) + pub height: u64, + /// The hash of the block at the tip of the chain + pub bestblock: String, + /// The unspents + pub unspents: Vec, + /// The total amount of all found unspent outputs in BTC + pub total_amount: f64, +} + +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +pub struct ScanTxOutSetUnspent { + /// The transaction id + pub txid: String, + /// The vout value + pub vout: u32, + /// The script key + #[serde(rename = "scriptPubKey")] + pub script_pub_key: String, + /// An output descriptor + pub desc: String, + /// The total amount in BTC of unspent output + pub amount: f64, + /// Whether this is a coinbase output + pub coinbase: bool, + /// Height of the unspent transaction output + pub height: u64, + /// Blockhash of the unspent transaction output + pub blockhash: String, + /// Number of confirmations of the unspent transaction output when the scan was done + pub confirmations: u64, +} + +#[derive(Deserialize, Debug, Clone, PartialEq)] +#[serde(untagged)] +pub enum ScanTxOutSet { + Start(ScanTxOutSetStart), + Abort(bool), + Status(Option), +} diff --git a/types/src/v28/mod.rs b/types/src/v28/mod.rs index b49ff179..77f729a0 100644 --- a/types/src/v28/mod.rs +++ b/types/src/v28/mod.rs @@ -252,6 +252,7 @@ mod blockchain; mod mining; mod network; mod raw_transactions; +mod wallet; #[doc(inline)] pub use self::raw_transactions::{ @@ -259,31 +260,38 @@ pub use self::raw_transactions::{ SubmitPackageTxResultFees, SubmitPackageTxResultFeesError, }; #[doc(inline)] -pub use self::{blockchain::GetBlockchainInfo, mining::GetMiningInfo, network::GetNetworkInfo}; +pub use self::{ + blockchain::{GetBlockchainInfo, ScanTxOutSet, ScanTxOutSetUnspent}, + mining::GetMiningInfo, + network::GetNetworkInfo, + wallet::{ListTransactions, ListTransactionsItem, ListUnspent, ListUnspentItem}, +}; #[doc(inline)] pub use crate::{ v17::{ - AddMultisigAddress, AddMultisigAddressError, AddedNode, AddedNodeAddress, - AddressInformation, Banned, BumpFee, BumpFeeError, ChainTips, ChainTipsError, - ChainTipsStatus, CreateRawTransaction, DumpPrivKey, DumpWallet, FundRawTransaction, - FundRawTransactionError, Generate, GenerateToAddress, GetAddedNodeInfo, GetAddressInfo, - GetAddressInfoEmbedded, GetAddressInfoError, GetAddressInfoLabel, GetAddressesByLabel, - GetBalance, GetBestBlockHash, GetBlockCount, GetBlockHash, GetBlockHeader, - GetBlockHeaderError, GetBlockHeaderVerbose, GetBlockHeaderVerboseError, GetBlockStats, - GetBlockStatsError, GetBlockTemplate, GetBlockTemplateError, GetBlockVerboseOne, - GetBlockVerboseOneError, GetBlockVerboseZero, GetChainTips, GetChainTxStats, - GetChainTxStatsError, GetDifficulty, GetMemoryInfoStats, GetMempoolInfo, + AbandonTransaction, AddMultisigAddress, AddMultisigAddressError, AddedNode, + AddedNodeAddress, AddressInformation, BackupWallet, Banned, BumpFee, BumpFeeError, + ChainTips, ChainTipsError, ChainTipsStatus, CreateRawTransaction, DumpPrivKey, DumpWallet, + FundRawTransaction, FundRawTransactionError, Generate, GenerateToAddress, GetAddedNodeInfo, + GetAddressInfo, GetAddressInfoEmbedded, GetAddressInfoError, GetAddressInfoLabel, + GetAddressesByLabel, GetBalance, GetBestBlockHash, GetBlockCount, GetBlockHash, + GetBlockHeader, GetBlockHeaderError, GetBlockHeaderVerbose, GetBlockHeaderVerboseError, + GetBlockStats, GetBlockStatsError, GetBlockTemplate, GetBlockTemplateError, + GetBlockVerboseOne, GetBlockVerboseOneError, GetBlockVerboseZero, GetChainTips, + GetChainTxStats, GetChainTxStatsError, GetDifficulty, GetMemoryInfoStats, GetMempoolInfo, GetMempoolInfoError, GetNetTotals, GetNetworkInfoAddress, GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, GetPeerInfo, GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, GetReceivedByAddress, GetTransaction, GetTransactionDetail, GetTransactionError, GetUnconfirmedBalance, GetWalletInfo, GetZmqNotifications, + ImportAddress, ImportPrivKey, ImportPrunedFunds, ImportPubKey, ImportWallet, KeypoolRefill, ListAddressGroupings, ListAddressGroupingsItem, ListBanned, ListLabels, ListLockUnspent, ListLockUnspentItem, ListReceivedByAddress, ListReceivedByAddressItem, ListSinceBlock, - ListSinceBlockTransaction, ListTransactions, ListTransactionsItem, ListUnspent, - ListUnspentItem, ListWallets, Locked, PeerInfo, RescanBlockchain, SendMany, - SendRawTransaction, SendToAddress, SignErrorData, SignMessage, - SignRawTransactionWithWallet, SoftforkReject, TransactionCategory, UploadTarget, - VerifyTxOutProof, WalletCreateFundedPsbt, WalletProcessPsbt, + ListSinceBlockTransaction, ListWallets, LockUnspent, Locked, PeerInfo, PruneBlockchain, + RemovePrunedFunds, RescanBlockchain, SendMany, SendRawTransaction, SendToAddress, + SetHdSeed, SetTxFee, SignErrorData, SignMessage, SignRawTransactionWithWallet, + SoftforkReject, TransactionCategory, UploadTarget, VerifyChain, VerifyTxOutProof, + WalletCreateFundedPsbt, WalletLock, WalletPassPhrase, WalletPassPhraseChange, + WalletProcessPsbt, }, v18::{ActiveCommand, GetRpcInfo}, v19::{ @@ -293,7 +301,9 @@ pub use crate::{ GetMempoolDescendantsVerbose, GetMempoolEntry, MapMempoolEntryError, MempoolEntry, MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, Softfork, SoftforkType, }, + v20::{AbortRescan, SetNetworkActive}, v22::{GetTxOut, GetTxOutError, Logging, ScriptPubkey}, + v23::SaveMempool, v26::{ CreateWallet, GetPrioritisedTransactions, GetTxOutSetInfo, GetTxOutSetInfoError, LoadWallet, PrioritisedTransaction, UnloadWallet, diff --git a/types/src/v28/wallet.rs b/types/src/v28/wallet.rs new file mode 100644 index 00000000..3759be84 --- /dev/null +++ b/types/src/v28/wallet.rs @@ -0,0 +1,132 @@ +// SPDX-License-Identifier: CC0-1.0 + +//! The JSON-RPC API for Bitcoin Core `v28` - wallet. +//! +//! Types for methods found under the `== Wallet ==` section of the API docs. + +use bitcoin::address::NetworkUnchecked; +use bitcoin::{Address, Amount, BlockHash, ScriptBuf, SignedAmount, Txid}; +use serde::{Deserialize, Serialize}; +extern crate bitcoin; + +/// Result of the JSON-RPC method `listunspent`. +/// +/// > listunspent ( minconf maxconf ["addresses",...] `[include_unsafe]` `[query_options]`) +/// > +/// > Returns array of unspent transaction outputs +/// > with between minconf and maxconf (inclusive) confirmations. +/// > Optionally filter to only include txouts paid to specified addresses. +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +pub struct ListUnspent(pub Vec); + +/// Unspent transaction output, returned as part of `listunspent`. +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +#[serde(rename_all = "camelCase")] // Match typical JSON field names +pub struct ListUnspentItem { + /// The transaction id. + pub txid: Txid, + /// The vout value. + pub vout: u32, + /// The bitcoin address of the transaction (optional for non-standard scripts). + pub address: Option>, + /// The associated label, present only if the address is in the address book. + pub label: Option, + /// Optional account field. + pub account: Option, + /// The script key. + #[serde(rename = "scriptPubKey")] + pub script_pubkey: ScriptBuf, + /// The transaction amount. + // Use Amount (unsigned) for UTXOs + #[serde(with = "bitcoin::amount::serde::as_btc")] + pub amount: Amount, + /// The number of confirmations. + pub confirmations: u32, + /// The redeemScript if scriptPubKey is P2SH. + #[serde(rename = "redeemScript")] + pub redeem_script: Option, + /// The witnessScript if the scriptPubKey is P2WSH or P2SH-P2WSH. + #[serde(rename = "witnessScript")] + pub witness_script: Option, + /// Whether we have the private keys to spend this output. + pub spendable: bool, + /// Whether we know how to spend this output, ignoring the lack of keys. + pub solvable: bool, + /// Whether this output is considered safe to spend. + pub safe: bool, + // Add other optional fields if needed for your version (desc, coinbase etc.) + /// Output descriptor if available. + pub desc: Option, + /// Whether this is a coinbase output (added in v25+). + pub coinbase: Option, +} + +/// Transaction item returned as part of `listtransactions`. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] // Removed Eq due to SignedAmount potentially not deriving Eq +#[serde(rename_all = "camelCase")] // Match common JSON names if needed +pub struct ListTransactionsItem { + /// The bitcoin address of the transaction (optional). + // Using Option
as address might not always be present/decodable + pub address: Option>, + /// The transaction category. + pub category: TransactionCategory, + /// The amount. + #[serde(with = "bitcoin::amount::serde::as_btc")] + pub amount: SignedAmount, + /// A comment for the address/transaction, if any. + pub label: Option, + /// The vout value. + pub vout: u32, + /// The amount of the fee in BTC. (Made optional) + pub fee: Option, + /// The number of confirmations for the transaction. + pub confirmations: i64, + /// Whether we consider the outputs of this unconfirmed transaction safe to spend. + pub trusted: Option, + /// The block hash containing the transaction. + #[serde(rename = "blockhash")] + pub block_hash: Option, + /// The index of the transaction in the block that includes it. + #[serde(rename = "blockindex")] + pub block_index: Option, + /// The block time in seconds since epoch (1 Jan 1970 GMT). + #[serde(rename = "blocktime")] + pub block_time: Option, + /// The transaction id. + pub txid: Txid, + /// The transaction time in seconds since epoch (Jan 1 1970 GMT). + pub time: u32, + /// The time received in seconds since epoch (Jan 1 1970 GMT). + #[serde(rename = "timereceived")] + pub time_received: u32, + /// If a comment is associated with the transaction. + pub comment: Option, + /// Whether this transaction could be replaced due to BIP125 (replace-by-fee); + #[serde(rename = "bip125-replaceable")] + pub bip125_replaceable: Bip125Replaceable, + /// If the transaction has been abandoned (inputs are respendable). + pub abandoned: Option, +} + +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +#[serde(rename_all = "lowercase")] +pub enum TransactionCategory { + Send, + Receive, + Generate, + Immature, + Orphan, + Move, +} + +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +#[serde(rename_all = "lowercase")] +pub enum Bip125Replaceable { + Yes, + No, + Unknown, +} + +// Ensure you have the top-level struct too +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +pub struct ListTransactions(pub Vec); diff --git a/verify/rpc-api-v17.txt b/verify/rpc-api-v17.txt index 2001348f..4e11ba63 100644 --- a/verify/rpc-api-v17.txt +++ b/verify/rpc-api-v17.txt @@ -85,7 +85,7 @@ abandontransaction "txid" abortrescan addmultisigaddress nrequired ["key",...] ( "label" "address_type" ) backupwallet "destination" -bumpfee "txid" ( options ) +bumpfee "txid" ( options ) createwallet "wallet_name" ( disable_private_keys ) dumpprivkey "address" dumpwallet "filename" @@ -141,4 +141,4 @@ walletpassphrasechange "oldpassphrase" "newpassphrase" walletprocesspsbt "psbt" ( sign "sighashtype" bip32derivs ) == Zmq == -getzmqnotifications +getzmqnotifications \ No newline at end of file diff --git a/verify/src/method/v17.rs b/verify/src/method/v17.rs index 303ae2f2..71688da1 100644 --- a/verify/src/method/v17.rs +++ b/verify/src/method/v17.rs @@ -30,10 +30,10 @@ pub const METHODS: &[Method] = &[ Method::new_string("gettxoutproof", "get_tx_out_proof"), Method::new_modelled("gettxoutsetinfo", "GetTxOutSetInfo", "get_tx_out_set_info"), Method::new_nothing("preciousblock", "precious_block"), - Method::new_numeric("pruneblockchain", "prune_blockchain"), - Method::new_nothing("savemempool", "save_mempool"), + Method::new_no_model("pruneblockchain", "PruneBlockchain", "prune_blockchain"), + Method::new_no_model("savemempool", "SaveMempool", "save_mempool"), Method::new_modelled("scantxoutset", "ScanTxOutSet", "scan_tx_out_set"), - Method::new_bool("verifychain", "verify_chain"), + Method::new_no_model("verifychain", "VerifyChain", "verify_chain"), Method::new_modelled("verifytxoutproof", "VerifyTxOutProof", "verify_tx_out_proof"), // control Method::new_no_model("getmemoryinfo", "GetMemoryInfoStats", "get_memory_info"), @@ -51,18 +51,18 @@ pub const METHODS: &[Method] = &[ Method::new_bool("prioritisetransaction", "prioritise_transaction"), Method::new_nothing("submitblock", "submit_block"), // network - Method::new_nothing("addnode", "add_node"), - Method::new_nothing("clearbanned", "clear_banned"), - Method::new_nothing("disconnectnode", "disconnect_node"), + Method::new_no_model("addnode", "AddNode", "add_node"), + Method::new_no_model("clearbanned", "ClearBanned", "clear_banned"), + Method::new_no_model("disconnectnode", "DisconnectNode", "disconnect_node"), Method::new_no_model("getaddednodeinfo", "GetAddedNodeInfo", "get_added_node_info"), - Method::new_numeric("getconnectioncount", "get_connection_count"), + Method::new_no_model("getconnectioncount", "GetConnectionCount", "get_connection_count"), Method::new_no_model("getnettotals", "GetNetTotals", "get_net_totals"), Method::new_modelled("getnetworkinfo", "GetNetworkInfo", "get_network_info"), Method::new_no_model("getpeerinfo", "GetPeerInfo", "get_peer_info"), - Method::new_string("listbanned", "list_banned"), // v17 docs seem wrong, says no return. - Method::new_nothing("ping", "ping"), - Method::new_nothing("setban", "set_ban"), - Method::new_nothing("setnetworkactive", "set_network_active"), + Method::new_no_model("listbanned", "ListBanned", "list_banned"), // v17 docs seem wrong, says no return. + Method::new_no_model("ping", "Ping", "ping"), + Method::new_no_model("setban", "SetBan", "set_ban"), + Method::new_no_model("setnetworkactive", "SetNetworkActive", "set_network_active"), // raw transactions Method::new_nothing("combinepsbt", "combine_psbt"), Method::new_nothing("combinerawtransaction", "combine_raw_transaction"), @@ -86,15 +86,15 @@ pub const METHODS: &[Method] = &[ Method::new_modelled("validateaddress", "ValidateAddress", "validate_address"), Method::new_bool("verifymessage", "verify_message"), // wallet - Method::new_nothing("abandontransaction", "abandon_transaction"), - Method::new_nothing("abortrescan", "abort_rescan"), + Method::new_no_model("abandontransaction", "AbandonTransaction", "abandon_transaction"), + Method::new_no_model("abortrescan", "AbortRescan", "abort_rescan"), Method::new_modelled("addmultisigaddress", "AddMultisigAddress", "add_multisig_address"), - Method::new_nothing("backupwallet", "backup_wallet"), + Method::new_no_model("backupwallet", "BackupWallet", "backup_wallet"), Method::new_modelled("bumpfee", "BumpFee", "bump_fee"), Method::new_modelled("createwallet", "CreateWallet", "create_wallet"), Method::new_modelled("dumpprivkey", "DumpPrivKey", "dump_priv_key"), Method::new_modelled("dumpwallet", "DumpWallet", "dump_wallet"), - Method::new_nothing("encryptwallet", "encrypt_wallet"), + Method::new_no_model("encryptwallet", "EncryptWallet", "encrypt_wallet"), Method::new_nothing("getaccount", "get_account"), // Deprecated Method::new_nothing("getaccountaddress", "get_account_address"), // Deprecated Method::new_nothing("getaddressbyaccount", "get_address_by_account"), // Deprecated @@ -113,12 +113,12 @@ pub const METHODS: &[Method] = &[ ), Method::new_modelled("getwalletinfo", "GetWalletInfo", "get_wallet_info"), Method::new_nothing("importaddress", "import_addressss"), - Method::new_nothing("importmulti", "import_multi"), - Method::new_nothing("importprivkey", "import_priv_key"), - Method::new_nothing("importprunedfunds", "import_pruned_funds"), - Method::new_nothing("importpubkey", "import_pubkey"), - Method::new_nothing("importwallet", "import_walet"), - Method::new_nothing("keypoolrefill", "keypool_refill"), + Method::new_modelled("importmulti", "ImportMulti", "import_multi"), + Method::new_no_model("importprivkey", "ImportPrivKey", "import_priv_key"), + Method::new_no_model("importprunedfunds", "ImportPrunedFunds", "import_pruned_funds"), + Method::new_no_model("importpubkey", "ImportPubKey", "import_pubkey"), + Method::new_no_model("importwallet", "ImportWallet", "import_walet"), + Method::new_no_model("keypoolrefill", "KeypoolRefill", "keypool_refill"), Method::new_nothing("listaccounts", "list_accounts"), // Deprecated Method::new_modelled("listaddressgroupings", "ListAddressGroupings", "list_address_groupings"), Method::new_modelled("listlabels", "ListLabels", "list_labels"), @@ -134,16 +134,16 @@ pub const METHODS: &[Method] = &[ Method::new_modelled("listunspent", "ListUnspent", "list_unspent"), Method::new_modelled("listwallets", "ListWallets", "list_wallets"), Method::new_modelled("loadwallet", "LoadWallet", "load_wallet"), - Method::new_bool("lockunspent", "lock_unspent"), + Method::new_no_model("lockunspent", "LockUnspent", "lock_unspent"), Method::new_bool("move", "move"), - Method::new_nothing("removeprunedfunds", "remove_pruned_funds"), + Method::new_no_model("removeprunedfunds", "RemovePrunedFunds", "remove_pruned_funds"), Method::new_modelled("rescanblockchain", "RescanBlockchain", "rescan_blockchain"), Method::new_nothing("sendfrom", "send_from"), // Deprecated Method::new_modelled("sendmany", "SendMany", "send_many"), Method::new_modelled("sendtoaddress", "SendToAddress", "send_to_address"), Method::new_nothing("setaccount", "set_account"), // Deprecated - Method::new_nothing("sethdseed", "set_hd_seed"), - Method::new_bool("settxfee", "set_tx_fee"), + Method::new_no_model("sethdseed", "SetHdSeed", "set_hd_seed"), + Method::new_no_model("settxfee", "SetTxFee", "set_tx_fee"), Method::new_modelled("signmessage", "SignMessage", "sign_message"), Method::new_modelled( "signrawtransactionwithwallet", @@ -151,14 +151,15 @@ pub const METHODS: &[Method] = &[ "sign_raw_transaction_with_wallet", ), Method::new_nothing("unloadwallet", "unload_wallet"), + Method::new_nothing("importwallet", "import_wallet"), Method::new_modelled( "walletcreatefundedpsbt", "WalletCreateFundedPsbt", "wallet_create_funded_psbt", ), Method::new_nothing("walletlock", "wallet_lock"), - Method::new_nothing("walletpassphrase", "wallet_passphrase"), - Method::new_nothing("walletpassphrasechange", "wallet_passphrase_change"), + Method::new_no_model("walletpassphrase", "WalletPassPhrase", "wallet_passphrase"), + Method::new_no_model("walletpassphrasechange", "WalletPassPhraseChange", "wallet_passphrase_change"), Method::new_modelled("walletprocesspsbt", "WalletProcessPsbt", "wallet_process_psbt"), // zmq Method::new_no_model("getzmqnotifications", "GetZmqNotifications", "get_zmq_notifications"), diff --git a/verify/src/method/v18.rs b/verify/src/method/v18.rs index 0aa49696..6d5a4a8f 100644 --- a/verify/src/method/v18.rs +++ b/verify/src/method/v18.rs @@ -29,10 +29,10 @@ pub const METHODS: &[Method] = &[ Method::new_string("gettxoutproof", "get_tx_out_proof"), Method::new_modelled("gettxoutsetinfo", "GetTxOutSetInfo", "get_tx_out_set_info"), Method::new_nothing("preciousblock", "precious_block"), - Method::new_numeric("pruneblockchain", "prune_blockchain"), - Method::new_nothing("savemempool", "save_mempool"), + Method::new_no_model("pruneblockchain", "PruneBlockchain", "prune_blockchain"), + Method::new_no_model("savemempool", "SaveMempool", "save_mempool"), Method::new_modelled("scantxoutset", "ScanTxOutSet", "scan_tx_out_set"), - Method::new_bool("verifychain", "verify_chain"), + Method::new_no_model("verifychain", "VerifyChain", "verify_chain"), Method::new_modelled("verifytxoutproof", "VerifyTxOutProof", "verify_tx_out_proof"), Method::new_no_model("getrpcinfo", "GetRpcInfo", "get_rpc_info"), Method::new_no_model("getmemoryinfo", "GetMemoryInfoStats", "get_memory_info"), @@ -48,19 +48,19 @@ pub const METHODS: &[Method] = &[ Method::new_bool("prioritisetransaction", "prioritise_transaction"), Method::new_nothing("submitblock", "submit_block"), Method::new_nothing("submitheader", "submit_header"), - Method::new_nothing("addnode", "add_node"), - Method::new_nothing("clearbanned", "clear_banned"), - Method::new_nothing("disconnectnode", "disconnect_node"), + Method::new_no_model("addnode", "AddNode", "add_node"), + Method::new_no_model("clearbanned", "ClearBanned", "clear_banned"), + Method::new_no_model("disconnectnode", "DisconnectNode", "disconnect_node"), Method::new_no_model("getaddednodeinfo", "GetAddedNodeInfo", "get_added_node_info"), - Method::new_numeric("getconnectioncount", "get_connection_count"), + Method::new_no_model("getconnectioncount", "GetConnectionCount", "get_connection_count"), Method::new_no_model("getnettotals", "GetNetTotals", "get_net_totals"), Method::new_modelled("getnetworkinfo", "GetNetworkInfo", "get_network_info"), Method::new_no_model("getnodeaddresses", "GetNodeAddresses", "get_node_addresses"), Method::new_no_model("getpeerinfo", "GetPeerInfo", "get_peer_info"), - Method::new_string("listbanned", "list_banned"), // v17 docs seem wrong, says no return. - Method::new_nothing("ping", "ping"), - Method::new_nothing("setban", "set_ban"), - Method::new_nothing("setnetworkactive", "set_network_active"), + Method::new_no_model("listbanned", "ListBanned", "list_banned"), // v17 docs seem wrong, says no return. + Method::new_no_model("ping", "Ping", "ping"), + Method::new_no_model("setban", "SetBan", "set_ban"), + Method::new_no_model("setnetworkactive", "SetNetworkActive", "set_network_active"), Method::new_modelled("analyzepsbt", "AnalyzePsbt", "analyze_psbt"), Method::new_nothing("combinepsbt", "combine_psbt"), Method::new_nothing("combinerawtransaction", "combine_raw_transaction"), @@ -85,15 +85,15 @@ pub const METHODS: &[Method] = &[ Method::new_string("signmessagewithprivkey", "sign_message_with_priv_key"), Method::new_modelled("validateaddress", "ValidateAddress", "validate_address"), Method::new_bool("verifymessage", "verify_message"), - Method::new_nothing("abandontransaction", "abandon_transaction"), - Method::new_nothing("abortrescan", "abort_rescan"), + Method::new_no_model("abandontransaction", "AbandonTransaction", "abandon_transaction"), + Method::new_no_model("abortrescan", "AbortRescan", "abort_rescan"), Method::new_modelled("addmultisigaddress", "AddMultisigAddress", "add_multisig_address"), - Method::new_nothing("backupwallet", "backup_wallet"), + Method::new_no_model("backupwallet", "BackupWallet", "backup_wallet"), Method::new_modelled("bumpfee", "BumpFee", "bump_fee"), Method::new_modelled("createwallet", "CreateWallet", "create_wallet"), Method::new_modelled("dumpprivkey", "DumpPrivKey", "dump_priv_key"), Method::new_modelled("dumpwallet", "DumpWallet", "dump_wallet"), - Method::new_nothing("encryptwallet", "encrypt_wallet"), + Method::new_no_model("encryptwallet", "EncryptWallet", "encrypt_wallet"), Method::new_modelled("getaddressesbylabel", "GetAddressesByLabel", "get_addresses_by_label"), Method::new_modelled("getaddressinfo", "GetAddressInfo", "get_address_info"), Method::new_modelled("getbalance", "GetBalance", "get_balance"), @@ -109,12 +109,12 @@ pub const METHODS: &[Method] = &[ ), Method::new_modelled("getwalletinfo", "GetWalletInfo", "get_wallet_info"), Method::new_nothing("importaddress", "import_addressss"), - Method::new_nothing("importmulti", "import_multi"), - Method::new_nothing("importprivkey", "import_priv_key"), - Method::new_nothing("importprunedfunds", "import_pruned_funds"), - Method::new_nothing("importpubkey", "import_pubkey"), - Method::new_nothing("importwallet", "import_walet"), - Method::new_nothing("keypoolrefill", "keypool_refill"), + Method::new_modelled("importmulti", "ImportMulti", "import_multi"), + Method::new_no_model("importprivkey", "ImportPrivKey", "import_priv_key"), + Method::new_no_model("importprunedfunds", "ImportPrunedFunds", "import_pruned_funds"), + Method::new_no_model("importpubkey", "ImportPubKey", "import_pubkey"), + Method::new_no_model("importwallet", "ImportWallet", "import_walet"), + Method::new_no_model("keypoolrefill", "KeypoolRefill", "keypool_refill"), Method::new_modelled("listaddressgroupings", "ListAddressGroupings", "list_address_groupings"), Method::new_modelled("listlabels", "ListLabels", "list_labels"), Method::new_modelled("listlockunspent", "ListLockUnspent", "list_lock_unspent"), @@ -130,14 +130,14 @@ pub const METHODS: &[Method] = &[ Method::new_no_model("listwalletdir", "ListWalletDir", "list_wallet_dir"), Method::new_modelled("listwallets", "ListWallets", "list_wallets"), Method::new_modelled("loadwallet", "LoadWallet", "load_wallet"), - Method::new_bool("lockunspent", "lock_unspent"), - Method::new_nothing("removeprunedfunds", "remove_pruned_funds"), + Method::new_no_model("lockunspent", "LockUnspent", "lock_unspent"), + Method::new_no_model("removeprunedfunds", "RemovePrunedFunds", "remove_pruned_funds"), Method::new_modelled("rescanblockchain", "RescanBlockchain", "rescan_blockchain"), Method::new_modelled("sendmany", "SendMany", "send_many"), Method::new_modelled("sendtoaddress", "SendToAddress", "send_to_address"), - Method::new_nothing("sethdseed", "set_hd_seed"), + Method::new_no_model("sethdseed", "SetHdSeed", "set_hd_seed"), Method::new_nothing("setlabel", "set_label"), - Method::new_bool("settxfee", "set_tx_fee"), + Method::new_no_model("settxfee", "SetTxFee", "set_tx_fee"), Method::new_modelled("signmessage", "SignMessage", "sign_message"), Method::new_modelled( "signrawtransactionwithwallet", @@ -151,8 +151,9 @@ pub const METHODS: &[Method] = &[ "wallet_create_funded_psbt", ), Method::new_nothing("walletlock", "wallet_lock"), - Method::new_nothing("walletpassphrase", "wallet_passphrase"), - Method::new_nothing("walletpassphrasechange", "wallet_passphrase_change"), + Method::new_nothing("importwallet", "import_wallet"), + Method::new_no_model("walletpassphrase", "WalletPassPhrase", "wallet_passphrase"), + Method::new_no_model("walletpassphrasechange", "WalletPassPhraseChange", "wallet_passphrase_change"), Method::new_modelled("walletprocesspsbt", "WalletProcessPsbt", "wallet_process_psbt"), Method::new_no_model("getzmqnotifications", "GetZmqNotifications", "get_zmq_notifications"), ]; diff --git a/verify/src/method/v19.rs b/verify/src/method/v19.rs index 6cb27897..c6226a1b 100644 --- a/verify/src/method/v19.rs +++ b/verify/src/method/v19.rs @@ -30,10 +30,10 @@ pub const METHODS: &[Method] = &[ Method::new_string("gettxoutproof", "get_tx_out_proof"), Method::new_modelled("gettxoutsetinfo", "GetTxOutSetInfo", "get_tx_out_set_info"), Method::new_nothing("preciousblock", "precious_block"), - Method::new_numeric("pruneblockchain", "prune_blockchain"), - Method::new_nothing("savemempool", "save_mempool"), + Method::new_no_model("pruneblockchain", "PruneBlockchain", "prune_blockchain"), + Method::new_no_model("savemempool", "SaveMempool", "save_mempool"), Method::new_modelled("scantxoutset", "ScanTxOutSet", "scan_tx_out_set"), - Method::new_bool("verifychain", "verify_chain"), + Method::new_no_model("verifychain", "VerifyChain", "verify_chain"), Method::new_modelled("verifytxoutproof", "VerifyTxOutProof", "verify_tx_out_proof"), Method::new_no_model("getrpcinfo", "GetRpcInfo", "get_rpc_info"), Method::new_no_model("getmemoryinfo", "GetMemoryInfoStats", "get_memory_info"), @@ -48,19 +48,19 @@ pub const METHODS: &[Method] = &[ Method::new_bool("prioritisetransaction", "prioritise_transaction"), Method::new_nothing("submitblock", "submit_block"), Method::new_nothing("submitheader", "submit_header"), - Method::new_nothing("addnode", "add_node"), - Method::new_nothing("clearbanned", "clear_banned"), - Method::new_nothing("disconnectnode", "disconnect_node"), + Method::new_no_model("addnode", "AddNode", "add_node"), + Method::new_no_model("clearbanned", "ClearBanned", "clear_banned"), + Method::new_no_model("disconnectnode", "DisconnectNode", "disconnect_node"), Method::new_no_model("getaddednodeinfo", "GetAddedNodeInfo", "get_added_node_info"), - Method::new_numeric("getconnectioncount", "get_connection_count"), + Method::new_no_model("getconnectioncount", "GetConnectionCount", "get_connection_count"), Method::new_no_model("getnettotals", "GetNetTotals", "get_net_totals"), Method::new_modelled("getnetworkinfo", "GetNetworkInfo", "get_network_info"), Method::new_no_model("getnodeaddresses", "GetNodeAddresses", "get_node_addresses"), Method::new_no_model("getpeerinfo", "GetPeerInfo", "get_peer_info"), - Method::new_string("listbanned", "list_banned"), // v17 docs seem wrong, says no return. - Method::new_nothing("ping", "ping"), - Method::new_nothing("setban", "set_ban"), - Method::new_nothing("setnetworkactive", "set_network_active"), + Method::new_no_model("listbanned", "ListBanned", "list_banned"), // v17 docs seem wrong, says no return. + Method::new_no_model("ping", "Ping", "ping"), + Method::new_no_model("setban", "SetBan", "set_ban"), + Method::new_no_model("setnetworkactive", "SetNetworkActive", "set_network_active"), Method::new_modelled("analyzepsbt", "AnalyzePsbt", "analyze_psbt"), Method::new_nothing("combinepsbt", "combine_psbt"), Method::new_nothing("combinerawtransaction", "combine_raw_transaction"), @@ -85,15 +85,15 @@ pub const METHODS: &[Method] = &[ Method::new_string("signmessagewithprivkey", "sign_message_with_priv_key"), Method::new_modelled("validateaddress", "ValidateAddress", "validate_address"), Method::new_bool("verifymessage", "verify_message"), - Method::new_nothing("abandontransaction", "abandon_transaction"), - Method::new_nothing("abortrescan", "abort_rescan"), + Method::new_no_model("abandontransaction", "AbandonTransaction", "abandon_transaction"), + Method::new_no_model("abortrescan", "AbortRescan", "abort_rescan"), Method::new_modelled("addmultisigaddress", "AddMultisigAddress", "add_multisig_address"), - Method::new_nothing("backupwallet", "backup_wallet"), + Method::new_no_model("backupwallet", "BackupWallet", "backup_wallet"), Method::new_modelled("bumpfee", "BumpFee", "bump_fee"), Method::new_modelled("createwallet", "CreateWallet", "create_wallet"), Method::new_modelled("dumpprivkey", "DumpPrivKey", "dump_priv_key"), Method::new_modelled("dumpwallet", "DumpWallet", "dump_wallet"), - Method::new_nothing("encryptwallet", "encrypt_wallet"), + Method::new_no_model("encryptwallet", "EncryptWallet", "encrypt_wallet"), Method::new_modelled("getaddressesbylabel", "GetAddressesByLabel", "get_addresses_by_label"), Method::new_modelled("getaddressinfo", "GetAddressInfo", "get_address_info"), Method::new_modelled("getbalance", "GetBalance", "get_balance"), @@ -110,12 +110,12 @@ pub const METHODS: &[Method] = &[ ), Method::new_modelled("getwalletinfo", "GetWalletInfo", "get_wallet_info"), Method::new_nothing("importaddress", "import_addressss"), - Method::new_nothing("importmulti", "import_multi"), - Method::new_nothing("importprivkey", "import_priv_key"), - Method::new_nothing("importprunedfunds", "import_pruned_funds"), - Method::new_nothing("importpubkey", "import_pubkey"), - Method::new_nothing("importwallet", "import_walet"), - Method::new_nothing("keypoolrefill", "keypool_refill"), + Method::new_modelled("importmulti", "ImportMulti", "import_multi"), + Method::new_no_model("importprivkey", "ImportPrivKey", "import_priv_key"), + Method::new_no_model("importprunedfunds", "ImportPrunedFunds", "import_pruned_funds"), + Method::new_no_model("importpubkey", "ImportPubKey", "import_pubkey"), + Method::new_no_model("importwallet", "ImportWallet", "import_walet"), + Method::new_no_model("keypoolrefill", "KeypoolRefill", "keypool_refill"), Method::new_modelled("listaddressgroupings", "ListAddressGroupings", "list_address_groupings"), Method::new_modelled("listlabels", "ListLabels", "list_labels"), Method::new_modelled("listlockunspent", "ListLockUnspent", "list_lock_unspent"), @@ -131,14 +131,14 @@ pub const METHODS: &[Method] = &[ Method::new_no_model("listwalletdir", "ListWalletDir", "list_wallet_dir"), Method::new_modelled("listwallets", "ListWallets", "list_wallets"), Method::new_modelled("loadwallet", "LoadWallet", "load_wallet"), - Method::new_bool("lockunspent", "lock_unspent"), - Method::new_nothing("removeprunedfunds", "remove_pruned_funds"), + Method::new_no_model("lockunspent", "LockUnspent", "lock_unspent"), + Method::new_no_model("removeprunedfunds", "RemovePrunedFunds", "remove_pruned_funds"), Method::new_modelled("rescanblockchain", "RescanBlockchain", "rescan_blockchain"), Method::new_modelled("sendmany", "SendMany", "send_many"), Method::new_modelled("sendtoaddress", "SendToAddress", "send_to_address"), - Method::new_nothing("sethdseed", "set_hd_seed"), + Method::new_no_model("sethdseed", "SetHdSeed", "set_hd_seed"), Method::new_nothing("setlabel", "set_label"), - Method::new_bool("settxfee", "set_tx_fee"), + Method::new_no_model("settxfee", "SetTxFee", "set_tx_fee"), Method::new_modelled("setwalletflag", "SetWalletFlag", "set_wallet_flag"), Method::new_modelled("signmessage", "SignMessage", "sign_message"), Method::new_modelled( @@ -152,9 +152,10 @@ pub const METHODS: &[Method] = &[ "WalletCreateFundedPsbt", "wallet_create_funded_psbt", ), + Method::new_nothing("importwallet", "import_wallet"), Method::new_nothing("walletlock", "wallet_lock"), - Method::new_nothing("walletpassphrase", "wallet_passphrase"), - Method::new_nothing("walletpassphrasechange", "wallet_passphrase_change"), + Method::new_no_model("walletpassphrase", "WalletPassPhrase", "wallet_passphrase"), + Method::new_no_model("walletpassphrasechange", "WalletPassPhraseChange", "wallet_passphrase_change"), Method::new_modelled("walletprocesspsbt", "WalletProcessPsbt", "wallet_process_psbt"), Method::new_no_model("getzmqnotifications", "GetZmqNotifications", "get_zmq_notifications"), ]; diff --git a/verify/src/method/v20.rs b/verify/src/method/v20.rs index 0783ead3..220828c3 100644 --- a/verify/src/method/v20.rs +++ b/verify/src/method/v20.rs @@ -30,10 +30,10 @@ pub const METHODS: &[Method] = &[ Method::new_string("gettxoutproof", "get_tx_out_proof"), Method::new_modelled("gettxoutsetinfo", "GetTxOutSetInfo", "get_tx_out_set_info"), Method::new_nothing("preciousblock", "precious_block"), - Method::new_numeric("pruneblockchain", "prune_blockchain"), - Method::new_nothing("savemempool", "save_mempool"), + Method::new_no_model("pruneblockchain", "PruneBlockchain", "prune_blockchain"), + Method::new_no_model("savemempool", "SaveMempool", "save_mempool"), Method::new_modelled("scantxoutset", "ScanTxOutSet", "scan_tx_out_set"), - Method::new_bool("verifychain", "verify_chain"), + Method::new_no_model("verifychain", "VerifyChain", "verify_chain"), Method::new_modelled("verifytxoutproof", "VerifyTxOutProof", "verify_tx_out_proof"), Method::new_no_model("getrpcinfo", "GetRpcInfo", "get_rpc_info"), Method::new_no_model("getmemoryinfo", "GetMemoryInfoStats", "get_memory_info"), @@ -49,19 +49,19 @@ pub const METHODS: &[Method] = &[ Method::new_bool("prioritisetransaction", "prioritise_transaction"), Method::new_nothing("submitblock", "submit_block"), Method::new_nothing("submitheader", "submit_header"), - Method::new_nothing("addnode", "add_node"), - Method::new_nothing("clearbanned", "clear_banned"), - Method::new_nothing("disconnectnode", "disconnect_node"), + Method::new_no_model("addnode", "AddNode", "add_node"), + Method::new_no_model("clearbanned", "ClearBanned", "clear_banned"), + Method::new_no_model("disconnectnode", "DisconnectNode", "disconnect_node"), Method::new_no_model("getaddednodeinfo", "GetAddedNodeInfo", "get_added_node_info"), - Method::new_numeric("getconnectioncount", "get_connection_count"), + Method::new_no_model("getconnectioncount", "GetConnectionCount", "get_connection_count"), Method::new_no_model("getnettotals", "GetNetTotals", "get_net_totals"), Method::new_modelled("getnetworkinfo", "GetNetworkInfo", "get_network_info"), Method::new_no_model("getnodeaddresses", "GetNodeAddresses", "get_node_addresses"), Method::new_no_model("getpeerinfo", "GetPeerInfo", "get_peer_info"), - Method::new_string("listbanned", "list_banned"), // v17 docs seem wrong, says no return. - Method::new_nothing("ping", "ping"), - Method::new_nothing("setban", "set_ban"), - Method::new_nothing("setnetworkactive", "set_network_active"), + Method::new_no_model("listbanned", "ListBanned", "list_banned"), // v17 docs seem wrong, says no return. + Method::new_no_model("ping", "Ping", "ping"), + Method::new_no_model("setban", "SetBan", "set_ban"), + Method::new_no_model("setnetworkactive", "SetNetworkActive", "set_network_active"), Method::new_modelled("analyzepsbt", "AnalyzePsbt", "analyze_psbt"), Method::new_nothing("combinepsbt", "combine_psbt"), Method::new_nothing("combinerawtransaction", "combine_raw_transaction"), @@ -86,15 +86,15 @@ pub const METHODS: &[Method] = &[ Method::new_string("signmessagewithprivkey", "sign_message_with_priv_key"), Method::new_modelled("validateaddress", "ValidateAddress", "validate_address"), Method::new_bool("verifymessage", "verify_message"), - Method::new_nothing("abandontransaction", "abandon_transaction"), - Method::new_nothing("abortrescan", "abort_rescan"), + Method::new_no_model("abandontransaction", "AbandonTransaction", "abandon_transaction"), + Method::new_no_model("abortrescan", "AbortRescan", "abort_rescan"), Method::new_modelled("addmultisigaddress", "AddMultisigAddress", "add_multisig_address"), - Method::new_nothing("backupwallet", "backup_wallet"), + Method::new_no_model("backupwallet", "BackupWallet", "backup_wallet"), Method::new_modelled("bumpfee", "BumpFee", "bump_fee"), Method::new_modelled("createwallet", "CreateWallet", "create_wallet"), Method::new_modelled("dumpprivkey", "DumpPrivKey", "dump_priv_key"), Method::new_modelled("dumpwallet", "DumpWallet", "dump_wallet"), - Method::new_nothing("encryptwallet", "encrypt_wallet"), + Method::new_no_model("encryptwallet", "EncryptWallet", "encrypt_wallet"), Method::new_modelled("getaddressesbylabel", "GetAddressesByLabel", "get_addresses_by_label"), Method::new_modelled("getaddressinfo", "GetAddressInfo", "get_address_info"), Method::new_modelled("getbalance", "GetBalance", "get_balance"), @@ -111,12 +111,12 @@ pub const METHODS: &[Method] = &[ ), Method::new_modelled("getwalletinfo", "GetWalletInfo", "get_wallet_info"), Method::new_nothing("importaddress", "import_addressss"), - Method::new_nothing("importmulti", "import_multi"), - Method::new_nothing("importprivkey", "import_priv_key"), - Method::new_nothing("importprunedfunds", "import_pruned_funds"), - Method::new_nothing("importpubkey", "import_pubkey"), - Method::new_nothing("importwallet", "import_walet"), - Method::new_nothing("keypoolrefill", "keypool_refill"), + Method::new_modelled("importmulti", "ImportMulti", "import_multi"), + Method::new_no_model("importprivkey", "ImportPrivKey", "import_priv_key"), + Method::new_no_model("importprunedfunds", "ImportPrunedFunds", "import_pruned_funds"), + Method::new_no_model("importpubkey", "ImportPubKey", "import_pubkey"), + Method::new_no_model("importwallet", "ImportWallet", "import_walet"), + Method::new_no_model("keypoolrefill", "KeypoolRefill", "keypool_refill"), Method::new_modelled("listaddressgroupings", "ListAddressGroupings", "list_address_groupings"), Method::new_modelled("listlabels", "ListLabels", "list_labels"), Method::new_modelled("listlockunspent", "ListLockUnspent", "list_lock_unspent"), @@ -132,14 +132,14 @@ pub const METHODS: &[Method] = &[ Method::new_no_model("listwalletdir", "ListWalletDir", "list_wallet_dir"), Method::new_modelled("listwallets", "ListWallets", "list_wallets"), Method::new_modelled("loadwallet", "LoadWallet", "load_wallet"), - Method::new_bool("lockunspent", "lock_unspent"), - Method::new_nothing("removeprunedfunds", "remove_pruned_funds"), + Method::new_no_model("lockunspent", "LockUnspent", "lock_unspent"), + Method::new_no_model("removeprunedfunds", "RemovePrunedFunds", "remove_pruned_funds"), Method::new_modelled("rescanblockchain", "RescanBlockchain", "rescan_blockchain"), Method::new_modelled("sendmany", "SendMany", "send_many"), Method::new_modelled("sendtoaddress", "SendToAddress", "send_to_address"), - Method::new_nothing("sethdseed", "set_hd_seed"), + Method::new_no_model("sethdseed", "SetHdSeed", "set_hd_seed"), Method::new_nothing("setlabel", "set_label"), - Method::new_bool("settxfee", "set_tx_fee"), + Method::new_no_model("settxfee", "SetTxFee", "set_tx_fee"), Method::new_modelled("setwalletflag", "SetWalletFlag", "set_wallet_flag"), Method::new_modelled("signmessage", "SignMessage", "sign_message"), Method::new_modelled( @@ -153,9 +153,10 @@ pub const METHODS: &[Method] = &[ "WalletCreateFundedPsbt", "wallet_create_funded_psbt", ), + Method::new_nothing("importwallet", "import_wallet"), Method::new_nothing("walletlock", "wallet_lock"), - Method::new_nothing("walletpassphrase", "wallet_passphrase"), - Method::new_nothing("walletpassphrasechange", "wallet_passphrase_change"), + Method::new_no_model("walletpassphrase", "WalletPassPhrase", "wallet_passphrase"), + Method::new_no_model("walletpassphrasechange", "WalletPassPhraseChange", "wallet_passphrase_change"), Method::new_modelled("walletprocesspsbt", "WalletProcessPsbt", "wallet_process_psbt"), Method::new_no_model("getzmqnotifications", "GetZmqNotifications", "get_zmq_notifications"), ]; diff --git a/verify/src/method/v21.rs b/verify/src/method/v21.rs index e0fd0601..0c4ee22b 100644 --- a/verify/src/method/v21.rs +++ b/verify/src/method/v21.rs @@ -30,10 +30,10 @@ pub const METHODS: &[Method] = &[ Method::new_string("gettxoutproof", "get_tx_out_proof"), Method::new_modelled("gettxoutsetinfo", "GetTxOutSetInfo", "get_tx_out_set_info"), Method::new_nothing("preciousblock", "precious_block"), - Method::new_numeric("pruneblockchain", "prune_blockchain"), - Method::new_nothing("savemempool", "save_mempool"), + Method::new_no_model("pruneblockchain", "PruneBlockchain", "prune_blockchain"), + Method::new_no_model("savemempool", "SaveMempool", "save_mempool"), Method::new_modelled("scantxoutset", "ScanTxOutSet", "scan_tx_out_set"), - Method::new_bool("verifychain", "verify_chain"), + Method::new_no_model("verifychain", "VerifyChain", "verify_chain"), Method::new_modelled("verifytxoutproof", "VerifyTxOutProof", "verify_tx_out_proof"), Method::new_no_model("getrpcinfo", "GetRpcInfo", "get_rpc_info"), Method::new_no_model("getmemoryinfo", "GetMemoryInfoStats", "get_memory_info"), @@ -50,19 +50,19 @@ pub const METHODS: &[Method] = &[ Method::new_bool("prioritisetransaction", "prioritise_transaction"), Method::new_nothing("submitblock", "submit_block"), Method::new_nothing("submitheader", "submit_header"), - Method::new_nothing("addnode", "add_node"), - Method::new_nothing("clearbanned", "clear_banned"), - Method::new_nothing("disconnectnode", "disconnect_node"), + Method::new_no_model("addnode", "AddNode", "add_node"), + Method::new_no_model("clearbanned", "ClearBanned", "clear_banned"), + Method::new_no_model("disconnectnode", "DisconnectNode", "disconnect_node"), Method::new_no_model("getaddednodeinfo", "GetAddedNodeInfo", "get_added_node_info"), - Method::new_numeric("getconnectioncount", "get_connection_count"), + Method::new_no_model("getconnectioncount", "GetConnectionCount", "get_connection_count"), Method::new_no_model("getnettotals", "GetNetTotals", "get_net_totals"), Method::new_modelled("getnetworkinfo", "GetNetworkInfo", "get_network_info"), Method::new_no_model("getnodeaddresses", "GetNodeAddresses", "get_node_addresses"), Method::new_no_model("getpeerinfo", "GetPeerInfo", "get_peer_info"), - Method::new_string("listbanned", "list_banned"), // v17 docs seem wrong, says no return. - Method::new_nothing("ping", "ping"), - Method::new_nothing("setban", "set_ban"), - Method::new_nothing("setnetworkactive", "set_network_active"), + Method::new_no_model("listbanned", "ListBanned", "list_banned"), // v17 docs seem wrong, says no return. + Method::new_no_model("ping", "Ping", "ping"), + Method::new_no_model("setban", "SetBan", "set_ban"), + Method::new_no_model("setnetworkactive", "SetNetworkActive", "set_network_active"), Method::new_modelled("analyzepsbt", "AnalyzePsbt", "analyze_psbt"), Method::new_nothing("combinepsbt", "combine_psbt"), Method::new_nothing("combinerawtransaction", "combine_raw_transaction"), @@ -88,15 +88,15 @@ pub const METHODS: &[Method] = &[ Method::new_string("signmessagewithprivkey", "sign_message_with_priv_key"), Method::new_modelled("validateaddress", "ValidateAddress", "validate_address"), Method::new_bool("verifymessage", "verify_message"), - Method::new_nothing("abandontransaction", "abandon_transaction"), - Method::new_nothing("abortrescan", "abort_rescan"), + Method::new_no_model("abandontransaction", "AbandonTransaction", "abandon_transaction"), + Method::new_no_model("abortrescan", "AbortRescan", "abort_rescan"), Method::new_modelled("addmultisigaddress", "AddMultisigAddress", "add_multisig_address"), - Method::new_nothing("backupwallet", "backup_wallet"), + Method::new_no_model("backupwallet", "BackupWallet", "backup_wallet"), Method::new_modelled("bumpfee", "BumpFee", "bump_fee"), Method::new_modelled("createwallet", "CreateWallet", "create_wallet"), Method::new_modelled("dumpprivkey", "DumpPrivKey", "dump_priv_key"), Method::new_modelled("dumpwallet", "DumpWallet", "dump_wallet"), - Method::new_nothing("encryptwallet", "encrypt_wallet"), + Method::new_no_model("encryptwallet", "EncryptWallet", "encrypt_wallet"), Method::new_modelled("getaddressesbylabel", "GetAddressesByLabel", "get_addresses_by_label"), Method::new_modelled("getaddressinfo", "GetAddressInfo", "get_address_info"), Method::new_modelled("getbalance", "GetBalance", "get_balance"), @@ -114,12 +114,12 @@ pub const METHODS: &[Method] = &[ Method::new_modelled("getwalletinfo", "GetWalletInfo", "get_wallet_info"), Method::new_nothing("importaddress", "import_address"), Method::new_no_model("importdescriptors", "ImportDescriptors", "import_descriptors"), - Method::new_nothing("importmulti", "import_multi"), - Method::new_nothing("importprivkey", "import_priv_key"), - Method::new_nothing("importprunedfunds", "import_pruned_funds"), - Method::new_nothing("importpubkey", "import_pubkey"), - Method::new_nothing("importwallet", "import_walet"), - Method::new_nothing("keypoolrefill", "keypool_refill"), + Method::new_modelled("importmulti", "ImportMulti", "import_multi"), + Method::new_no_model("importprivkey", "ImportPrivKey", "import_priv_key"), + Method::new_no_model("importprunedfunds", "ImportPrunedFunds", "import_pruned_funds"), + Method::new_no_model("importpubkey", "ImportPubKey", "import_pubkey"), + Method::new_no_model("importwallet", "ImportWallet", "import_walet"), + Method::new_no_model("keypoolrefill", "KeypoolRefill", "keypool_refill"), Method::new_modelled("listaddressgroupings", "ListAddressGroupings", "list_address_groupings"), Method::new_modelled("listlabels", "ListLabels", "list_labels"), Method::new_modelled("listlockunspent", "ListLockUnspent", "list_lock_unspent"), @@ -136,15 +136,15 @@ pub const METHODS: &[Method] = &[ Method::new_no_model("listwalletdir", "ListWalletDir", "list_wallet_dir"), Method::new_modelled("listwallets", "ListWallets", "list_wallets"), Method::new_modelled("loadwallet", "LoadWallet", "load_wallet"), - Method::new_bool("lockunspent", "lock_unspent"), - Method::new_nothing("removeprunedfunds", "remove_pruned_funds"), + Method::new_no_model("lockunspent", "LockUnspent", "lock_unspent"), + Method::new_no_model("removeprunedfunds", "RemovePrunedFunds", "remove_pruned_funds"), Method::new_modelled("rescanblockchain", "RescanBlockchain", "rescan_blockchain"), Method::new_modelled("send", "Send", "send"), Method::new_modelled("sendmany", "SendMany", "send_many"), Method::new_modelled("sendtoaddress", "SendToAddress", "send_to_address"), - Method::new_nothing("sethdseed", "set_hd_seed"), + Method::new_no_model("sethdseed", "SetHdSeed", "set_hd_seed"), Method::new_nothing("setlabel", "set_label"), - Method::new_bool("settxfee", "set_tx_fee"), + Method::new_no_model("settxfee", "SetTxFee", "set_tx_fee"), Method::new_modelled("setwalletflag", "SetWalletFlag", "set_wallet_flag"), Method::new_modelled("signmessage", "SignMessage", "sign_message"), Method::new_modelled( @@ -152,6 +152,7 @@ pub const METHODS: &[Method] = &[ "SignRawTransactionWithWallet", "sign_raw_transaction_with_wallet", ), + Method::new_nothing("importwallet", "import_wallet"), Method::new_nothing("unloadwallet", "unload_wallet"), Method::new_no_model("upgradewallet", "UpgradeWalled", "upgrade_wallet"), Method::new_modelled( @@ -160,8 +161,8 @@ pub const METHODS: &[Method] = &[ "wallet_create_funded_psbt", ), Method::new_nothing("walletlock", "wallet_lock"), - Method::new_nothing("walletpassphrase", "wallet_passphrase"), - Method::new_nothing("walletpassphrasechange", "wallet_passphrase_change"), + Method::new_no_model("walletpassphrase", "WalletPassPhrase", "wallet_passphrase"), + Method::new_no_model("walletpassphrasechange", "WalletPassPhraseChange", "wallet_passphrase_change"), Method::new_modelled("walletprocesspsbt", "WalletProcessPsbt", "wallet_process_psbt"), Method::new_no_model("getzmqnotifications", "GetZmqNotifications", "get_zmq_notifications"), ]; diff --git a/verify/src/method/v22.rs b/verify/src/method/v22.rs index 207599a4..b1657477 100644 --- a/verify/src/method/v22.rs +++ b/verify/src/method/v22.rs @@ -30,10 +30,10 @@ pub const METHODS: &[Method] = &[ Method::new_string("gettxoutproof", "get_tx_out_proof"), Method::new_modelled("gettxoutsetinfo", "GetTxOutSetInfo", "get_tx_out_set_info"), Method::new_nothing("preciousblock", "precious_block"), - Method::new_numeric("pruneblockchain", "prune_blockchain"), - Method::new_nothing("savemempool", "save_mempool"), + Method::new_no_model("pruneblockchain", "PruneBlockchain", "prune_blockchain"), + Method::new_no_model("savemempool", "SaveMempool", "save_mempool"), Method::new_modelled("scantxoutset", "ScanTxOutSet", "scan_tx_out_set"), - Method::new_bool("verifychain", "verify_chain"), + Method::new_no_model("verifychain", "VerifyChain", "verify_chain"), Method::new_modelled("verifytxoutproof", "VerifyTxOutProof", "verify_tx_out_proof"), Method::new_no_model("getrpcinfo", "GetRpcInfo", "get_rpc_info"), Method::new_no_model("getmemoryinfo", "GetMemoryInfoStats", "get_memory_info"), @@ -50,19 +50,19 @@ pub const METHODS: &[Method] = &[ Method::new_bool("prioritisetransaction", "prioritise_transaction"), Method::new_nothing("submitblock", "submit_block"), Method::new_nothing("submitheader", "submit_header"), - Method::new_nothing("addnode", "add_node"), - Method::new_nothing("clearbanned", "clear_banned"), - Method::new_nothing("disconnectnode", "disconnect_node"), + Method::new_no_model("addnode", "AddNode", "add_node"), + Method::new_no_model("clearbanned", "ClearBanned", "clear_banned"), + Method::new_no_model("disconnectnode", "DisconnectNode", "disconnect_node"), Method::new_no_model("getaddednodeinfo", "GetAddedNodeInfo", "get_added_node_info"), - Method::new_numeric("getconnectioncount", "get_connection_count"), + Method::new_no_model("getconnectioncount", "GetConnectionCount", "get_connection_count"), Method::new_no_model("getnettotals", "GetNetTotals", "get_net_totals"), Method::new_modelled("getnetworkinfo", "GetNetworkInfo", "get_network_info"), Method::new_no_model("getnodeaddresses", "GetNodeAddresses", "get_node_addresses"), Method::new_no_model("getpeerinfo", "GetPeerInfo", "get_peer_info"), - Method::new_string("listbanned", "list_banned"), // v17 docs seem wrong, says no return. - Method::new_nothing("ping", "ping"), - Method::new_nothing("setban", "set_ban"), - Method::new_nothing("setnetworkactive", "set_network_active"), + Method::new_no_model("listbanned", "ListBanned", "list_banned"), // v17 docs seem wrong, says no return. + Method::new_no_model("ping", "Ping", "ping"), + Method::new_no_model("setban", "SetBan", "set_ban"), + Method::new_no_model("setnetworkactive", "SetNetworkActive", "set_network_active"), Method::new_modelled("analyzepsbt", "AnalyzePsbt", "analyze_psbt"), Method::new_nothing("combinepsbt", "combine_psbt"), Method::new_nothing("combinerawtransaction", "combine_raw_transaction"), @@ -89,15 +89,15 @@ pub const METHODS: &[Method] = &[ Method::new_string("signmessagewithprivkey", "sign_message_with_priv_key"), Method::new_modelled("validateaddress", "ValidateAddress", "validate_address"), Method::new_bool("verifymessage", "verify_message"), - Method::new_nothing("abandontransaction", "abandon_transaction"), - Method::new_nothing("abortrescan", "abort_rescan"), + Method::new_no_model("abandontransaction", "AbandonTransaction", "abandon_transaction"), + Method::new_no_model("abortrescan", "AbortRescan", "abort_rescan"), Method::new_modelled("addmultisigaddress", "AddMultisigAddress", "add_multisig_address"), - Method::new_nothing("backupwallet", "backup_wallet"), + Method::new_no_model("backupwallet", "BackupWallet", "backup_wallet"), Method::new_modelled("bumpfee", "BumpFee", "bump_fee"), Method::new_modelled("createwallet", "CreateWallet", "create_wallet"), Method::new_modelled("dumpprivkey", "DumpPrivKey", "dump_priv_key"), Method::new_modelled("dumpwallet", "DumpWallet", "dump_wallet"), - Method::new_nothing("encryptwallet", "encrypt_wallet"), + Method::new_no_model("encryptwallet", "EncryptWallet", "encrypt_wallet"), Method::new_modelled("getaddressesbylabel", "GetAddressesByLabel", "get_addresses_by_label"), Method::new_modelled("getaddressinfo", "GetAddressInfo", "get_address_info"), Method::new_modelled("getbalance", "GetBalance", "get_balance"), @@ -115,12 +115,12 @@ pub const METHODS: &[Method] = &[ Method::new_modelled("getwalletinfo", "GetWalletInfo", "get_wallet_info"), Method::new_nothing("importaddress", "import_address"), Method::new_no_model("importdescriptors", "ImportDescriptors", "import_descriptors"), - Method::new_nothing("importmulti", "import_multi"), - Method::new_nothing("importprivkey", "import_priv_key"), - Method::new_nothing("importprunedfunds", "import_pruned_funds"), - Method::new_nothing("importpubkey", "import_pubkey"), - Method::new_nothing("importwallet", "import_walet"), - Method::new_nothing("keypoolrefill", "keypool_refill"), + Method::new_modelled("importmulti", "ImportMulti", "import_multi"), + Method::new_no_model("importprivkey", "ImportPrivKey", "import_priv_key"), + Method::new_no_model("importprunedfunds", "ImportPrunedFunds", "import_pruned_funds"), + Method::new_no_model("importpubkey", "ImportPubKey", "import_pubkey"), + Method::new_no_model("importwallet", "ImportWallet", "import_walet"), + Method::new_no_model("keypoolrefill", "KeypoolRefill", "keypool_refill"), Method::new_modelled("listaddressgroupings", "ListAddressGroupings", "list_address_groupings"), Method::new_modelled("listdescriptors", "ListDescriptors", "list_descriptors"), Method::new_modelled("listlabels", "ListLabels", "list_labels"), @@ -138,15 +138,15 @@ pub const METHODS: &[Method] = &[ Method::new_no_model("listwalletdir", "ListWalletDir", "list_wallet_dir"), Method::new_modelled("listwallets", "ListWallets", "list_wallets"), Method::new_modelled("loadwallet", "LoadWallet", "load_wallet"), - Method::new_bool("lockunspent", "lock_unspent"), - Method::new_nothing("removeprunedfunds", "remove_pruned_funds"), + Method::new_no_model("lockunspent", "LockUnspent", "lock_unspent"), + Method::new_no_model("removeprunedfunds", "RemovePrunedFunds", "remove_pruned_funds"), Method::new_modelled("rescanblockchain", "RescanBlockchain", "rescan_blockchain"), Method::new_modelled("send", "Send", "send"), Method::new_modelled("sendmany", "SendMany", "send_many"), Method::new_modelled("sendtoaddress", "SendToAddress", "send_to_address"), - Method::new_nothing("sethdseed", "set_hd_seed"), + Method::new_no_model("sethdseed", "SetHdSeed", "set_hd_seed"), Method::new_nothing("setlabel", "set_label"), - Method::new_bool("settxfee", "set_tx_fee"), + Method::new_no_model("settxfee", "SetTxFee", "set_tx_fee"), Method::new_modelled("setwalletflag", "SetWalletFlag", "set_wallet_flag"), Method::new_modelled("signmessage", "SignMessage", "sign_message"), Method::new_modelled( @@ -154,6 +154,7 @@ pub const METHODS: &[Method] = &[ "SignRawTransactionWithWallet", "sign_raw_transaction_with_wallet", ), + Method::new_nothing("importwallet", "import_wallet"), Method::new_nothing("unloadwallet", "unload_wallet"), Method::new_no_model("upgradewallet", "UpgradeWalled", "upgrade_wallet"), Method::new_modelled( @@ -163,8 +164,8 @@ pub const METHODS: &[Method] = &[ ), Method::new_modelled("walletdisplayaddress", "WalletDisplayAddress", "wallet_display_address"), Method::new_nothing("walletlock", "wallet_lock"), - Method::new_nothing("walletpassphrase", "wallet_passphrase"), - Method::new_nothing("walletpassphrasechange", "wallet_passphrase_change"), + Method::new_no_model("walletpassphrase", "WalletPassPhrase", "wallet_passphrase"), + Method::new_no_model("walletpassphrasechange", "WalletPassPhraseChange", "wallet_passphrase_change"), Method::new_modelled("walletprocesspsbt", "WalletProcessPsbt", "wallet_process_psbt"), Method::new_no_model("getzmqnotifications", "GetZmqNotifications", "get_zmq_notifications"), ]; diff --git a/verify/src/method/v23.rs b/verify/src/method/v23.rs index 0b2d06b4..cb46cdd9 100644 --- a/verify/src/method/v23.rs +++ b/verify/src/method/v23.rs @@ -32,10 +32,10 @@ pub const METHODS: &[Method] = &[ Method::new_string("gettxoutproof", "get_tx_out_proof"), Method::new_modelled("gettxoutsetinfo", "GetTxOutSetInfo", "get_tx_out_set_info"), Method::new_nothing("preciousblock", "precious_block"), - Method::new_numeric("pruneblockchain", "prune_blockchain"), - Method::new_nothing("savemempool", "save_mempool"), + Method::new_no_model("pruneblockchain", "PruneBlockchain", "prune_blockchain"), + Method::new_no_model("savemempool", "SaveMempool", "save_mempool"), Method::new_modelled("scantxoutset", "ScanTxOutSet", "scan_tx_out_set"), - Method::new_bool("verifychain", "verify_chain"), + Method::new_no_model("verifychain", "VerifyChain", "verify_chain"), Method::new_modelled("verifytxoutproof", "VerifyTxOutProof", "verify_tx_out_proof"), Method::new_no_model("getrpcinfo", "GetRpcInfo", "get_rpc_info"), Method::new_no_model("getmemoryinfo", "GetMemoryInfoStats", "get_memory_info"), @@ -49,19 +49,19 @@ pub const METHODS: &[Method] = &[ Method::new_bool("prioritisetransaction", "prioritise_transaction"), Method::new_nothing("submitblock", "submit_block"), Method::new_nothing("submitheader", "submit_header"), - Method::new_nothing("addnode", "add_node"), - Method::new_nothing("clearbanned", "clear_banned"), - Method::new_nothing("disconnectnode", "disconnect_node"), + Method::new_no_model("addnode", "AddNode", "add_node"), + Method::new_no_model("clearbanned", "ClearBanned", "clear_banned"), + Method::new_no_model("disconnectnode", "DisconnectNode", "disconnect_node"), Method::new_no_model("getaddednodeinfo", "GetAddedNodeInfo", "get_added_node_info"), - Method::new_numeric("getconnectioncount", "get_connection_count"), + Method::new_no_model("getconnectioncount", "GetConnectionCount", "get_connection_count"), Method::new_no_model("getnettotals", "GetNetTotals", "get_net_totals"), Method::new_modelled("getnetworkinfo", "GetNetworkInfo", "get_network_info"), Method::new_no_model("getnodeaddresses", "GetNodeAddresses", "get_node_addresses"), Method::new_no_model("getpeerinfo", "GetPeerInfo", "get_peer_info"), - Method::new_string("listbanned", "list_banned"), // v17 docs seem wrong, says no return. - Method::new_nothing("ping", "ping"), - Method::new_nothing("setban", "set_ban"), - Method::new_nothing("setnetworkactive", "set_network_active"), + Method::new_no_model("listbanned", "ListBanned", "list_banned"), // v17 docs seem wrong, says no return. + Method::new_no_model("ping", "Ping", "ping"), + Method::new_no_model("setban", "SetBan", "set_ban"), + Method::new_no_model("setnetworkactive", "SetNetworkActive", "set_network_active"), Method::new_modelled("analyzepsbt", "AnalyzePsbt", "analyze_psbt"), Method::new_nothing("combinepsbt", "combine_psbt"), Method::new_nothing("combinerawtransaction", "combine_raw_transaction"), @@ -88,15 +88,14 @@ pub const METHODS: &[Method] = &[ Method::new_string("signmessagewithprivkey", "sign_message_with_priv_key"), Method::new_modelled("validateaddress", "ValidateAddress", "validate_address"), Method::new_bool("verifymessage", "verify_message"), - Method::new_nothing("abandontransaction", "abandon_transaction"), - Method::new_nothing("abortrescan", "abort_rescan"), - Method::new_modelled("addmultisigaddress", "AddMultisigAddress", "add_multisig_address"), - Method::new_nothing("backupwallet", "backup_wallet"), + Method::new_no_model("abandontransaction", "AbandonTransaction", "abandon_transaction"), + Method::new_no_model("abortrescan", "AbortRescan", "abort_rescan"), Method::new_modelled("addmultisigaddress", "AddMultisigAddress", "add_multisig_address"), + Method::new_no_model("backupwallet", "BackupWallet", "backup_wallet"), Method::new_modelled("bumpfee", "BumpFee", "bump_fee"), Method::new_modelled("createwallet", "CreateWallet", "create_wallet"), Method::new_modelled("dumpprivkey", "DumpPrivKey", "dump_priv_key"), Method::new_modelled("dumpwallet", "DumpWallet", "dump_wallet"), - Method::new_nothing("encryptwallet", "encrypt_wallet"), + Method::new_no_model("encryptwallet", "EncryptWallet", "encrypt_wallet"), Method::new_modelled("getaddressesbylabel", "GetAddressesByLabel", "get_addresses_by_label"), Method::new_modelled("getaddressinfo", "GetAddressInfo", "get_address_info"), Method::new_modelled("getbalance", "GetBalance", "get_balance"), @@ -114,12 +113,12 @@ pub const METHODS: &[Method] = &[ Method::new_modelled("getwalletinfo", "GetWalletInfo", "get_wallet_info"), Method::new_nothing("importaddress", "import_address"), Method::new_no_model("importdescriptors", "ImportDescriptors", "import_descriptors"), - Method::new_nothing("importmulti", "import_multi"), - Method::new_nothing("importprivkey", "import_priv_key"), - Method::new_nothing("importprunedfunds", "import_pruned_funds"), - Method::new_nothing("importpubkey", "import_pubkey"), - Method::new_nothing("importwallet", "import_walet"), - Method::new_nothing("keypoolrefill", "keypool_refill"), + Method::new_modelled("importmulti", "ImportMulti", "import_multi"), + Method::new_no_model("importprivkey", "ImportPrivKey", "import_priv_key"), + Method::new_no_model("importprunedfunds", "ImportPrunedFunds", "import_pruned_funds"), + Method::new_no_model("importpubkey", "ImportPubKey", "import_pubkey"), + Method::new_no_model("importwallet", "ImportWallet", "import_walet"), + Method::new_no_model("keypoolrefill", "KeypoolRefill", "keypool_refill"), Method::new_modelled("listaddressgroupings", "ListAddressGroupings", "list_address_groupings"), Method::new_modelled("listdescriptors", "ListDescriptors", "list_descriptors"), Method::new_modelled("listlabels", "ListLabels", "list_labels"), @@ -138,16 +137,16 @@ pub const METHODS: &[Method] = &[ Method::new_no_model("listwalletdir", "ListWalletDir", "list_wallet_dir"), Method::new_modelled("listwallets", "ListWallets", "list_wallets"), Method::new_modelled("loadwallet", "LoadWallet", "load_wallet"), - Method::new_bool("lockunspent", "lock_unspent"), - Method::new_nothing("removeprunedfunds", "remove_pruned_funds"), + Method::new_no_model("lockunspent", "LockUnspent", "lock_unspent"), + Method::new_no_model("removeprunedfunds", "RemovePrunedFunds", "remove_pruned_funds"), Method::new_modelled("rescanblockchain", "RescanBlockchain", "rescan_blockchain"), Method::new_modelled("restorewallet", "RestoreWallet", "restore_wallet"), Method::new_modelled("send", "Send", "send"), Method::new_modelled("sendmany", "SendMany", "send_many"), Method::new_modelled("sendtoaddress", "SendToAddress", "send_to_address"), - Method::new_nothing("sethdseed", "set_hd_seed"), + Method::new_no_model("sethdseed", "SetHdSeed", "set_hd_seed"), Method::new_nothing("setlabel", "set_label"), - Method::new_bool("settxfee", "set_tx_fee"), + Method::new_no_model("settxfee", "SetTxFee", "set_tx_fee"), Method::new_modelled("setwalletflag", "SetWalletFlag", "set_wallet_flag"), Method::new_modelled("signmessage", "SignMessage", "sign_message"), Method::new_modelled( @@ -155,6 +154,7 @@ pub const METHODS: &[Method] = &[ "SignRawTransactionWithWallet", "sign_raw_transaction_with_wallet", ), + Method::new_nothing("importwallet", "import_wallet"), Method::new_nothing("unloadwallet", "unload_wallet"), Method::new_no_model("upgradewallet", "UpgradeWalled", "upgrade_wallet"), Method::new_modelled( @@ -164,8 +164,8 @@ pub const METHODS: &[Method] = &[ ), Method::new_modelled("walletdisplayaddress", "WalletDisplayAddress", "wallet_display_address"), Method::new_nothing("walletlock", "wallet_lock"), - Method::new_nothing("walletpassphrase", "wallet_passphrase"), - Method::new_nothing("walletpassphrasechange", "wallet_passphrase_change"), + Method::new_no_model("walletpassphrase", "WalletPassPhrase", "wallet_passphrase"), + Method::new_no_model("walletpassphrasechange", "WalletPassPhraseChange", "wallet_passphrase_change"), Method::new_modelled("walletprocesspsbt", "WalletProcessPsbt", "wallet_process_psbt"), Method::new_no_model("getzmqnotifications", "GetZmqNotifications", "get_zmq_notifications"), ]; diff --git a/verify/src/method/v24.rs b/verify/src/method/v24.rs index bb16af93..6ad63f21 100644 --- a/verify/src/method/v24.rs +++ b/verify/src/method/v24.rs @@ -33,10 +33,10 @@ pub const METHODS: &[Method] = &[ Method::new_modelled("gettxoutsetinfo", "GetTxOutSetInfo", "get_tx_out_set_info"), Method::new_modelled("gettxspendingprevout", "GetTxSpendingPrevout", "get_tx_spending_prevout"), Method::new_nothing("preciousblock", "precious_block"), - Method::new_numeric("pruneblockchain", "prune_blockchain"), - Method::new_nothing("savemempool", "save_mempool"), + Method::new_no_model("pruneblockchain", "PruneBlockchain", "prune_blockchain"), + Method::new_no_model("savemempool", "SaveMempool", "save_mempool"), Method::new_modelled("scantxoutset", "ScanTxOutSet", "scan_tx_out_set"), - Method::new_bool("verifychain", "verify_chain"), + Method::new_no_model("verifychain", "VerifyChain", "verify_chain"), Method::new_modelled("verifytxoutproof", "VerifyTxOutProof", "verify_tx_out_proof"), Method::new_no_model("getrpcinfo", "GetRpcInfo", "get_rpc_info"), Method::new_no_model("getmemoryinfo", "GetMemoryInfoStats", "get_memory_info"), @@ -50,19 +50,19 @@ pub const METHODS: &[Method] = &[ Method::new_bool("prioritisetransaction", "prioritise_transaction"), Method::new_nothing("submitblock", "submit_block"), Method::new_nothing("submitheader", "submit_header"), - Method::new_nothing("addnode", "add_node"), - Method::new_nothing("clearbanned", "clear_banned"), - Method::new_nothing("disconnectnode", "disconnect_node"), + Method::new_no_model("addnode", "AddNode", "add_node"), + Method::new_no_model("clearbanned", "ClearBanned", "clear_banned"), + Method::new_no_model("disconnectnode", "DisconnectNode", "disconnect_node"), Method::new_no_model("getaddednodeinfo", "GetAddedNodeInfo", "get_added_node_info"), - Method::new_numeric("getconnectioncount", "get_connection_count"), + Method::new_no_model("getconnectioncount", "GetConnectionCount", "get_connection_count"), Method::new_no_model("getnettotals", "GetNetTotals", "get_net_totals"), Method::new_modelled("getnetworkinfo", "GetNetworkInfo", "get_network_info"), Method::new_no_model("getnodeaddresses", "GetNodeAddresses", "get_node_addresses"), Method::new_no_model("getpeerinfo", "GetPeerInfo", "get_peer_info"), - Method::new_string("listbanned", "list_banned"), // v17 docs seem wrong, says no return. - Method::new_nothing("ping", "ping"), - Method::new_nothing("setban", "set_ban"), - Method::new_nothing("setnetworkactive", "set_network_active"), + Method::new_no_model("listbanned", "ListBanned", "list_banned"), // v17 docs seem wrong, says no return. + Method::new_no_model("ping", "Ping", "ping"), + Method::new_no_model("setban", "SetBan", "set_ban"), + Method::new_no_model("setnetworkactive", "SetNetworkActive", "set_network_active"), Method::new_modelled("analyzepsbt", "AnalyzePsbt", "analyze_psbt"), Method::new_nothing("combinepsbt", "combine_psbt"), Method::new_nothing("combinerawtransaction", "combine_raw_transaction"), @@ -89,15 +89,14 @@ pub const METHODS: &[Method] = &[ Method::new_string("signmessagewithprivkey", "sign_message_with_priv_key"), Method::new_modelled("validateaddress", "ValidateAddress", "validate_address"), Method::new_bool("verifymessage", "verify_message"), - Method::new_nothing("abandontransaction", "abandon_transaction"), - Method::new_nothing("abortrescan", "abort_rescan"), - Method::new_modelled("addmultisigaddress", "AddMultisigAddress", "add_multisig_address"), - Method::new_nothing("backupwallet", "backup_wallet"), + Method::new_no_model("abandontransaction", "AbandonTransaction", "abandon_transaction"), + Method::new_no_model("abortrescan", "AbortRescan", "abort_rescan"), Method::new_modelled("addmultisigaddress", "AddMultisigAddress", "add_multisig_address"), + Method::new_no_model("backupwallet", "BackupWallet", "backup_wallet"), Method::new_modelled("bumpfee", "BumpFee", "bump_fee"), Method::new_modelled("createwallet", "CreateWallet", "create_wallet"), Method::new_modelled("dumpprivkey", "DumpPrivKey", "dump_priv_key"), Method::new_modelled("dumpwallet", "DumpWallet", "dump_wallet"), - Method::new_nothing("encryptwallet", "encrypt_wallet"), + Method::new_no_model("encryptwallet", "EncryptWallet", "encrypt_wallet"), Method::new_modelled("getaddressesbylabel", "GetAddressesByLabel", "get_addresses_by_label"), Method::new_modelled("getaddressinfo", "GetAddressInfo", "get_address_info"), Method::new_modelled("getbalance", "GetBalance", "get_balance"), @@ -115,12 +114,12 @@ pub const METHODS: &[Method] = &[ Method::new_modelled("getwalletinfo", "GetWalletInfo", "get_wallet_info"), Method::new_nothing("importaddress", "import_address"), Method::new_no_model("importdescriptors", "ImportDescriptors", "import_descriptors"), - Method::new_nothing("importmulti", "import_multi"), - Method::new_nothing("importprivkey", "import_priv_key"), - Method::new_nothing("importprunedfunds", "import_pruned_funds"), - Method::new_nothing("importpubkey", "import_pubkey"), - Method::new_nothing("importwallet", "import_walet"), - Method::new_nothing("keypoolrefill", "keypool_refill"), + Method::new_modelled("importmulti", "ImportMulti", "import_multi"), + Method::new_no_model("importprivkey", "ImportPrivKey", "import_priv_key"), + Method::new_no_model("importprunedfunds", "ImportPrunedFunds", "import_pruned_funds"), + Method::new_no_model("importpubkey", "ImportPubKey", "import_pubkey"), + Method::new_no_model("importwallet", "ImportWallet", "import_walet"), + Method::new_no_model("keypoolrefill", "KeypoolRefill", "keypool_refill"), Method::new_modelled("listaddressgroupings", "ListAddressGroupings", "list_address_groupings"), Method::new_modelled("listdescriptors", "ListDescriptors", "list_descriptors"), Method::new_modelled("listlabels", "ListLabels", "list_labels"), @@ -140,19 +139,20 @@ pub const METHODS: &[Method] = &[ Method::new_no_model("listwalletdir", "ListWalletDir", "list_wallet_dir"), Method::new_modelled("listwallets", "ListWallets", "list_wallets"), Method::new_modelled("loadwallet", "LoadWallet", "load_wallet"), - Method::new_bool("lockunspent", "lock_unspent"), - Method::new_nothing("removeprunedfunds", "remove_pruned_funds"), + Method::new_no_model("lockunspent", "LockUnspent", "lock_unspent"), + Method::new_no_model("removeprunedfunds", "RemovePrunedFunds", "remove_pruned_funds"), Method::new_modelled("rescanblockchain", "RescanBlockchain", "rescan_blockchain"), Method::new_modelled("restorewallet", "RestoreWallet", "restore_wallet"), Method::new_modelled("send", "Send", "send"), Method::new_modelled("sendall", "SendAll", "send_all"), Method::new_modelled("sendmany", "SendMany", "send_many"), Method::new_modelled("sendtoaddress", "SendToAddress", "send_to_address"), - Method::new_nothing("sethdseed", "set_hd_seed"), + Method::new_no_model("sethdseed", "SetHdSeed", "set_hd_seed"), Method::new_nothing("setlabel", "set_label"), - Method::new_bool("settxfee", "set_tx_fee"), + Method::new_no_model("settxfee", "SetTxFee", "set_tx_fee"), Method::new_modelled("setwalletflag", "SetWalletFlag", "set_wallet_flag"), Method::new_modelled("signmessage", "SignMessage", "sign_message"), + Method::new_nothing("importwallet", "import_wallet"), Method::new_modelled( "signrawtransactionwithwallet", "SignRawTransactionWithWallet", @@ -168,8 +168,8 @@ pub const METHODS: &[Method] = &[ ), Method::new_modelled("walletdisplayaddress", "WalletDisplayAddress", "wallet_display_address"), Method::new_nothing("walletlock", "wallet_lock"), - Method::new_nothing("walletpassphrase", "wallet_passphrase"), - Method::new_nothing("walletpassphrasechange", "wallet_passphrase_change"), + Method::new_no_model("walletpassphrase", "WalletPassPhrase", "wallet_passphrase"), + Method::new_no_model("walletpassphrasechange", "WalletPassPhraseChange", "wallet_passphrase_change"), Method::new_modelled("walletprocesspsbt", "WalletProcessPsbt", "wallet_process_psbt"), Method::new_no_model("getzmqnotifications", "GetZmqNotifications", "get_zmq_notifications"), ]; diff --git a/verify/src/method/v25.rs b/verify/src/method/v25.rs index 2c5ea011..d5a464a7 100644 --- a/verify/src/method/v25.rs +++ b/verify/src/method/v25.rs @@ -33,11 +33,11 @@ pub const METHODS: &[Method] = &[ Method::new_modelled("gettxoutsetinfo", "GetTxOutSetInfo", "get_tx_out_set_info"), Method::new_modelled("gettxspendingprevout", "GetTxSpendingPrevout", "get_tx_spending_prevout"), Method::new_nothing("preciousblock", "precious_block"), - Method::new_numeric("pruneblockchain", "prune_blockchain"), - Method::new_nothing("savemempool", "save_mempool"), + Method::new_no_model("pruneblockchain", "PruneBlockchain", "prune_blockchain"), + Method::new_no_model("savemempool", "SaveMempool", "save_mempool"), Method::new_modelled("scanblocks", "ScanBlocks", "scan_blocks"), Method::new_modelled("scantxoutset", "ScanTxOutSet", "scan_tx_out_set"), - Method::new_bool("verifychain", "verify_chain"), + Method::new_no_model("verifychain", "VerifyChain", "verify_chain"), Method::new_modelled("verifytxoutproof", "VerifyTxOutProof", "verify_tx_out_proof"), Method::new_no_model("getrpcinfo", "GetRpcInfo", "get_rpc_info"), Method::new_no_model("getmemoryinfo", "GetMemoryInfoStats", "get_memory_info"), @@ -51,19 +51,19 @@ pub const METHODS: &[Method] = &[ Method::new_bool("prioritisetransaction", "prioritise_transaction"), Method::new_nothing("submitblock", "submit_block"), Method::new_nothing("submitheader", "submit_header"), - Method::new_nothing("addnode", "add_node"), - Method::new_nothing("clearbanned", "clear_banned"), - Method::new_nothing("disconnectnode", "disconnect_node"), + Method::new_no_model("addnode", "AddNode", "add_node"), + Method::new_no_model("clearbanned", "ClearBanned", "clear_banned"), + Method::new_no_model("disconnectnode", "DisconnectNode", "disconnect_node"), Method::new_no_model("getaddednodeinfo", "GetAddedNodeInfo", "get_added_node_info"), - Method::new_numeric("getconnectioncount", "get_connection_count"), + Method::new_no_model("getconnectioncount", "GetConnectionCount", "get_connection_count"), Method::new_no_model("getnettotals", "GetNetTotals", "get_net_totals"), Method::new_modelled("getnetworkinfo", "GetNetworkInfo", "get_network_info"), Method::new_no_model("getnodeaddresses", "GetNodeAddresses", "get_node_addresses"), Method::new_no_model("getpeerinfo", "GetPeerInfo", "get_peer_info"), - Method::new_string("listbanned", "list_banned"), // v17 docs seem wrong, says no return. - Method::new_nothing("ping", "ping"), - Method::new_nothing("setban", "set_ban"), - Method::new_nothing("setnetworkactive", "set_network_active"), + Method::new_no_model("listbanned", "ListBanned", "list_banned"), // v17 docs seem wrong, says no return. + Method::new_no_model("ping", "Ping", "ping"), + Method::new_no_model("setban", "SetBan", "set_ban"), + Method::new_no_model("setnetworkactive", "SetNetworkActive", "set_network_active"), Method::new_modelled("analyzepsbt", "AnalyzePsbt", "analyze_psbt"), Method::new_nothing("combinepsbt", "combine_psbt"), Method::new_nothing("combinerawtransaction", "combine_raw_transaction"), @@ -90,15 +90,14 @@ pub const METHODS: &[Method] = &[ Method::new_string("signmessagewithprivkey", "sign_message_with_priv_key"), Method::new_modelled("validateaddress", "ValidateAddress", "validate_address"), Method::new_bool("verifymessage", "verify_message"), - Method::new_nothing("abandontransaction", "abandon_transaction"), - Method::new_nothing("abortrescan", "abort_rescan"), - Method::new_modelled("addmultisigaddress", "AddMultisigAddress", "add_multisig_address"), - Method::new_nothing("backupwallet", "backup_wallet"), + Method::new_no_model("abandontransaction", "AbandonTransaction", "abandon_transaction"), + Method::new_no_model("abortrescan", "AbortRescan", "abort_rescan"), Method::new_modelled("addmultisigaddress", "AddMultisigAddress", "add_multisig_address"), + Method::new_no_model("backupwallet", "BackupWallet", "backup_wallet"), Method::new_modelled("bumpfee", "BumpFee", "bump_fee"), Method::new_modelled("createwallet", "CreateWallet", "create_wallet"), Method::new_modelled("dumpprivkey", "DumpPrivKey", "dump_priv_key"), Method::new_modelled("dumpwallet", "DumpWallet", "dump_wallet"), - Method::new_nothing("encryptwallet", "encrypt_wallet"), + Method::new_no_model("encryptwallet", "EncryptWallet", "encrypt_wallet"), Method::new_modelled("getaddressesbylabel", "GetAddressesByLabel", "get_addresses_by_label"), Method::new_modelled("getaddressinfo", "GetAddressInfo", "get_address_info"), Method::new_modelled("getbalance", "GetBalance", "get_balance"), @@ -116,12 +115,12 @@ pub const METHODS: &[Method] = &[ Method::new_modelled("getwalletinfo", "GetWalletInfo", "get_wallet_info"), Method::new_nothing("importaddress", "import_address"), Method::new_no_model("importdescriptors", "ImportDescriptors", "import_descriptors"), - Method::new_nothing("importmulti", "import_multi"), - Method::new_nothing("importprivkey", "import_priv_key"), - Method::new_nothing("importprunedfunds", "import_pruned_funds"), - Method::new_nothing("importpubkey", "import_pubkey"), - Method::new_nothing("importwallet", "import_walet"), - Method::new_nothing("keypoolrefill", "keypool_refill"), + Method::new_modelled("importmulti", "ImportMulti", "import_multi"), + Method::new_no_model("importprivkey", "ImportPrivKey", "import_priv_key"), + Method::new_no_model("importprunedfunds", "ImportPrunedFunds", "import_pruned_funds"), + Method::new_no_model("importpubkey", "ImportPubKey", "import_pubkey"), + Method::new_no_model("importwallet", "ImportWallet", "import_walet"), + Method::new_no_model("keypoolrefill", "KeypoolRefill", "keypool_refill"), Method::new_modelled("listaddressgroupings", "ListAddressGroupings", "list_address_groupings"), Method::new_modelled("listdescriptors", "ListDescriptors", "list_descriptors"), Method::new_modelled("listlabels", "ListLabels", "list_labels"), @@ -141,18 +140,19 @@ pub const METHODS: &[Method] = &[ Method::new_no_model("listwalletdir", "ListWalletDir", "list_wallet_dir"), Method::new_modelled("listwallets", "ListWallets", "list_wallets"), Method::new_modelled("loadwallet", "LoadWallet", "load_wallet"), - Method::new_bool("lockunspent", "lock_unspent"), - Method::new_nothing("removeprunedfunds", "remove_pruned_funds"), + Method::new_no_model("lockunspent", "LockUnspent", "lock_unspent"), + Method::new_no_model("removeprunedfunds", "RemovePrunedFunds", "remove_pruned_funds"), Method::new_modelled("rescanblockchain", "RescanBlockchain", "rescan_blockchain"), Method::new_modelled("restorewallet", "RestoreWallet", "restore_wallet"), Method::new_modelled("send", "Send", "send"), Method::new_modelled("sendall", "SendAll", "send_all"), Method::new_modelled("sendmany", "SendMany", "send_many"), Method::new_modelled("sendtoaddress", "SendToAddress", "send_to_address"), - Method::new_nothing("sethdseed", "set_hd_seed"), + Method::new_no_model("sethdseed", "SetHdSeed", "set_hd_seed"), Method::new_nothing("setlabel", "set_label"), - Method::new_bool("settxfee", "set_tx_fee"), + Method::new_no_model("settxfee", "SetTxFee", "set_tx_fee"), Method::new_modelled("setwalletflag", "SetWalletFlag", "set_wallet_flag"), + Method::new_nothing("importwallet", "import_wallet"), Method::new_modelled("signmessage", "SignMessage", "sign_message"), Method::new_modelled( "signrawtransactionwithwallet", @@ -169,8 +169,8 @@ pub const METHODS: &[Method] = &[ ), Method::new_modelled("walletdisplayaddress", "WalletDisplayAddress", "wallet_display_address"), Method::new_nothing("walletlock", "wallet_lock"), - Method::new_nothing("walletpassphrase", "wallet_passphrase"), - Method::new_nothing("walletpassphrasechange", "wallet_passphrase_change"), + Method::new_no_model("walletpassphrase", "WalletPassPhrase", "wallet_passphrase"), + Method::new_no_model("walletpassphrasechange", "WalletPassPhraseChange", "wallet_passphrase_change"), Method::new_modelled("walletprocesspsbt", "WalletProcessPsbt", "wallet_process_psbt"), Method::new_no_model("getzmqnotifications", "GetZmqNotifications", "get_zmq_notifications"), ]; diff --git a/verify/src/method/v26.rs b/verify/src/method/v26.rs index db26e8c8..de8ebc0a 100644 --- a/verify/src/method/v26.rs +++ b/verify/src/method/v26.rs @@ -37,11 +37,11 @@ pub const METHODS: &[Method] = &[ Method::new_modelled("importmempool", "ImportMempool", "import_mempool"), Method::new_no_model("loadtxoutset", "LoadTxOutSet", "load_tx_out_set"), Method::new_nothing("preciousblock", "precious_block"), - Method::new_numeric("pruneblockchain", "prune_blockchain"), - Method::new_nothing("savemempool", "save_mempool"), + Method::new_no_model("pruneblockchain", "PruneBlockchain", "prune_blockchain"), + Method::new_no_model("savemempool", "SaveMempool", "save_mempool"), Method::new_modelled("scanblocks", "ScanBlocks", "scan_blocks"), Method::new_modelled("scantxoutset", "ScanTxOutSet", "scan_tx_out_set"), - Method::new_bool("verifychain", "verify_chain"), + Method::new_no_model("verifychain", "VerifyChain", "verify_chain"), Method::new_modelled("verifytxoutproof", "VerifyTxOutProof", "verify_tx_out_proof"), Method::new_no_model("getrpcinfo", "GetRpcInfo", "get_rpc_info"), Method::new_no_model("getmemoryinfo", "GetMemoryInfoStats", "get_memory_info"), @@ -56,20 +56,20 @@ pub const METHODS: &[Method] = &[ Method::new_bool("prioritisetransaction", "prioritise_transaction"), Method::new_nothing("submitblock", "submit_block"), Method::new_nothing("submitheader", "submit_header"), - Method::new_nothing("addnode", "add_node"), - Method::new_nothing("clearbanned", "clear_banned"), - Method::new_nothing("disconnectnode", "disconnect_node"), + Method::new_no_model("addnode", "AddNode", "add_node"), + Method::new_no_model("clearbanned", "ClearBanned", "clear_banned"), + Method::new_no_model("disconnectnode", "DisconnectNode", "disconnect_node"), Method::new_no_model("getaddednodeinfo", "GetAddedNodeInfo", "get_added_node_info"), Method::new_no_model("getaddrmaninfo", "GetAddrManInfo", "get_addr_man_info"), - Method::new_numeric("getconnectioncount", "get_connection_count"), + Method::new_no_model("getconnectioncount", "GetConnectionCount", "get_connection_count"), Method::new_no_model("getnettotals", "GetNetTotals", "get_net_totals"), Method::new_modelled("getnetworkinfo", "GetNetworkInfo", "get_network_info"), Method::new_no_model("getnodeaddresses", "GetNodeAddresses", "get_node_addresses"), Method::new_no_model("getpeerinfo", "GetPeerInfo", "get_peer_info"), - Method::new_string("listbanned", "list_banned"), // v17 docs seem wrong, says no return. - Method::new_nothing("ping", "ping"), - Method::new_nothing("setban", "set_ban"), - Method::new_nothing("setnetworkactive", "set_network_active"), + Method::new_no_model("listbanned", "ListBanned", "list_banned"), // v17 docs seem wrong, says no return. + Method::new_no_model("ping", "Ping", "ping"), + Method::new_no_model("setban", "SetBan", "set_ban"), + Method::new_no_model("setnetworkactive", "SetNetworkActive", "set_network_active"), Method::new_modelled("analyzepsbt", "AnalyzePsbt", "analyze_psbt"), Method::new_nothing("combinepsbt", "combine_psbt"), Method::new_nothing("combinerawtransaction", "combine_raw_transaction"), @@ -98,15 +98,14 @@ pub const METHODS: &[Method] = &[ Method::new_string("signmessagewithprivkey", "sign_message_with_priv_key"), Method::new_modelled("validateaddress", "ValidateAddress", "validate_address"), Method::new_bool("verifymessage", "verify_message"), - Method::new_nothing("abandontransaction", "abandon_transaction"), - Method::new_nothing("abortrescan", "abort_rescan"), - Method::new_modelled("addmultisigaddress", "AddMultisigAddress", "add_multisig_address"), - Method::new_nothing("backupwallet", "backup_wallet"), + Method::new_no_model("abandontransaction", "AbandonTransaction", "abandon_transaction"), + Method::new_no_model("abortrescan", "AbortRescan", "abort_rescan"), Method::new_modelled("addmultisigaddress", "AddMultisigAddress", "add_multisig_address"), + Method::new_no_model("backupwallet", "BackupWallet", "backup_wallet"), Method::new_modelled("bumpfee", "BumpFee", "bump_fee"), Method::new_modelled("createwallet", "CreateWallet", "create_wallet"), Method::new_modelled("dumpprivkey", "DumpPrivKey", "dump_priv_key"), Method::new_modelled("dumpwallet", "DumpWallet", "dump_wallet"), - Method::new_nothing("encryptwallet", "encrypt_wallet"), + Method::new_no_model("encryptwallet", "EncryptWallet", "encrypt_wallet"), Method::new_modelled("getaddressesbylabel", "GetAddressesByLabel", "get_addresses_by_label"), Method::new_modelled("getaddressinfo", "GetAddressInfo", "get_address_info"), Method::new_modelled("getbalance", "GetBalance", "get_balance"), @@ -124,12 +123,12 @@ pub const METHODS: &[Method] = &[ Method::new_modelled("getwalletinfo", "GetWalletInfo", "get_wallet_info"), Method::new_nothing("importaddress", "import_address"), Method::new_no_model("importdescriptors", "ImportDescriptors", "import_descriptors"), - Method::new_nothing("importmulti", "import_multi"), - Method::new_nothing("importprivkey", "import_priv_key"), - Method::new_nothing("importprunedfunds", "import_pruned_funds"), - Method::new_nothing("importpubkey", "import_pubkey"), - Method::new_nothing("importwallet", "import_walet"), - Method::new_nothing("keypoolrefill", "keypool_refill"), + Method::new_modelled("importmulti", "ImportMulti", "import_multi"), + Method::new_no_model("importprivkey", "ImportPrivKey", "import_priv_key"), + Method::new_no_model("importprunedfunds", "ImportPrunedFunds", "import_pruned_funds"), + Method::new_no_model("importpubkey", "ImportPubKey", "import_pubkey"), + Method::new_no_model("importwallet", "ImportWallet", "import_walet"), + Method::new_no_model("keypoolrefill", "KeypoolRefill", "keypool_refill"), Method::new_modelled("listaddressgroupings", "ListAddressGroupings", "list_address_groupings"), Method::new_modelled("listdescriptors", "ListDescriptors", "list_descriptors"), Method::new_modelled("listlabels", "ListLabels", "list_labels"), @@ -149,17 +148,18 @@ pub const METHODS: &[Method] = &[ Method::new_no_model("listwalletdir", "ListWalletDir", "list_wallet_dir"), Method::new_modelled("listwallets", "ListWallets", "list_wallets"), Method::new_modelled("loadwallet", "LoadWallet", "load_wallet"), - Method::new_bool("lockunspent", "lock_unspent"), - Method::new_nothing("removeprunedfunds", "remove_pruned_funds"), + Method::new_no_model("lockunspent", "LockUnspent", "lock_unspent"), + Method::new_no_model("removeprunedfunds", "RemovePrunedFunds", "remove_pruned_funds"), Method::new_modelled("rescanblockchain", "RescanBlockchain", "rescan_blockchain"), Method::new_modelled("restorewallet", "RestoreWallet", "restore_wallet"), + Method::new_nothing("importwallet", "import_wallet"), Method::new_modelled("send", "Send", "send"), Method::new_modelled("sendall", "SendAll", "send_all"), Method::new_modelled("sendmany", "SendMany", "send_many"), Method::new_modelled("sendtoaddress", "SendToAddress", "send_to_address"), - Method::new_nothing("sethdseed", "set_hd_seed"), + Method::new_no_model("sethdseed", "SetHdSeed", "set_hd_seed"), Method::new_nothing("setlabel", "set_label"), - Method::new_bool("settxfee", "set_tx_fee"), + Method::new_no_model("settxfee", "SetTxFee", "set_tx_fee"), Method::new_modelled("setwalletflag", "SetWalletFlag", "set_wallet_flag"), Method::new_modelled("signmessage", "SignMessage", "sign_message"), Method::new_modelled( @@ -177,8 +177,8 @@ pub const METHODS: &[Method] = &[ ), Method::new_modelled("walletdisplayaddress", "WalletDisplayAddress", "wallet_display_address"), Method::new_nothing("walletlock", "wallet_lock"), - Method::new_nothing("walletpassphrase", "wallet_passphrase"), - Method::new_nothing("walletpassphrasechange", "wallet_passphrase_change"), + Method::new_no_model("walletpassphrase", "WalletPassPhrase", "wallet_passphrase"), + Method::new_no_model("walletpassphrasechange", "WalletPassPhraseChange", "wallet_passphrase_change"), Method::new_modelled("walletprocesspsbt", "WalletProcessPsbt", "wallet_process_psbt"), Method::new_no_model("getzmqnotifications", "GetZmqNotifications", "get_zmq_notifications"), ]; diff --git a/verify/src/method/v27.rs b/verify/src/method/v27.rs index 2dfb3cb3..112b6226 100644 --- a/verify/src/method/v27.rs +++ b/verify/src/method/v27.rs @@ -37,11 +37,11 @@ pub const METHODS: &[Method] = &[ Method::new_modelled("importmempool", "ImportMempool", "import_mempool"), Method::new_no_model("loadtxoutset", "LoadTxOutSet", "load_tx_out_set"), Method::new_nothing("preciousblock", "precious_block"), - Method::new_numeric("pruneblockchain", "prune_blockchain"), - Method::new_nothing("savemempool", "save_mempool"), + Method::new_no_model("pruneblockchain", "PruneBlockchain", "prune_blockchain"), + Method::new_no_model("savemempool", "SaveMempool", "save_mempool"), Method::new_modelled("scanblocks", "ScanBlocks", "scan_blocks"), Method::new_modelled("scantxoutset", "ScanTxOutSet", "scan_tx_out_set"), - Method::new_bool("verifychain", "verify_chain"), + Method::new_no_model("verifychain", "VerifyChain", "verify_chain"), Method::new_modelled("verifytxoutproof", "VerifyTxOutProof", "verify_tx_out_proof"), Method::new_no_model("getrpcinfo", "GetRpcInfo", "get_rpc_info"), Method::new_no_model("getmemoryinfo", "GetMemoryInfoStats", "get_memory_info"), @@ -58,20 +58,20 @@ pub const METHODS: &[Method] = &[ Method::new_bool("prioritisetransaction", "prioritise_transaction"), Method::new_nothing("submitblock", "submit_block"), Method::new_nothing("submitheader", "submit_header"), - Method::new_nothing("addnode", "add_node"), - Method::new_nothing("clearbanned", "clear_banned"), - Method::new_nothing("disconnectnode", "disconnect_node"), + Method::new_no_model("addnode", "AddNode", "add_node"), + Method::new_no_model("clearbanned", "ClearBanned", "clear_banned"), + Method::new_no_model("disconnectnode", "DisconnectNode", "disconnect_node"), Method::new_no_model("getaddednodeinfo", "GetAddedNodeInfo", "get_added_node_info"), Method::new_no_model("getaddrmaninfo", "GetAddrManInfo", "get_addr_man_info"), - Method::new_numeric("getconnectioncount", "get_connection_count"), + Method::new_no_model("getconnectioncount", "GetConnectionCount", "get_connection_count"), Method::new_no_model("getnettotals", "GetNetTotals", "get_net_totals"), Method::new_modelled("getnetworkinfo", "GetNetworkInfo", "get_network_info"), Method::new_no_model("getnodeaddresses", "GetNodeAddresses", "get_node_addresses"), Method::new_no_model("getpeerinfo", "GetPeerInfo", "get_peer_info"), - Method::new_string("listbanned", "list_banned"), // v17 docs seem wrong, says no return. - Method::new_nothing("ping", "ping"), - Method::new_nothing("setban", "set_ban"), - Method::new_nothing("setnetworkactive", "set_network_active"), + Method::new_no_model("listbanned", "ListBanned", "list_banned"), // v17 docs seem wrong, says no return. + Method::new_no_model("ping", "Ping", "ping"), + Method::new_no_model("setban", "SetBan", "set_ban"), + Method::new_no_model("setnetworkactive", "SetNetworkActive", "set_network_active"), Method::new_modelled("analyzepsbt", "AnalyzePsbt", "analyze_psbt"), Method::new_nothing("combinepsbt", "combine_psbt"), Method::new_nothing("combinerawtransaction", "combine_raw_transaction"), @@ -100,15 +100,14 @@ pub const METHODS: &[Method] = &[ Method::new_string("signmessagewithprivkey", "sign_message_with_priv_key"), Method::new_modelled("validateaddress", "ValidateAddress", "validate_address"), Method::new_bool("verifymessage", "verify_message"), - Method::new_nothing("abandontransaction", "abandon_transaction"), - Method::new_nothing("abortrescan", "abort_rescan"), - Method::new_modelled("addmultisigaddress", "AddMultisigAddress", "add_multisig_address"), - Method::new_nothing("backupwallet", "backup_wallet"), + Method::new_no_model("abandontransaction", "AbandonTransaction", "abandon_transaction"), + Method::new_no_model("abortrescan", "AbortRescan", "abort_rescan"), Method::new_modelled("addmultisigaddress", "AddMultisigAddress", "add_multisig_address"), + Method::new_no_model("backupwallet", "BackupWallet", "backup_wallet"), Method::new_modelled("bumpfee", "BumpFee", "bump_fee"), Method::new_modelled("createwallet", "CreateWallet", "create_wallet"), Method::new_modelled("dumpprivkey", "DumpPrivKey", "dump_priv_key"), Method::new_modelled("dumpwallet", "DumpWallet", "dump_wallet"), - Method::new_nothing("encryptwallet", "encrypt_wallet"), + Method::new_no_model("encryptwallet", "EncryptWallet", "encrypt_wallet"), Method::new_modelled("getaddressesbylabel", "GetAddressesByLabel", "get_addresses_by_label"), Method::new_modelled("getaddressinfo", "GetAddressInfo", "get_address_info"), Method::new_modelled("getbalance", "GetBalance", "get_balance"), @@ -126,12 +125,12 @@ pub const METHODS: &[Method] = &[ Method::new_modelled("getwalletinfo", "GetWalletInfo", "get_wallet_info"), Method::new_nothing("importaddress", "import_address"), Method::new_no_model("importdescriptors", "ImportDescriptors", "import_descriptors"), - Method::new_nothing("importmulti", "import_multi"), - Method::new_nothing("importprivkey", "import_priv_key"), - Method::new_nothing("importprunedfunds", "import_pruned_funds"), - Method::new_nothing("importpubkey", "import_pubkey"), - Method::new_nothing("importwallet", "import_walet"), - Method::new_nothing("keypoolrefill", "keypool_refill"), + Method::new_modelled("importmulti", "ImportMulti", "import_multi"), + Method::new_no_model("importprivkey", "ImportPrivKey", "import_priv_key"), + Method::new_no_model("importprunedfunds", "ImportPrunedFunds", "import_pruned_funds"), + Method::new_no_model("importpubkey", "ImportPubKey", "import_pubkey"), + Method::new_no_model("importwallet", "ImportWallet", "import_walet"), + Method::new_no_model("keypoolrefill", "KeypoolRefill", "keypool_refill"), Method::new_modelled("listaddressgroupings", "ListAddressGroupings", "list_address_groupings"), Method::new_modelled("listdescriptors", "ListDescriptors", "list_descriptors"), Method::new_modelled("listlabels", "ListLabels", "list_labels"), @@ -151,17 +150,18 @@ pub const METHODS: &[Method] = &[ Method::new_no_model("listwalletdir", "ListWalletDir", "list_wallet_dir"), Method::new_modelled("listwallets", "ListWallets", "list_wallets"), Method::new_modelled("loadwallet", "LoadWallet", "load_wallet"), - Method::new_bool("lockunspent", "lock_unspent"), - Method::new_nothing("removeprunedfunds", "remove_pruned_funds"), + Method::new_no_model("lockunspent", "LockUnspent", "lock_unspent"), + Method::new_no_model("removeprunedfunds", "RemovePrunedFunds", "remove_pruned_funds"), + Method::new_nothing("importwallet", "import_wallet"), Method::new_modelled("rescanblockchain", "RescanBlockchain", "rescan_blockchain"), Method::new_modelled("restorewallet", "RestoreWallet", "restore_wallet"), Method::new_modelled("send", "Send", "send"), Method::new_modelled("sendall", "SendAll", "send_all"), Method::new_modelled("sendmany", "SendMany", "send_many"), Method::new_modelled("sendtoaddress", "SendToAddress", "send_to_address"), - Method::new_nothing("sethdseed", "set_hd_seed"), + Method::new_no_model("sethdseed", "SetHdSeed", "set_hd_seed"), Method::new_nothing("setlabel", "set_label"), - Method::new_bool("settxfee", "set_tx_fee"), + Method::new_no_model("settxfee", "SetTxFee", "set_tx_fee"), Method::new_modelled("setwalletflag", "SetWalletFlag", "set_wallet_flag"), Method::new_modelled("signmessage", "SignMessage", "sign_message"), Method::new_modelled( @@ -179,8 +179,8 @@ pub const METHODS: &[Method] = &[ ), Method::new_modelled("walletdisplayaddress", "WalletDisplayAddress", "wallet_display_address"), Method::new_nothing("walletlock", "wallet_lock"), - Method::new_nothing("walletpassphrase", "wallet_passphrase"), - Method::new_nothing("walletpassphrasechange", "wallet_passphrase_change"), + Method::new_no_model("walletpassphrase", "WalletPassPhrase", "wallet_passphrase"), + Method::new_no_model("walletpassphrasechange", "WalletPassPhraseChange", "wallet_passphrase_change"), Method::new_modelled("walletprocesspsbt", "WalletProcessPsbt", "wallet_process_psbt"), Method::new_no_model("getzmqnotifications", "GetZmqNotifications", "get_zmq_notifications"), ]; diff --git a/verify/src/method/v28.rs b/verify/src/method/v28.rs index e757f65a..68c2f5b7 100644 --- a/verify/src/method/v28.rs +++ b/verify/src/method/v28.rs @@ -37,11 +37,11 @@ pub const METHODS: &[Method] = &[ Method::new_modelled("importmempool", "ImportMempool", "import_mempool"), Method::new_no_model("loadtxoutset", "LoadTxOutSet", "load_tx_out_set"), Method::new_nothing("preciousblock", "precious_block"), - Method::new_numeric("pruneblockchain", "prune_blockchain"), - Method::new_nothing("savemempool", "save_mempool"), + Method::new_no_model("pruneblockchain", "PruneBlockchain", "prune_blockchain"), + Method::new_no_model("savemempool", "SaveMempool", "save_mempool"), Method::new_modelled("scanblocks", "ScanBlocks", "scan_blocks"), Method::new_modelled("scantxoutset", "ScanTxOutSet", "scan_tx_out_set"), - Method::new_bool("verifychain", "verify_chain"), + Method::new_no_model("verifychain", "VerifyChain", "verify_chain"), Method::new_modelled("verifytxoutproof", "VerifyTxOutProof", "verify_tx_out_proof"), Method::new_no_model("getrpcinfo", "GetRpcInfo", "get_rpc_info"), Method::new_no_model("getmemoryinfo", "GetMemoryInfoStats", "get_memory_info"), @@ -58,20 +58,20 @@ pub const METHODS: &[Method] = &[ Method::new_bool("prioritisetransaction", "prioritise_transaction"), Method::new_nothing("submitblock", "submit_block"), Method::new_nothing("submitheader", "submit_header"), - Method::new_nothing("addnode", "add_node"), - Method::new_nothing("clearbanned", "clear_banned"), - Method::new_nothing("disconnectnode", "disconnect_node"), + Method::new_no_model("addnode", "AddNode", "add_node"), + Method::new_no_model("clearbanned", "ClearBanned", "clear_banned"), + Method::new_no_model("disconnectnode", "DisconnectNode", "disconnect_node"), Method::new_no_model("getaddednodeinfo", "GetAddedNodeInfo", "get_added_node_info"), Method::new_no_model("getaddrmaninfo", "GetAddrManInfo", "get_addr_man_info"), - Method::new_numeric("getconnectioncount", "get_connection_count"), + Method::new_no_model("getconnectioncount", "GetConnectionCount", "get_connection_count"), Method::new_no_model("getnettotals", "GetNetTotals", "get_net_totals"), Method::new_modelled("getnetworkinfo", "GetNetworkInfo", "get_network_info"), Method::new_no_model("getnodeaddresses", "GetNodeAddresses", "get_node_addresses"), Method::new_no_model("getpeerinfo", "GetPeerInfo", "get_peer_info"), - Method::new_string("listbanned", "list_banned"), // v17 docs seem wrong, says no return. - Method::new_nothing("ping", "ping"), - Method::new_nothing("setban", "set_ban"), - Method::new_nothing("setnetworkactive", "set_network_active"), + Method::new_no_model("listbanned", "ListBanned", "list_banned"), // v17 docs seem wrong, says no return. + Method::new_no_model("ping", "Ping", "ping"), + Method::new_no_model("setban", "SetBan", "set_ban"), + Method::new_no_model("setnetworkactive", "SetNetworkActive", "set_network_active"), Method::new_modelled("analyzepsbt", "AnalyzePsbt", "analyze_psbt"), Method::new_nothing("combinepsbt", "combine_psbt"), Method::new_nothing("combinerawtransaction", "combine_raw_transaction"), @@ -100,16 +100,15 @@ pub const METHODS: &[Method] = &[ Method::new_string("signmessagewithprivkey", "sign_message_with_priv_key"), Method::new_modelled("validateaddress", "ValidateAddress", "validate_address"), Method::new_bool("verifymessage", "verify_message"), - Method::new_nothing("abandontransaction", "abandon_transaction"), - Method::new_nothing("abortrescan", "abort_rescan"), - Method::new_modelled("addmultisigaddress", "AddMultisigAddress", "add_multisig_address"), - Method::new_nothing("backupwallet", "backup_wallet"), + Method::new_no_model("abandontransaction", "AbandonTransaction", "abandon_transaction"), + Method::new_no_model("abortrescan", "AbortRescan", "abort_rescan"), Method::new_modelled("addmultisigaddress", "AddMultisigAddress", "add_multisig_address"), + Method::new_no_model("backupwallet", "BackupWallet", "backup_wallet"), Method::new_modelled("bumpfee", "BumpFee", "bump_fee"), Method::new_modelled("createwallet", "CreateWallet", "create_wallet"), Method::new_no_model("createwalletdescriptor", "CreateWalletDescriptor", "create_wallet_descriptor"), Method::new_modelled("dumpprivkey", "DumpPrivKey", "dump_priv_key"), Method::new_modelled("dumpwallet", "DumpWallet", "dump_wallet"), - Method::new_nothing("encryptwallet", "encrypt_wallet"), + Method::new_no_model("encryptwallet", "EncryptWallet", "encrypt_wallet"), Method::new_modelled("getaddressesbylabel", "GetAddressesByLabel", "get_addresses_by_label"), Method::new_modelled("getaddressinfo", "GetAddressInfo", "get_address_info"), Method::new_modelled("getbalance", "GetBalance", "get_balance"), @@ -128,12 +127,12 @@ pub const METHODS: &[Method] = &[ Method::new_modelled("getwalletinfo", "GetWalletInfo", "get_wallet_info"), Method::new_nothing("importaddress", "import_address"), Method::new_no_model("importdescriptors", "ImportDescriptors", "import_descriptors"), - Method::new_nothing("importmulti", "import_multi"), - Method::new_nothing("importprivkey", "import_priv_key"), - Method::new_nothing("importprunedfunds", "import_pruned_funds"), - Method::new_nothing("importpubkey", "import_pubkey"), - Method::new_nothing("importwallet", "import_walet"), - Method::new_nothing("keypoolrefill", "keypool_refill"), + Method::new_modelled("importmulti", "ImportMulti", "import_multi"), + Method::new_no_model("importprivkey", "ImportPrivKey", "import_priv_key"), + Method::new_no_model("importprunedfunds", "ImportPrunedFunds", "import_pruned_funds"), + Method::new_no_model("importpubkey", "ImportPubKey", "import_pubkey"), + Method::new_no_model("importwallet", "ImportWallet", "import_walet"), + Method::new_no_model("keypoolrefill", "KeypoolRefill", "keypool_refill"), Method::new_modelled("listaddressgroupings", "ListAddressGroupings", "list_address_groupings"), Method::new_modelled("listdescriptors", "ListDescriptors", "list_descriptors"), Method::new_modelled("listlabels", "ListLabels", "list_labels"), @@ -153,17 +152,18 @@ pub const METHODS: &[Method] = &[ Method::new_no_model("listwalletdir", "ListWalletDir", "list_wallet_dir"), Method::new_modelled("listwallets", "ListWallets", "list_wallets"), Method::new_modelled("loadwallet", "LoadWallet", "load_wallet"), - Method::new_bool("lockunspent", "lock_unspent"), - Method::new_nothing("removeprunedfunds", "remove_pruned_funds"), + Method::new_nothing("importwallet", "import_wallet"), + Method::new_no_model("lockunspent", "LockUnspent", "lock_unspent"), + Method::new_no_model("removeprunedfunds", "RemovePrunedFunds", "remove_pruned_funds"), Method::new_modelled("rescanblockchain", "RescanBlockchain", "rescan_blockchain"), Method::new_modelled("restorewallet", "RestoreWallet", "restore_wallet"), Method::new_modelled("send", "Send", "send"), Method::new_modelled("sendall", "SendAll", "send_all"), Method::new_modelled("sendmany", "SendMany", "send_many"), Method::new_modelled("sendtoaddress", "SendToAddress", "send_to_address"), - Method::new_nothing("sethdseed", "set_hd_seed"), + Method::new_no_model("sethdseed", "SetHdSeed", "set_hd_seed"), Method::new_nothing("setlabel", "set_label"), - Method::new_bool("settxfee", "set_tx_fee"), + Method::new_no_model("settxfee", "SetTxFee", "set_tx_fee"), Method::new_modelled("setwalletflag", "SetWalletFlag", "set_wallet_flag"), Method::new_modelled("signmessage", "SignMessage", "sign_message"), Method::new_modelled( @@ -181,8 +181,8 @@ pub const METHODS: &[Method] = &[ ), Method::new_modelled("walletdisplayaddress", "WalletDisplayAddress", "wallet_display_address"), Method::new_nothing("walletlock", "wallet_lock"), - Method::new_nothing("walletpassphrase", "wallet_passphrase"), - Method::new_nothing("walletpassphrasechange", "wallet_passphrase_change"), + Method::new_no_model("walletpassphrase", "WalletPassPhrase", "wallet_passphrase"), + Method::new_no_model("walletpassphrasechange", "WalletPassPhraseChange", "wallet_passphrase_change"), Method::new_modelled("walletprocesspsbt", "WalletProcessPsbt", "wallet_process_psbt"), Method::new_no_model("getzmqnotifications", "GetZmqNotifications", "get_zmq_notifications"), ];