diff --git a/client/src/client_sync/v17/mod.rs b/client/src/client_sync/v17/mod.rs index 240f14f0..58215d5c 100644 --- a/client/src/client_sync/v17/mod.rs +++ b/client/src/client_sync/v17/mod.rs @@ -12,6 +12,7 @@ pub mod network; pub mod raw_transactions; pub mod util; pub mod wallet; +pub mod zmq; use std::collections::{BTreeMap, HashMap}; use std::path::Path; @@ -159,6 +160,9 @@ crate::impl_client_v17__wallet_passphrase!(); crate::impl_client_v17__wallet_passphrase_change!(); crate::impl_client_v17__wallet_process_psbt!(); +// == Zmq == +crate::impl_client_v17__get_zmq_notifications!(); + /// Argument to the `Client::get_new_address_with_type` function. /// /// For Core versions 0.17 through to v22. For Core v23 and onwards use `v23::AddressType`. diff --git a/client/src/client_sync/v17/wallet.rs b/client/src/client_sync/v17/wallet.rs index a9332c98..75f39712 100644 --- a/client/src/client_sync/v17/wallet.rs +++ b/client/src/client_sync/v17/wallet.rs @@ -560,7 +560,11 @@ macro_rules! impl_client_v17__send_many { impl Client { pub fn send_many(&self, amounts: BTreeMap) -> Result { let dummy = ""; // Must be set to "" for backwards compatibility. - self.call("sendmany", &[into_json(dummy)?, into_json(amounts)?]) + let amount_btc: BTreeMap = amounts + .into_iter() + .map(|(addr, amount)| (addr.to_string(), amount.to_btc())) + .collect(); + self.call("sendmany", &[into_json(dummy)?, into_json(amount_btc)?]) } } }; diff --git a/client/src/client_sync/v17/zmq.rs b/client/src/client_sync/v17/zmq.rs new file mode 100644 index 00000000..60125dfd --- /dev/null +++ b/client/src/client_sync/v17/zmq.rs @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: CC0-1.0 + +//! Macros for implementing JSON-RPC methods for the `== Zmq ==` section (v0.17). + +/// Implements Bitcoin Core JSON-RPC API method `getzmqnotifications`. +#[macro_export] +macro_rules! impl_client_v17__get_zmq_notifications { + () => { + impl Client { + pub fn get_zmq_notifications(&self) -> Result> { + self.call("getzmqnotifications", &[]) + } + } + }; +} diff --git a/client/src/client_sync/v18/mod.rs b/client/src/client_sync/v18/mod.rs index b5ad837f..7a806ccd 100644 --- a/client/src/client_sync/v18/mod.rs +++ b/client/src/client_sync/v18/mod.rs @@ -175,3 +175,6 @@ crate::impl_client_v17__wallet_lock!(); crate::impl_client_v17__wallet_passphrase!(); crate::impl_client_v17__wallet_passphrase_change!(); crate::impl_client_v17__wallet_process_psbt!(); + +// == Zmq == +crate::impl_client_v17__get_zmq_notifications!(); diff --git a/client/src/client_sync/v19/mod.rs b/client/src/client_sync/v19/mod.rs index 153ea3f8..7cf1d16e 100644 --- a/client/src/client_sync/v19/mod.rs +++ b/client/src/client_sync/v19/mod.rs @@ -172,3 +172,6 @@ crate::impl_client_v17__wallet_lock!(); crate::impl_client_v17__wallet_passphrase!(); crate::impl_client_v17__wallet_passphrase_change!(); crate::impl_client_v17__wallet_process_psbt!(); + +// == Zmq == +crate::impl_client_v17__get_zmq_notifications!(); diff --git a/client/src/client_sync/v20/mod.rs b/client/src/client_sync/v20/mod.rs index 1e2bd38e..21424320 100644 --- a/client/src/client_sync/v20/mod.rs +++ b/client/src/client_sync/v20/mod.rs @@ -172,3 +172,6 @@ crate::impl_client_v17__wallet_lock!(); crate::impl_client_v17__wallet_passphrase!(); crate::impl_client_v17__wallet_passphrase_change!(); crate::impl_client_v17__wallet_process_psbt!(); + +// == Zmq == +crate::impl_client_v17__get_zmq_notifications!(); diff --git a/client/src/client_sync/v21/mod.rs b/client/src/client_sync/v21/mod.rs index 9f54068b..c2ada750 100644 --- a/client/src/client_sync/v21/mod.rs +++ b/client/src/client_sync/v21/mod.rs @@ -172,6 +172,7 @@ crate::impl_client_v17__remove_pruned_funds!(); crate::impl_client_v17__rescan_blockchain!(); crate::impl_client_v21__send!(); crate::impl_client_v17__send_many!(); +crate::impl_client_v21__send_many_verbose!(); crate::impl_client_v17__send_to_address!(); crate::impl_client_v17__set_hd_seed!(); crate::impl_client_v17__set_tx_fee!(); @@ -186,6 +187,9 @@ crate::impl_client_v17__wallet_passphrase!(); crate::impl_client_v17__wallet_passphrase_change!(); crate::impl_client_v17__wallet_process_psbt!(); +// == Zmq == +crate::impl_client_v17__get_zmq_notifications!(); + /// Request object for the `importdescriptors` method. #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[serde(deny_unknown_fields)] diff --git a/client/src/client_sync/v21/wallet.rs b/client/src/client_sync/v21/wallet.rs index 7a832e6a..43f344b5 100644 --- a/client/src/client_sync/v21/wallet.rs +++ b/client/src/client_sync/v21/wallet.rs @@ -98,6 +98,48 @@ macro_rules! impl_client_v21__send { }; } +/// Implements Bitcoin Core JSON-RPC API method `sendmany` with `verbose=true` (v21+). +#[macro_export] +macro_rules! impl_client_v21__send_many_verbose { + () => { + impl Client { + pub fn send_many_verbose( + &self, + amounts: BTreeMap, + ) -> Result { + let dummy = ""; // Backwards compatibility dummy. + let amount_btc: BTreeMap = amounts + .into_iter() + .map(|(addr, amount)| (addr.to_string(), amount.to_btc())) + .collect(); + let minconf = 1u64; + let comment = ""; + let subtract_fee_from: Vec = Vec::new(); + let replaceable = true; + let conf_target = 1u64; + let estimate_mode = "unset"; + let fee_rate = serde_json::Value::Null; + let verbose = true; + self.call( + "sendmany", + &[ + into_json(dummy)?, + into_json(amount_btc)?, + minconf.into(), + comment.into(), + into_json(subtract_fee_from)?, + replaceable.into(), + conf_target.into(), + estimate_mode.into(), + fee_rate, + verbose.into(), + ], + ) + } + } + }; +} + /// Implements Bitcoin Core JSON-RPC API method `unloadwallet`. #[macro_export] macro_rules! impl_client_v21__unload_wallet { diff --git a/client/src/client_sync/v22/mod.rs b/client/src/client_sync/v22/mod.rs index bfa0c1e0..6d32b66f 100644 --- a/client/src/client_sync/v22/mod.rs +++ b/client/src/client_sync/v22/mod.rs @@ -174,6 +174,7 @@ crate::impl_client_v17__remove_pruned_funds!(); crate::impl_client_v17__rescan_blockchain!(); crate::impl_client_v21__send!(); crate::impl_client_v17__send_many!(); +crate::impl_client_v21__send_many_verbose!(); crate::impl_client_v17__send_to_address!(); crate::impl_client_v17__set_hd_seed!(); crate::impl_client_v17__set_tx_fee!(); @@ -188,3 +189,6 @@ crate::impl_client_v17__wallet_lock!(); crate::impl_client_v17__wallet_passphrase!(); crate::impl_client_v17__wallet_passphrase_change!(); crate::impl_client_v17__wallet_process_psbt!(); + +// == Zmq == +crate::impl_client_v17__get_zmq_notifications!(); diff --git a/client/src/client_sync/v23/mod.rs b/client/src/client_sync/v23/mod.rs index 96272f7f..8cc0102e 100644 --- a/client/src/client_sync/v23/mod.rs +++ b/client/src/client_sync/v23/mod.rs @@ -179,6 +179,7 @@ crate::impl_client_v17__rescan_blockchain!(); crate::impl_client_v23__restore_wallet!(); crate::impl_client_v21__send!(); crate::impl_client_v17__send_many!(); +crate::impl_client_v21__send_many_verbose!(); crate::impl_client_v17__send_to_address!(); crate::impl_client_v17__set_hd_seed!(); crate::impl_client_v17__set_tx_fee!(); @@ -194,6 +195,9 @@ crate::impl_client_v17__wallet_passphrase!(); crate::impl_client_v17__wallet_passphrase_change!(); crate::impl_client_v17__wallet_process_psbt!(); +// == Zmq == +crate::impl_client_v17__get_zmq_notifications!(); + /// Argument to the `Client::get_new_address_with_type` function. /// /// For Core v23 and onwards. For earlier versions use `v17::AddressType`. diff --git a/client/src/client_sync/v24/mod.rs b/client/src/client_sync/v24/mod.rs index ed063ec8..49f4a804 100644 --- a/client/src/client_sync/v24/mod.rs +++ b/client/src/client_sync/v24/mod.rs @@ -182,6 +182,7 @@ crate::impl_client_v23__restore_wallet!(); crate::impl_client_v21__send!(); crate::impl_client_v24__send_all!(); crate::impl_client_v17__send_many!(); +crate::impl_client_v21__send_many_verbose!(); crate::impl_client_v17__send_to_address!(); crate::impl_client_v17__set_hd_seed!(); crate::impl_client_v17__set_tx_fee!(); @@ -197,3 +198,6 @@ crate::impl_client_v17__wallet_lock!(); crate::impl_client_v17__wallet_passphrase!(); crate::impl_client_v17__wallet_passphrase_change!(); crate::impl_client_v17__wallet_process_psbt!(); + +// == Zmq == +crate::impl_client_v17__get_zmq_notifications!(); diff --git a/client/src/client_sync/v25/mod.rs b/client/src/client_sync/v25/mod.rs index 0eb9c5b6..36ecc2cc 100644 --- a/client/src/client_sync/v25/mod.rs +++ b/client/src/client_sync/v25/mod.rs @@ -183,6 +183,7 @@ crate::impl_client_v23__restore_wallet!(); crate::impl_client_v21__send!(); crate::impl_client_v24__send_all!(); crate::impl_client_v17__send_many!(); +crate::impl_client_v21__send_many_verbose!(); crate::impl_client_v17__send_to_address!(); crate::impl_client_v17__set_hd_seed!(); crate::impl_client_v17__set_tx_fee!(); @@ -198,3 +199,6 @@ crate::impl_client_v17__wallet_lock!(); crate::impl_client_v17__wallet_passphrase!(); crate::impl_client_v17__wallet_passphrase_change!(); crate::impl_client_v17__wallet_process_psbt!(); + +// == Zmq == +crate::impl_client_v17__get_zmq_notifications!(); diff --git a/client/src/client_sync/v26/mod.rs b/client/src/client_sync/v26/mod.rs index bae0cb3c..f7fd02f2 100644 --- a/client/src/client_sync/v26/mod.rs +++ b/client/src/client_sync/v26/mod.rs @@ -192,6 +192,7 @@ crate::impl_client_v23__restore_wallet!(); crate::impl_client_v21__send!(); crate::impl_client_v24__send_all!(); crate::impl_client_v17__send_many!(); +crate::impl_client_v21__send_many_verbose!(); crate::impl_client_v17__send_to_address!(); crate::impl_client_v17__set_hd_seed!(); crate::impl_client_v17__set_tx_fee!(); @@ -207,3 +208,6 @@ crate::impl_client_v17__wallet_lock!(); crate::impl_client_v17__wallet_passphrase!(); crate::impl_client_v17__wallet_passphrase_change!(); crate::impl_client_v17__wallet_process_psbt!(); + +// == Zmq == +crate::impl_client_v17__get_zmq_notifications!(); diff --git a/client/src/client_sync/v27/mod.rs b/client/src/client_sync/v27/mod.rs index 0a75a1c8..a4c9f449 100644 --- a/client/src/client_sync/v27/mod.rs +++ b/client/src/client_sync/v27/mod.rs @@ -186,6 +186,7 @@ crate::impl_client_v23__restore_wallet!(); crate::impl_client_v21__send!(); crate::impl_client_v24__send_all!(); crate::impl_client_v17__send_many!(); +crate::impl_client_v21__send_many_verbose!(); crate::impl_client_v17__send_to_address!(); crate::impl_client_v17__set_hd_seed!(); crate::impl_client_v17__set_tx_fee!(); @@ -201,3 +202,6 @@ crate::impl_client_v17__wallet_lock!(); crate::impl_client_v17__wallet_passphrase!(); crate::impl_client_v17__wallet_passphrase_change!(); crate::impl_client_v17__wallet_process_psbt!(); + +// == Zmq == +crate::impl_client_v17__get_zmq_notifications!(); diff --git a/client/src/client_sync/v28/mod.rs b/client/src/client_sync/v28/mod.rs index 45011ec5..5c2c24bf 100644 --- a/client/src/client_sync/v28/mod.rs +++ b/client/src/client_sync/v28/mod.rs @@ -191,6 +191,7 @@ crate::impl_client_v23__restore_wallet!(); crate::impl_client_v21__send!(); crate::impl_client_v24__send_all!(); crate::impl_client_v17__send_many!(); +crate::impl_client_v21__send_many_verbose!(); crate::impl_client_v17__send_to_address!(); crate::impl_client_v17__set_hd_seed!(); crate::impl_client_v17__set_tx_fee!(); @@ -206,3 +207,6 @@ crate::impl_client_v17__wallet_lock!(); crate::impl_client_v17__wallet_passphrase!(); crate::impl_client_v17__wallet_passphrase_change!(); crate::impl_client_v17__wallet_process_psbt!(); + +// == Zmq == +crate::impl_client_v17__get_zmq_notifications!(); diff --git a/client/src/client_sync/v29/mod.rs b/client/src/client_sync/v29/mod.rs index 696beece..d8754589 100644 --- a/client/src/client_sync/v29/mod.rs +++ b/client/src/client_sync/v29/mod.rs @@ -191,6 +191,7 @@ crate::impl_client_v23__restore_wallet!(); crate::impl_client_v21__send!(); crate::impl_client_v24__send_all!(); crate::impl_client_v17__send_many!(); +crate::impl_client_v21__send_many_verbose!(); crate::impl_client_v17__send_to_address!(); crate::impl_client_v17__set_hd_seed!(); crate::impl_client_v17__set_tx_fee!(); @@ -207,6 +208,9 @@ crate::impl_client_v17__wallet_passphrase!(); crate::impl_client_v17__wallet_passphrase_change!(); crate::impl_client_v17__wallet_process_psbt!(); +// == Zmq == +crate::impl_client_v17__get_zmq_notifications!(); + /// Arg for the `getblocktemplate` method. (v29+). #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default)] pub struct TemplateRequest { diff --git a/integration_test/tests/wallet.rs b/integration_test/tests/wallet.rs index e2cdcb87..821524d2 100644 --- a/integration_test/tests/wallet.rs +++ b/integration_test/tests/wallet.rs @@ -390,6 +390,31 @@ fn wallet__get_unconfirmed_balance__modelled() { model.unwrap(); } +#[test] +fn wallet__get_wallet_info__modelled() { + let node = Node::with_wallet(Wallet::Default, &[]); + node.mine_a_block(); + + let json: GetWalletInfo = node.client.get_wallet_info().expect("getwalletinfo"); + let model: Result = json.into_model(); + let wallet_info = model.unwrap(); + + assert!(!wallet_info.wallet_name.is_empty()); + + #[cfg(not(feature = "v18_and_below"))] + { + assert!(wallet_info.avoid_reuse.is_some()); + assert!(wallet_info.scanning.is_some()); + } + + #[cfg(not(feature = "v25_and_below"))] + { + let last_processed = wallet_info.last_processed_block.as_ref().expect("last_processed_block"); + let best_hash = node.client.best_block_hash().expect("best_block_hash"); + assert_eq!(last_processed.hash, best_hash); + } +} + #[test] fn wallet__import_address() { let node = match () { @@ -857,6 +882,37 @@ fn wallet__unload_wallet() { create_load_unload_wallet(); } +#[test] +fn wallet__send_many__modelled() { + let node = Node::with_wallet(Wallet::Default, &[]); + node.fund_wallet(); + + let addr1 = node.client.new_address().expect("newaddress"); + let addr2 = node.client.new_address().expect("newaddress"); + + let mut amounts = BTreeMap::new(); + amounts.insert(addr1, Amount::from_sat(100_000)); + amounts.insert(addr2, Amount::from_sat(100_000)); + + let json: SendMany = node.client.send_many(amounts.clone()).expect("sendmany"); + let model: Result = json.into_model(); + let txid = model.unwrap().0; + + assert_eq!(txid.to_string().len(), 64); + + #[cfg(not(feature = "v20_and_below"))] + { + let json_verbose: SendManyVerbose = node + .client + .send_many_verbose(amounts) + .expect("sendmany verbose"); + let model_verbose: Result = json_verbose.into_model(); + let verbose = model_verbose.unwrap(); + assert_eq!(verbose.txid.to_string().len(), 64); + assert_eq!(verbose.fee_reason, "Fallback fee"); + } +} + #[cfg(not(feature = "v20_and_below"))] #[test] fn wallet__send__modelled() { diff --git a/integration_test/tests/zmq.rs b/integration_test/tests/zmq.rs new file mode 100644 index 00000000..fc1e1c30 --- /dev/null +++ b/integration_test/tests/zmq.rs @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: CC0-1.0 + +//! Tests for methods found under the `== Zmq ==` section of the API docs. + +#![allow(non_snake_case)] // Test names intentionally use double underscore. +#![allow(unused_imports)] // Because of feature gated tests. + +use integration_test::{Node, Wallet, NodeExt as _}; +use node::vtype::*; // All the version specific types. + +#[test] +#[cfg(not(feature = "v17"))] +fn zmq__get_zmq_notifications__modelled() { + // Start node with a ZMQ notification enabled so we have at least one entry. + // Using hashblock as it is lightweight. + let node = Node::with_wallet(Wallet::Default, &["-zmqpubhashblock=tcp://127.0.0.1:29000"]); + + let list: Vec = node.client.get_zmq_notifications().expect("getzmqnotifications"); + let zmq_notification = &list[0]; + assert_eq!(zmq_notification.type_, "pubhashblock"); + assert_eq!(zmq_notification.address, "tcp://127.0.0.1:29000"); +} diff --git a/types/src/model/mod.rs b/types/src/model/mod.rs index 5b2bb536..59200227 100644 --- a/types/src/model/mod.rs +++ b/types/src/model/mod.rs @@ -55,13 +55,13 @@ pub use self::{ CreateWallet, DumpPrivKey, GetAddressInfo, GetAddressInfoEmbedded, GetAddressesByLabel, GetBalance, GetBalances, GetBalancesMine, GetBalancesWatchOnly, GetHdKeys, GetNewAddress, GetRawChangeAddress, GetReceivedByAddress, GetReceivedByLabel, GetTransaction, - GetTransactionDetail, GetUnconfirmedBalance, GetWalletInfo, HdKey, HdKeyDescriptor, - LastProcessedBlock, ListAddressGroupings, ListAddressGroupingsItem, ListLockUnspent, - ListLockUnspentItem, ListReceivedByAddress, ListReceivedByAddressItem, ListReceivedByLabel, - ListReceivedByLabelItem, ListSinceBlock, ListSinceBlockTransaction, ListTransactions, - ListTransactionsItem, ListUnspent, ListUnspentItem, ListWallets, LoadWallet, PsbtBumpFee, - RescanBlockchain, ScriptType, Send, SendAll, SendMany, SendToAddress, SignMessage, - SimulateRawTransaction, TransactionCategory, UnloadWallet, WalletCreateFundedPsbt, - WalletDisplayAddress, WalletProcessPsbt, + GetTransactionDetail, GetUnconfirmedBalance, GetWalletInfo, GetWalletInfoScanning, HdKey, + HdKeyDescriptor, LastProcessedBlock, ListAddressGroupings, ListAddressGroupingsItem, + ListLockUnspent, ListLockUnspentItem, ListReceivedByAddress, ListReceivedByAddressItem, + ListReceivedByLabel, ListReceivedByLabelItem, ListSinceBlock, ListSinceBlockTransaction, + ListTransactions, ListTransactionsItem, ListUnspent, ListUnspentItem, ListWallets, + LoadWallet, PsbtBumpFee, RescanBlockchain, ScriptType, Send, SendAll, SendMany, + SendManyVerbose, SendToAddress, SignMessage, SimulateRawTransaction, TransactionCategory, + UnloadWallet, WalletCreateFundedPsbt, WalletDisplayAddress, WalletProcessPsbt, }, }; diff --git a/types/src/model/wallet.rs b/types/src/model/wallet.rs index 0b59a125..889d4895 100644 --- a/types/src/model/wallet.rs +++ b/types/src/model/wallet.rs @@ -455,6 +455,8 @@ pub struct GetWalletInfo { pub wallet_name: String, /// The wallet version. pub wallet_version: u32, + /// Database format. v21 and later only. + pub format: Option, /// The total confirmed balance of the wallet in BTC. pub balance: Amount, /// The total unconfirmed balance of the wallet in BTC. @@ -472,13 +474,40 @@ pub struct GetWalletInfo { pub keypool_size_hd_internal: u32, /// The timestamp in seconds since epoch (midnight Jan 1 1970 GMT) that the wallet is unlocked /// for transfers, or 0 if the wallet is locked. - pub unlocked_until: u32, + pub unlocked_until: Option, /// The transaction fee configuration. pub pay_tx_fee: Option, /// The Hash160 of the HD seed (only present when HD is enabled). pub hd_seed_id: Option, /// If privatekeys are disabled for this wallet (enforced watch-only wallet). pub private_keys_enabled: bool, + /// Whether this wallet tracks clean/dirty coins in terms of reuse. v19 and later only. + pub avoid_reuse: Option, + /// Current scanning details, or false if no scan is in progress. v19 and later only. + pub scanning: Option, + /// Whether wallet uses descriptors. v21 and later only. + pub descriptors: Option, + /// Whether this wallet is configured to use an external signer such as a hardware wallet. v23 and later only. + pub external_signer: Option, + /// Whether this wallet intentionally does not contain any keys, scripts, or descriptors. v26 and later only. + pub blank: Option, + /// The start time for blocks scanning. v26 and later only. + pub birthtime: Option, + /// Hash and height of the block this information was generated on. v26 and later only. + pub last_processed_block: Option, +} + +/// Models the `scanning` field of `getwalletinfo` (v19+). When not scanning Core returns `false`. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[serde(untagged)] +pub enum GetWalletInfoScanning { + Details { + /// Elapsed seconds since scan start. + duration: u64, + /// Scanning progress percentage [0.0, 1.0]. + progress: f64, + }, + NotScanning(bool), } /// Models the result of JSON-RPC method `listaddressgroupings`. @@ -808,6 +837,16 @@ pub struct SendAll { #[serde(deny_unknown_fields)] pub struct SendMany(pub Txid); +/// Models the verbose result of JSON-RPC method `sendmany` when `verbose=true`. +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] +pub struct SendManyVerbose { + /// The transaction id for the send. Only 1 transaction is created regardless of the number of addresses. + pub txid: Txid, + /// The transaction fee reason. + pub fee_reason: String, +} + /// Models the result of JSON-RPC method `sendtoaddress`. #[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] #[serde(deny_unknown_fields)] diff --git a/types/src/v17/mod.rs b/types/src/v17/mod.rs index a60a275d..b8eae11b 100644 --- a/types/src/v17/mod.rs +++ b/types/src/v17/mod.rs @@ -171,7 +171,7 @@ //! | getreceivedbyaddress | version + model | | //! | gettransaction | version + model | | //! | getunconfirmedbalance | version + model | | -//! | getwalletinfo | version + model | UNTESTED | +//! | getwalletinfo | version + model | | //! | importaddress | returns nothing | | //! | importmulti | version | | //! | importprivkey | returns nothing | | @@ -195,7 +195,7 @@ //! | removeprunedfunds | returns nothing | | //! | rescanblockchain | version + model | | //! | sendfrom | returns nothing | | -//! | sendmany | version + model | UNTESTED | +//! | sendmany | version + model | | //! | sendtoaddress | version + model | | //! | setaccount | returns nothing | | //! | sethdseed | returns nothing | | @@ -216,7 +216,7 @@ //! //! | JSON-RPC Method Name | Returns | Notes | //! |:-----------------------------------|:---------------:|:--------------------------------------:| -//! | getzmqnotifications | version | UNTESTED | +//! | getzmqnotifications | version | | //! //! diff --git a/types/src/v17/wallet/into.rs b/types/src/v17/wallet/into.rs index d6bb0ee9..87fe6615 100644 --- a/types/src/v17/wallet/into.rs +++ b/types/src/v17/wallet/into.rs @@ -437,6 +437,7 @@ impl GetWalletInfo { Ok(model::GetWalletInfo { wallet_name: self.wallet_name, wallet_version, + format: None, balance, unconfirmed_balance, immature_balance, @@ -448,6 +449,13 @@ impl GetWalletInfo { pay_tx_fee, hd_seed_id, private_keys_enabled: self.private_keys_enabled, + avoid_reuse: None, + scanning: None, + descriptors: None, + external_signer: None, + blank: None, + birthtime: None, + last_processed_block: None, }) } } diff --git a/types/src/v17/wallet/mod.rs b/types/src/v17/wallet/mod.rs index e47cea70..a06200e7 100644 --- a/types/src/v17/wallet/mod.rs +++ b/types/src/v17/wallet/mod.rs @@ -549,7 +549,7 @@ pub struct GetWalletInfo { pub keypool_size_hd_internal: i64, /// The timestamp in seconds since epoch (midnight Jan 1 1970 GMT) that the wallet is unlocked /// for transfers, or 0 if the wallet is locked. - pub unlocked_until: u32, + pub unlocked_until: Option, /// The transaction fee configuration, set in BTC/kB. #[serde(rename = "paytxfee")] pub pay_tx_fee: f64, diff --git a/types/src/v18/mod.rs b/types/src/v18/mod.rs index 62dda715..91762f42 100644 --- a/types/src/v18/mod.rs +++ b/types/src/v18/mod.rs @@ -175,7 +175,7 @@ //! | getreceivedbylabel | version + model | | //! | gettransaction | version + model | | //! | getunconfirmedbalance | version + model | | -//! | getwalletinfo | version + model | UNTESTED | +//! | getwalletinfo | version + model | | //! | importaddress | returns nothing | | //! | importmulti | version | | //! | importprivkey | returns nothing | | @@ -197,7 +197,7 @@ //! | lockunspent | version | | //! | removeprunedfunds | returns nothing | | //! | rescanblockchain | version + model | | -//! | sendmany | version + model | UNTESTED | +//! | sendmany | version + model | | //! | sendtoaddress | version + model | | //! | sethdseed | returns nothing | | //! | setlabel | returns nothing | | @@ -218,7 +218,7 @@ //! //! | JSON-RPC Method Name | Returns | Notes | //! |:-----------------------------------|:---------------:|:--------------------------------------:| -//! | getzmqnotifications | version | UNTESTED | +//! | getzmqnotifications | version | | //! //! @@ -229,6 +229,7 @@ mod network; mod raw_transactions; mod util; mod wallet; +mod zmq; #[doc(inline)] pub use self::{ @@ -245,10 +246,11 @@ pub use self::{ util::{DeriveAddresses, GetDescriptorInfo}, wallet::{ GetAddressInfo, GetAddressInfoEmbedded, GetAddressInfoError, GetReceivedByLabel, - ImportMulti, ImportMultiEntry, JsonRpcError, ListReceivedByAddress, + GetWalletInfo, ImportMulti, ImportMultiEntry, JsonRpcError, ListReceivedByAddress, ListReceivedByAddressItem, ListReceivedByLabel, ListReceivedByLabelError, ListUnspent, ListUnspentItem, ListWalletDir, ListWalletDirWallet, }, + zmq::GetZmqNotifications, }; #[doc(inline)] pub use crate::v17::{ @@ -270,19 +272,18 @@ pub use crate::v17::{ GetRawMempoolVerbose, GetRawTransaction, GetRawTransactionVerbose, GetRawTransactionVerboseError, GetReceivedByAddress, GetTransaction, GetTransactionDetail, GetTransactionDetailError, GetTransactionError, GetTxOut, GetTxOutError, GetTxOutSetInfo, - GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfo, GetWalletInfoError, - GetZmqNotifications, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, - ListBanned, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, - ListReceivedByAddressError, ListSinceBlock, ListSinceBlockError, ListSinceBlockTransaction, - ListSinceBlockTransactionError, ListTransactions, ListTransactionsItem, - ListTransactionsItemError, ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, - Logging, MapMempoolEntryError, MempoolAcceptance, MempoolEntryError, MempoolEntryFees, - MempoolEntryFeesError, PruneBlockchain, PsbtInput, PsbtOutput, PsbtScript, RawTransaction, - RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, - SendMany, SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignFail, - SignFailError, SignMessage, SignMessageWithPrivKey, SignRawTransaction, - SignRawTransactionError, Softfork, SoftforkReject, TestMempoolAccept, TransactionCategory, - UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, - VerifyTxOutProof, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WalletProcessPsbt, - WitnessUtxo, + GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings, + ListAddressGroupingsError, ListAddressGroupingsItem, ListBanned, ListLabels, ListLockUnspent, + ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListSinceBlock, + ListSinceBlockError, ListSinceBlockTransaction, ListSinceBlockTransactionError, + ListTransactions, ListTransactionsItem, ListTransactionsItemError, ListUnspentItemError, + ListWallets, LoadWallet, LockUnspent, Locked, Logging, MapMempoolEntryError, MempoolAcceptance, + MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, PruneBlockchain, PsbtInput, + PsbtOutput, PsbtScript, RawTransaction, RawTransactionError, RawTransactionInput, + RawTransactionOutput, RescanBlockchain, ScriptType, SendMany, SendRawTransaction, + SendToAddress, SetNetworkActive, SetTxFee, SignFail, SignFailError, SignMessage, + SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, Softfork, SoftforkReject, + TestMempoolAccept, TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, + VerifyChain, VerifyMessage, VerifyTxOutProof, WalletCreateFundedPsbt, + WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo, }; diff --git a/types/src/v18/wallet/into.rs b/types/src/v18/wallet/into.rs index 1cb2c06e..41cb98cf 100644 --- a/types/src/v18/wallet/into.rs +++ b/types/src/v18/wallet/into.rs @@ -10,9 +10,10 @@ use bitcoin::{ use super::{ GetAddressInfo, GetAddressInfoEmbedded, GetAddressInfoEmbeddedError, GetAddressInfoError, - GetReceivedByLabel, ListReceivedByAddress, ListReceivedByAddressError, - ListReceivedByAddressItem, ListReceivedByLabel, ListReceivedByLabelError, - ListReceivedByLabelItem, ListUnspent, ListUnspentItem, ListUnspentItemError, + GetReceivedByLabel, GetWalletInfo, GetWalletInfoError, ListReceivedByAddress, + ListReceivedByAddressError, ListReceivedByAddressItem, ListReceivedByLabel, + ListReceivedByLabelError, ListReceivedByLabelItem, ListUnspent, ListUnspentItem, + ListUnspentItemError, }; use crate::model; @@ -166,6 +167,52 @@ impl GetReceivedByLabel { } } +impl GetWalletInfo { + /// Converts version specific type to a version nonspecific, more strongly typed type. + pub fn into_model(self) -> Result { + use GetWalletInfoError as E; + + let wallet_version = crate::to_u32(self.wallet_version, "wallet_version")?; + let balance = Amount::from_btc(self.balance).map_err(E::Balance)?; + let unconfirmed_balance = + Amount::from_btc(self.unconfirmed_balance).map_err(E::UnconfirmedBalance)?; + let immature_balance = + Amount::from_btc(self.immature_balance).map_err(E::ImmatureBalance)?; + let tx_count = crate::to_u32(self.tx_count, "tx_count")?; + let keypool_oldest = crate::to_u32(self.keypool_oldest, "keypoo_oldest")?; + let keypool_size = crate::to_u32(self.keypool_size, "keypoo_size")?; + let keypool_size_hd_internal = + crate::to_u32(self.keypool_size_hd_internal, "keypoo_size_hd_internal")?; + let pay_tx_fee = crate::btc_per_kb(self.pay_tx_fee).map_err(E::PayTxFee)?; + let hd_seed_id = + self.hd_seed_id.map(|s| s.parse::()).transpose().map_err(E::HdSeedId)?; + + Ok(model::GetWalletInfo { + wallet_name: self.wallet_name, + wallet_version, + format: None, + balance, + unconfirmed_balance, + immature_balance, + tx_count, + keypool_oldest, + keypool_size, + keypool_size_hd_internal, + unlocked_until: self.unlocked_until, + pay_tx_fee, + hd_seed_id, + private_keys_enabled: self.private_keys_enabled, + avoid_reuse: None, + scanning: None, + descriptors: None, + external_signer: None, + blank: None, + birthtime: None, + last_processed_block: None, + }) + } +} + impl ListReceivedByAddress { /// Converts version specific type to a version nonspecific, more strongly typed type. pub fn into_model(self) -> Result { diff --git a/types/src/v18/wallet/mod.rs b/types/src/v18/wallet/mod.rs index 3c7f6859..b975a7f5 100644 --- a/types/src/v18/wallet/mod.rs +++ b/types/src/v18/wallet/mod.rs @@ -11,8 +11,8 @@ use serde::{Deserialize, Serialize}; pub use self::error::{GetAddressInfoError, ListReceivedByLabelError}; pub use super::{ - GetAddressInfoEmbeddedError, GetAddressInfoLabel, ListReceivedByAddressError, - ListUnspentItemError, ScriptType, + GetAddressInfoEmbeddedError, GetAddressInfoLabel, GetWalletInfoError, + ListReceivedByAddressError, ListUnspentItemError, ScriptType, }; /// Result of the JSON-RPC method `getaddressinfo`. @@ -152,6 +152,51 @@ pub struct GetAddressInfoEmbedded { #[serde(deny_unknown_fields)] pub struct GetReceivedByLabel(pub f64); +/// Result of the JSON-RPC method `getwalletinfo`. +/// +/// > getwalletinfo +/// > Returns an object containing various wallet state info. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] +pub struct GetWalletInfo { + /// The wallet name. + #[serde(rename = "walletname")] + pub wallet_name: String, + /// The wallet version. + #[serde(rename = "walletversion")] + pub wallet_version: i64, + /// The total confirmed balance of the wallet in BTC. + pub balance: f64, + /// The total unconfirmed balance of the wallet in BTC. + pub unconfirmed_balance: f64, + /// The total immature balance of the wallet in BTC. + pub immature_balance: f64, + /// The total number of transactions in the wallet + #[serde(rename = "txcount")] + pub tx_count: i64, + /// The timestamp (seconds since Unix epoch) of the oldest pre-generated key in the key pool. + #[serde(rename = "keypoololdest")] + pub keypool_oldest: i64, + /// How many new keys are pre-generated (only counts external keys). + #[serde(rename = "keypoolsize")] + pub keypool_size: i64, + /// How many new keys are pre-generated for internal use (used for change outputs, only appears + /// if the wallet is using this feature, otherwise external keys are used). + #[serde(rename = "keypoolsize_hd_internal")] + pub keypool_size_hd_internal: i64, + /// The timestamp in seconds since epoch (midnight Jan 1 1970 GMT) that the wallet is unlocked + /// for transfers, or 0 if the wallet is locked. + pub unlocked_until: Option, + /// The transaction fee configuration, set in BTC/kB. + #[serde(rename = "paytxfee")] + pub pay_tx_fee: f64, + /// The Hash160 of the HD seed (only present when HD is enabled). + #[serde(rename = "hdseedid")] + pub hd_seed_id: Option, + /// If privatekeys are disabled for this wallet (enforced watch-only wallet). + pub private_keys_enabled: bool, +} + /// Result of JSON-RPC method `importmulti`. /// /// > importmulti requests ( options ) diff --git a/types/src/v18/zmq.rs b/types/src/v18/zmq.rs new file mode 100644 index 00000000..85492fe0 --- /dev/null +++ b/types/src/v18/zmq.rs @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: CC0-1.0 + +//! The JSON-RPC API for Bitcoin Core `v0.18` - zmq. +//! +//! Types for methods found under the `== Zmq ==` section of the API docs. + +use serde::{Deserialize, Serialize}; + +/// Result of JSON-RPC method `getzmqnotifications`. +/// +///> getzmqnotifications +///> +///> Returns information about the active ZeroMQ notifications. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] +pub struct GetZmqNotifications { + /// Type of notification. + #[serde(rename = "type")] + pub type_: String, + /// Address of the publisher. + pub address: String, + /// Outbound message high water mark. + pub hwm: u64, +} diff --git a/types/src/v19/mod.rs b/types/src/v19/mod.rs index b23e23c8..5eb1b322 100644 --- a/types/src/v19/mod.rs +++ b/types/src/v19/mod.rs @@ -176,7 +176,7 @@ //! | getreceivedbylabel | version + model | | //! | gettransaction | version + model | | //! | getunconfirmedbalance | version + model | | -//! | getwalletinfo | version + model | UNTESTED | +//! | getwalletinfo | version + model | | //! | importaddress | returns nothing | | //! | importmulti | version | | //! | importprivkey | returns nothing | | @@ -198,7 +198,7 @@ //! | lockunspent | version | | //! | removeprunedfunds | returns nothing | | //! | rescanblockchain | version + model | | -//! | sendmany | version + model | UNTESTED | +//! | sendmany | version + model | | //! | sendtoaddress | version + model | | //! | sethdseed | returns nothing | | //! | setlabel | returns nothing | | @@ -220,7 +220,7 @@ //! //! | JSON-RPC Method Name | Returns | Notes | //! |:-----------------------------------|:---------------:|:--------------------------------------:| -//! | getzmqnotifications | version | UNTESTED | +//! | getzmqnotifications | version | | //! //! @@ -246,7 +246,7 @@ pub use self::{ util::GetDescriptorInfo, wallet::{ GetBalances, GetBalancesError, GetBalancesMine, GetBalancesWatchOnly, GetTransaction, - SetWalletFlag, + GetWalletInfo, GetWalletInfoScanning, SetWalletFlag, }, }; #[doc(inline)] @@ -268,25 +268,25 @@ pub use crate::v17::{ GetRawMempoolVerbose, GetRawTransaction, GetRawTransactionVerbose, GetRawTransactionVerboseError, GetReceivedByAddress, GetTransactionDetail, GetTransactionDetailError, GetTransactionError, GetTxOut, GetTxOutError, GetTxOutSetInfo, - GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfo, GetWalletInfoError, - GetZmqNotifications, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, - ListBanned, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, - ListReceivedByAddressError, ListSinceBlock, ListSinceBlockError, ListSinceBlockTransaction, - ListSinceBlockTransactionError, ListTransactions, ListTransactionsItem, - ListTransactionsItemError, ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, - Logging, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, - RescanBlockchain, ScriptType, SendMany, SendRawTransaction, SendToAddress, SetNetworkActive, - SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, - SoftforkReject, TestMempoolAccept, TransactionCategory, UploadTarget, ValidateAddress, - ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof, WalletCreateFundedPsbt, + GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings, + ListAddressGroupingsError, ListAddressGroupingsItem, ListBanned, ListLabels, ListLockUnspent, + ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListSinceBlock, + ListSinceBlockError, ListSinceBlockTransaction, ListSinceBlockTransactionError, + ListTransactions, ListTransactionsItem, ListTransactionsItemError, ListUnspentItemError, + ListWallets, LoadWallet, LockUnspent, Locked, Logging, PruneBlockchain, RawTransactionError, + RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendMany, + SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, + SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, SoftforkReject, + TestMempoolAccept, TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, + VerifyChain, VerifyMessage, VerifyTxOutProof, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo, }; #[doc(inline)] pub use crate::v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, AnalyzePsbtInputMissingError, DeriveAddresses, GetAddressInfo, GetAddressInfoEmbedded, - GetAddressInfoError, GetNodeAddresses, GetReceivedByLabel, ImportMulti, ImportMultiEntry, - JoinPsbts, JsonRpcError, ListReceivedByAddress, ListReceivedByAddressItem, ListReceivedByLabel, - ListReceivedByLabelError, ListUnspent, ListUnspentItem, ListWalletDir, ListWalletDirWallet, - NodeAddress, UtxoUpdatePsbt, + GetAddressInfoError, GetNodeAddresses, GetReceivedByLabel, GetZmqNotifications, ImportMulti, + ImportMultiEntry, JoinPsbts, JsonRpcError, ListReceivedByAddress, ListReceivedByAddressItem, + ListReceivedByLabel, ListReceivedByLabelError, ListUnspent, ListUnspentItem, ListWalletDir, + ListWalletDirWallet, NodeAddress, UtxoUpdatePsbt, }; diff --git a/types/src/v19/wallet/into.rs b/types/src/v19/wallet/into.rs index 905e218a..bb873068 100644 --- a/types/src/v19/wallet/into.rs +++ b/types/src/v19/wallet/into.rs @@ -6,7 +6,7 @@ use bitcoin::{Amount, BlockHash, SignedAmount, Transaction, Txid}; use super::{ GetBalances, GetBalancesError, GetBalancesMine, GetBalancesWatchOnly, GetTransaction, - GetTransactionError, + GetTransactionError, GetWalletInfo, GetWalletInfoError, GetWalletInfoScanning, }; use crate::model; @@ -103,3 +103,59 @@ impl GetTransaction { }) } } + +impl GetWalletInfo { + /// Converts version specific type to a version nonspecific, more strongly typed type. + pub fn into_model(self) -> Result { + use GetWalletInfoError as E; + + let wallet_version = crate::to_u32(self.wallet_version, "wallet_version")?; + let balance = Amount::from_btc(self.balance).map_err(E::Balance)?; + let unconfirmed_balance = + Amount::from_btc(self.unconfirmed_balance).map_err(E::UnconfirmedBalance)?; + let immature_balance = + Amount::from_btc(self.immature_balance).map_err(E::ImmatureBalance)?; + let tx_count = crate::to_u32(self.tx_count, "tx_count")?; + let keypool_oldest = crate::to_u32(self.keypool_oldest, "keypoo_oldest")?; + let keypool_size = crate::to_u32(self.keypool_size, "keypoo_size")?; + let keypool_size_hd_internal = + crate::to_u32(self.keypool_size_hd_internal, "keypoo_size_hd_internal")?; + let pay_tx_fee = crate::btc_per_kb(self.pay_tx_fee).map_err(E::PayTxFee)?; + let hd_seed_id = self + .hd_seed_id + .map(|s| s.parse::()) + .transpose() + .map_err(E::HdSeedId)?; + + let scanning = match self.scanning { + GetWalletInfoScanning::Details { duration, progress } => + Some(model::GetWalletInfoScanning::Details { duration, progress }), + GetWalletInfoScanning::NotScanning(b) => + Some(model::GetWalletInfoScanning::NotScanning(b)), + }; + + Ok(model::GetWalletInfo { + wallet_name: self.wallet_name, + wallet_version, + format: None, + balance, + unconfirmed_balance, + immature_balance, + tx_count, + keypool_oldest, + keypool_size, + keypool_size_hd_internal, + unlocked_until: self.unlocked_until, + pay_tx_fee, + hd_seed_id, + private_keys_enabled: self.private_keys_enabled, + avoid_reuse: Some(self.avoid_reuse), + scanning, + descriptors: None, + external_signer: None, + blank: None, + birthtime: None, + last_processed_block: None, + }) + } +} diff --git a/types/src/v19/wallet/mod.rs b/types/src/v19/wallet/mod.rs index 1baaab23..9a48bec3 100644 --- a/types/src/v19/wallet/mod.rs +++ b/types/src/v19/wallet/mod.rs @@ -11,7 +11,7 @@ use bitcoin::Transaction; use serde::{Deserialize, Serialize}; pub use self::error::GetBalancesError; -use super::{Bip125Replaceable, GetTransactionDetail, GetTransactionError}; +use super::{Bip125Replaceable, GetTransactionDetail, GetTransactionError, GetWalletInfoError}; /// Result of the JSON-RPC method `getbalances`. /// @@ -107,6 +107,65 @@ pub struct GetTransaction { pub decoded: Option, } +/// Result of the JSON-RPC method `getwalletinfo`. +/// +/// > getwalletinfo +/// > Returns an object containing various wallet state info. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] +pub struct GetWalletInfo { + /// The wallet name. + #[serde(rename = "walletname")] + pub wallet_name: String, + /// The wallet version. + #[serde(rename = "walletversion")] + pub wallet_version: i64, + /// The total confirmed balance of the wallet in BTC. (DEPRECATED) + pub balance: f64, + /// The total unconfirmed balance of the wallet in BTC. (DEPRECATED) + pub unconfirmed_balance: f64, + /// The total immature balance of the wallet in BTC. (DEPRECATED) + pub immature_balance: f64, + /// The total number of transactions in the wallet + #[serde(rename = "txcount")] + pub tx_count: i64, + /// The timestamp (seconds since Unix epoch) of the oldest pre-generated key in the key pool. + #[serde(rename = "keypoololdest")] + pub keypool_oldest: i64, + /// How many new keys are pre-generated (only counts external keys). + #[serde(rename = "keypoolsize")] + pub keypool_size: i64, + /// How many new keys are pre-generated for internal use (used for change outputs, only appears + /// if the wallet is using this feature, otherwise external keys are used). + #[serde(rename = "keypoolsize_hd_internal")] + pub keypool_size_hd_internal: i64, + /// The timestamp in seconds since epoch (midnight Jan 1 1970 GMT) that the wallet is unlocked + /// for transfers, or 0 if the wallet is locked. + pub unlocked_until: Option, + /// The transaction fee configuration, set in BTC/kB. + #[serde(rename = "paytxfee")] + pub pay_tx_fee: f64, + /// The Hash160 of the HD seed (only present when HD is enabled). + #[serde(rename = "hdseedid")] + pub hd_seed_id: Option, + /// If privatekeys are disabled for this wallet (enforced watch-only wallet). + pub private_keys_enabled: bool, + /// Whether this wallet tracks clean/dirty coins in terms of reuse. + pub avoid_reuse: bool, + /// Current scanning details, or false if no scan is in progress. + pub scanning: GetWalletInfoScanning, +} + +/// The `scanning` field of `GetWalletInfo` in v19. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[serde(untagged)] +pub enum GetWalletInfoScanning { + /// Scanning details. + Details { duration: u64, progress: f64 }, + /// Not scanning (false). + NotScanning(bool), +} + /// Result of the JSON-RPC method `setwalletflag`. /// /// > setwalletflag "flag" ( value ) diff --git a/types/src/v20/mod.rs b/types/src/v20/mod.rs index db662c99..954baf13 100644 --- a/types/src/v20/mod.rs +++ b/types/src/v20/mod.rs @@ -177,7 +177,7 @@ //! | getreceivedbylabel | version + model | | //! | gettransaction | version + model | | //! | getunconfirmedbalance | version + model | | -//! | getwalletinfo | version + model | UNTESTED | +//! | getwalletinfo | version + model | | //! | importaddress | returns nothing | | //! | importmulti | version | | //! | importprivkey | returns nothing | | @@ -199,7 +199,7 @@ //! | lockunspent | version | | //! | removeprunedfunds | returns nothing | | //! | rescanblockchain | version + model | | -//! | sendmany | version + model | UNTESTED | +//! | sendmany | version + model | | //! | sendtoaddress | version + model | | //! | sethdseed | returns nothing | | //! | setlabel | returns nothing | | @@ -221,7 +221,7 @@ //! //! | JSON-RPC Method Name | Returns | Notes | //! |:-----------------------------------|:---------------:|:--------------------------------------:| -//! | getzmqnotifications | version | UNTESTED | +//! | getzmqnotifications | version | | //! //! @@ -262,25 +262,24 @@ pub use crate::{ GetNewAddress, GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, GetRawTransaction, GetRawTransactionVerbose, GetRawTransactionVerboseError, GetReceivedByAddress, GetTransactionDetailError, GetTransactionError, GetTxOut, GetTxOutError, GetTxOutSetInfo, - GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfo, GetWalletInfoError, - GetZmqNotifications, ListAddressGroupings, ListAddressGroupingsError, - ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, - ListLockUnspentItemError, ListReceivedByAddressError, ListSinceBlock, ListSinceBlockError, - ListSinceBlockTransaction, ListSinceBlockTransactionError, ListTransactions, - ListTransactionsItem, ListTransactionsItemError, ListUnspentItemError, ListWallets, - LoadWallet, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, - RawTransactionOutput, RescanBlockchain, ScriptType, SendMany, SendRawTransaction, - SendToAddress, SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, - SignRawTransaction, SignRawTransactionError, SoftforkReject, TestMempoolAccept, - TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, - VerifyMessage, VerifyTxOutProof, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, - WalletProcessPsbt, WitnessUtxo, + GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings, + ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, + ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListSinceBlock, + ListSinceBlockError, ListSinceBlockTransaction, ListSinceBlockTransactionError, + ListTransactions, ListTransactionsItem, ListTransactionsItemError, ListUnspentItemError, + ListWallets, LoadWallet, LockUnspent, Locked, PruneBlockchain, RawTransactionError, + RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendMany, + SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, + SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, SoftforkReject, + TestMempoolAccept, TransactionCategory, UploadTarget, ValidateAddress, + ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof, WalletCreateFundedPsbt, + WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, AnalyzePsbtInputMissingError, DeriveAddresses, GetAddressInfoError, GetNodeAddresses, - GetReceivedByLabel, ImportMulti, ImportMultiEntry, JoinPsbts, JsonRpcError, - ListReceivedByAddress, ListReceivedByAddressItem, ListReceivedByLabel, + GetReceivedByLabel, GetZmqNotifications, ImportMulti, ImportMultiEntry, JoinPsbts, + JsonRpcError, ListReceivedByAddress, ListReceivedByAddressItem, ListReceivedByLabel, ListReceivedByLabelError, ListUnspent, ListUnspentItem, ListWalletDir, ListWalletDirWallet, NodeAddress, UtxoUpdatePsbt, }, @@ -290,7 +289,8 @@ pub use crate::{ GetBlockFilterError, GetBlockchainInfo, GetBlockchainInfoError, GetChainTxStats, GetDescriptorInfo, GetMempoolAncestors, GetMempoolAncestorsVerbose, GetMempoolDescendants, GetMempoolDescendantsVerbose, GetMempoolEntry, GetMempoolInfo, GetNetworkInfo, GetPeerInfo, - GetRpcInfo, MapMempoolEntryError, MempoolEntry, MempoolEntryError, MempoolEntryFees, - MempoolEntryFeesError, PeerInfo, SetWalletFlag, Softfork, SoftforkType, + GetRpcInfo, GetWalletInfo, GetWalletInfoScanning, MapMempoolEntryError, MempoolEntry, + MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, PeerInfo, SetWalletFlag, + Softfork, SoftforkType, }, }; diff --git a/types/src/v21/mod.rs b/types/src/v21/mod.rs index 9b404038..cb47427a 100644 --- a/types/src/v21/mod.rs +++ b/types/src/v21/mod.rs @@ -179,7 +179,7 @@ //! | getreceivedbylabel | version + model | | //! | gettransaction | version + model | | //! | getunconfirmedbalance | version + model | | -//! | getwalletinfo | version + model | UNTESTED | +//! | getwalletinfo | version + model | | //! | importaddress | returns nothing | | //! | importdescriptors | version | | //! | importmulti | version | | @@ -204,7 +204,7 @@ //! | removeprunedfunds | returns nothing | | //! | rescanblockchain | version + model | | //! | send | version + model | | -//! | sendmany | version + model | UNTESTED | +//! | sendmany | version + model | | //! | sendtoaddress | version + model | | //! | sethdseed | returns nothing | | //! | setlabel | returns nothing | | @@ -227,7 +227,7 @@ //! //! | JSON-RPC Method Name | Returns | Notes | //! |:-----------------------------------|:---------------:|:--------------------------------------:| -//! | getzmqnotifications | version | UNTESTED | +//! | getzmqnotifications | version | | //! //! @@ -255,8 +255,9 @@ pub use self::{ }, util::{GetIndexInfo, GetIndexInfoName}, wallet::{ - ImportDescriptors, ImportDescriptorsResult, PsbtBumpFee, PsbtBumpFeeError, Send, SendError, - UnloadWallet, UpgradeWallet, + GetWalletInfo, GetWalletInfoScanning, ImportDescriptors, ImportDescriptorsResult, + PsbtBumpFee, PsbtBumpFeeError, Send, SendError, SendMany, SendManyVerbose, UnloadWallet, + UpgradeWallet, }, }; #[doc(inline)] @@ -278,25 +279,24 @@ pub use crate::{ GetNewAddress, GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, GetRawTransaction, GetRawTransactionVerbose, GetRawTransactionVerboseError, GetReceivedByAddress, GetTransactionDetailError, GetTransactionError, GetTxOut, GetTxOutError, GetTxOutSetInfo, - GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfo, GetWalletInfoError, - GetZmqNotifications, ListAddressGroupings, ListAddressGroupingsError, - ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, - ListLockUnspentItemError, ListReceivedByAddressError, ListSinceBlock, ListSinceBlockError, - ListSinceBlockTransaction, ListSinceBlockTransactionError, ListTransactions, - ListTransactionsItem, ListTransactionsItemError, ListUnspentItemError, ListWallets, - LoadWallet, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, - RawTransactionOutput, RescanBlockchain, ScriptType, SendMany, SendRawTransaction, - SendToAddress, SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, - SignRawTransaction, SignRawTransactionError, SoftforkReject, TransactionCategory, - UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, - VerifyTxOutProof, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WalletProcessPsbt, - WitnessUtxo, + GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings, + ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, + ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListSinceBlock, + ListSinceBlockError, ListSinceBlockTransaction, ListSinceBlockTransactionError, + ListTransactions, ListTransactionsItem, ListTransactionsItemError, ListUnspentItemError, + ListWallets, LoadWallet, LockUnspent, Locked, PruneBlockchain, RawTransactionError, + RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, + SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, + SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, SoftforkReject, + TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, + VerifyMessage, VerifyTxOutProof, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, + WalletProcessPsbt, WitnessUtxo, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, AnalyzePsbtInputMissingError, DeriveAddresses, GetAddressInfoError, GetNodeAddresses, - GetReceivedByLabel, ImportMulti, ImportMultiEntry, JoinPsbts, JsonRpcError, - ListReceivedByAddress, ListReceivedByAddressItem, ListReceivedByLabel, + GetReceivedByLabel, GetZmqNotifications, ImportMulti, ImportMultiEntry, JoinPsbts, + JsonRpcError, ListReceivedByAddress, ListReceivedByAddressItem, ListReceivedByLabel, ListReceivedByLabelError, ListUnspent, ListUnspentItem, ListWalletDir, ListWalletDirWallet, NodeAddress, UtxoUpdatePsbt, }, diff --git a/types/src/v21/wallet/into.rs b/types/src/v21/wallet/into.rs index fcd5a7cf..75c1a1d5 100644 --- a/types/src/v21/wallet/into.rs +++ b/types/src/v21/wallet/into.rs @@ -1,6 +1,11 @@ // SPDX-License-Identifier: CC0-1.0 -use super::{PsbtBumpFee, PsbtBumpFeeError, Send, SendError, UnloadWallet}; +use bitcoin::{hex, Txid}; + +use super::{ + GetWalletInfo, GetWalletInfoError, GetWalletInfoScanning, PsbtBumpFee, PsbtBumpFeeError, Send, + SendError, SendMany, SendManyVerbose, UnloadWallet, +}; use crate::model; impl UnloadWallet { @@ -42,3 +47,71 @@ impl Send { Ok(model::Send { complete: self.complete, txid, hex, psbt }) } } + +impl SendMany { + /// Converts version specific type to a version nonspecific, more strongly typed type. + pub fn into_model(self) -> Result { + let txid = self.0.parse::()?; + Ok(model::SendMany(txid)) + } +} + +impl SendManyVerbose { + /// Converts version specific type to a version nonspecific, more strongly typed type. + pub fn into_model(self) -> Result { + let txid = self.txid.parse::()?; + Ok(model::SendManyVerbose { txid, fee_reason: self.fee_reason }) + } +} + +impl GetWalletInfo { + /// Converts version specific type to a version nonspecific, more strongly typed type. + pub fn into_model(self) -> Result { + use GetWalletInfoError as E; + + let wallet_version = crate::to_u32(self.wallet_version, "wallet_version")?; + let balance = bitcoin::Amount::from_btc(self.balance).map_err(E::Balance)?; + let unconfirmed_balance = + bitcoin::Amount::from_btc(self.unconfirmed_balance).map_err(E::UnconfirmedBalance)?; + let immature_balance = + bitcoin::Amount::from_btc(self.immature_balance).map_err(E::ImmatureBalance)?; + let tx_count = crate::to_u32(self.tx_count, "tx_count")?; + let keypool_oldest = crate::to_u32(self.keypool_oldest, "keypool_oldest")?; + let keypool_size = crate::to_u32(self.keypool_size, "keypool_size")?; + let keypool_size_hd_internal = + crate::to_u32(self.keypool_size_hd_internal, "keypool_size_hd_internal")?; + let pay_tx_fee = crate::btc_per_kb(self.pay_tx_fee).map_err(E::PayTxFee)?; + let hd_seed_id = self.hd_seed_id.map(|s| s.parse()).transpose().map_err(E::HdSeedId)?; + + let scanning = match self.scanning { + GetWalletInfoScanning::Details { duration, progress } => + Some(model::GetWalletInfoScanning::Details { duration, progress }), + GetWalletInfoScanning::NotScanning(b) => + Some(model::GetWalletInfoScanning::NotScanning(b)), + }; + + Ok(model::GetWalletInfo { + wallet_name: self.wallet_name, + wallet_version, + balance, + unconfirmed_balance, + immature_balance, + tx_count, + keypool_oldest, + keypool_size, + keypool_size_hd_internal, + unlocked_until: self.unlocked_until, + pay_tx_fee, + hd_seed_id, + private_keys_enabled: self.private_keys_enabled, + avoid_reuse: Some(self.avoid_reuse), + scanning, + format: Some(self.format), + descriptors: Some(self.descriptors), + external_signer: None, + blank: None, + birthtime: None, + last_processed_block: None, + }) + } +} diff --git a/types/src/v21/wallet/mod.rs b/types/src/v21/wallet/mod.rs index 6004e25f..55cfbce8 100644 --- a/types/src/v21/wallet/mod.rs +++ b/types/src/v21/wallet/mod.rs @@ -10,6 +10,7 @@ mod into; use serde::{Deserialize, Serialize}; pub use self::error::{PsbtBumpFeeError, SendError}; +pub use super::GetWalletInfoError; /// Result of JSON-RPC method `importdescriptors`. /// @@ -109,6 +110,36 @@ pub struct Send { pub psbt: Option, } +/// Result of JSON-RPC method `sendmany` when `verbose=false`. +/// +/// > sendmany "" {"address":amount} +/// > +/// > Send multiple times. Amounts are double-precision floating point numbers. +/// > Requires wallet passphrase to be set with walletpassphrase call if wallet is encrypted. +/// > +/// > Arguments: +/// > 1. dummy (string, required) Must be set to "" for backwards compatibility. +/// > 2. amounts (json object, required) The addresses and amounts +/// > { "address": amount, (numeric or string, required) The bitcoin address is the key, the numeric amount (can be string) in BTC is the value } +/// > ... +/// > 10. verbose (boolean, optional, default=false) If true, return extra infomration about the transaction. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] +pub struct SendMany( + /// The transaction id for the send. + pub String, +); + +/// Result of JSON-RPC method `sendmany` when `verbose=true`. +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] +pub struct SendManyVerbose { + /// The transaction id for the send. Only 1 transaction is created regardless of the number of addresses. + pub txid: String, + /// The transaction fee reason. + pub fee_reason: String, +} + /// Result of the JSON-RPC method `unloadwallet`. /// /// > unloadwallet ( "wallet_name" load_on_startup ) @@ -140,3 +171,66 @@ pub struct UpgradeWallet { /// Error message (if there is one) pub error: Option, } + +/// Result of the JSON-RPC method `getwalletinfo`. +/// +/// > getwalletinfo +/// > Returns an object containing various wallet state info. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] +pub struct GetWalletInfo { + /// The wallet name. + #[serde(rename = "walletname")] + pub wallet_name: String, + /// The wallet version. + #[serde(rename = "walletversion")] + pub wallet_version: i64, + /// The database format (bdb or sqlite). + pub format: String, + /// The total confirmed balance of the wallet in BTC. (DEPRECATED) + pub balance: f64, + /// The total unconfirmed balance of the wallet in BTC. (DEPRECATED) + pub unconfirmed_balance: f64, + /// The total immature balance of the wallet in BTC. (DEPRECATED) + pub immature_balance: f64, + /// The total number of transactions in the wallet + #[serde(rename = "txcount")] + pub tx_count: i64, + /// The UNIX epoch time of the oldest pre-generated key in the key pool. Legacy wallets only. + #[serde(rename = "keypoololdest")] + pub keypool_oldest: i64, + /// How many new keys are pre-generated (only counts external keys). + #[serde(rename = "keypoolsize")] + pub keypool_size: i64, + /// How many new keys are pre-generated for internal use (used for change outputs, only appears + /// if the wallet is using this feature, otherwise external keys are used). + #[serde(rename = "keypoolsize_hd_internal")] + pub keypool_size_hd_internal: i64, + /// The UNIX epoch time until which the wallet is unlocked for transfers, or 0 if the wallet is locked. + /// Only present for passphrase-encrypted wallets. + pub unlocked_until: Option, + /// The transaction fee configuration, set in BTC/kvB. + #[serde(rename = "paytxfee")] + pub pay_tx_fee: f64, + /// The Hash160 of the HD seed (only present when HD is enabled). + #[serde(rename = "hdseedid")] + pub hd_seed_id: Option, + /// If privatekeys are disabled for this wallet (enforced watch-only wallet). + pub private_keys_enabled: bool, + /// Whether this wallet tracks clean/dirty coins in terms of reuse. + pub avoid_reuse: bool, + /// Current scanning details, or false if no scan is in progress. + pub scanning: GetWalletInfoScanning, + /// Whether this wallet uses descriptors for scriptPubKey management. + pub descriptors: bool, +} + +/// The `scanning` field of the `getwalletinfo` RPC in v21. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[serde(untagged)] +pub enum GetWalletInfoScanning { + /// Scanning details. + Details { duration: u64, progress: f64 }, + /// Not scanning (false). + NotScanning(bool), +} diff --git a/types/src/v22/mod.rs b/types/src/v22/mod.rs index 95f6225e..c1a34376 100644 --- a/types/src/v22/mod.rs +++ b/types/src/v22/mod.rs @@ -188,7 +188,7 @@ //! | getreceivedbylabel | version + model | | //! | gettransaction | version + model | | //! | getunconfirmedbalance | version + model | | -//! | getwalletinfo | version + model | UNTESTED | +//! | getwalletinfo | version + model | | //! | importaddress | returns nothing | | //! | importdescriptors | version | | //! | importmulti | version | | @@ -214,7 +214,7 @@ //! | removeprunedfunds | returns nothing | | //! | rescanblockchain | version + model | | //! | send | version + model | | -//! | sendmany | version + model | UNTESTED | +//! | sendmany | version + model | | //! | sendtoaddress | version + model | | //! | sethdseed | returns nothing | | //! | setlabel | returns nothing | | @@ -238,7 +238,7 @@ //! //! | JSON-RPC Method Name | Returns | Notes | //! |:-----------------------------------|:---------------:|:--------------------------------------:| -//! | getzmqnotifications | version | UNTESTED | +//! | getzmqnotifications | version | | //! //! @@ -281,14 +281,13 @@ pub use crate::{ GetRawMempool, GetRawMempoolVerbose, GetRawTransaction, GetRawTransactionVerbose, GetRawTransactionVerboseError, GetReceivedByAddress, GetTransactionDetailError, GetTransactionError, GetTxOut, GetTxOutError, GetTxOutSetInfo, GetTxOutSetInfoError, - GetUnconfirmedBalance, GetWalletInfo, GetWalletInfoError, GetZmqNotifications, - ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, - ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, - ListSinceBlock, ListSinceBlockError, ListSinceBlockTransaction, - ListSinceBlockTransactionError, ListTransactions, ListTransactionsItem, - ListTransactionsItemError, ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, - Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, - RescanBlockchain, ScriptType, SendMany, SendRawTransaction, SendToAddress, + GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError, + ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, + ListLockUnspentItemError, ListReceivedByAddressError, ListSinceBlock, ListSinceBlockError, + ListSinceBlockTransaction, ListSinceBlockTransactionError, ListTransactions, + ListTransactionsItem, ListTransactionsItemError, ListUnspentItemError, ListWallets, + LoadWallet, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, + RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, SoftforkReject, TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof, @@ -297,9 +296,10 @@ pub use crate::{ v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, AnalyzePsbtInputMissingError, DeriveAddresses, GetAddressInfoError, GetReceivedByLabel, - ImportMulti, ImportMultiEntry, JoinPsbts, JsonRpcError, ListReceivedByAddress, - ListReceivedByAddressItem, ListReceivedByLabel, ListReceivedByLabelError, ListUnspent, - ListUnspentItem, ListWalletDir, ListWalletDirWallet, UtxoUpdatePsbt, + GetZmqNotifications, ImportMulti, ImportMultiEntry, JoinPsbts, JsonRpcError, + ListReceivedByAddress, ListReceivedByAddressItem, ListReceivedByLabel, + ListReceivedByLabelError, ListUnspent, ListUnspentItem, ListWalletDir, ListWalletDirWallet, + UtxoUpdatePsbt, }, v19::{ Bip9SoftforkStatistics, Bip9SoftforkStatus, GetBalances, GetBalancesError, GetBalancesMine, @@ -314,9 +314,10 @@ pub use crate::{ v21::{ AddPeerAddress, Bip9SoftforkInfo, GenerateBlock, GetBlockchainInfo, GetIndexInfo, GetIndexInfoName, GetMempoolAncestors, GetMempoolAncestorsVerbose, GetMempoolDescendants, - GetMempoolDescendantsVerbose, GetMempoolEntry, GetNetworkInfo, ImportDescriptors, - ImportDescriptorsResult, MempoolEntry, PsbtBumpFee, PsbtBumpFeeError, Send, SendError, - Softfork, SoftforkType, UnloadWallet, UpgradeWallet, + GetMempoolDescendantsVerbose, GetMempoolEntry, GetNetworkInfo, GetWalletInfo, + GetWalletInfoScanning, ImportDescriptors, ImportDescriptorsResult, MempoolEntry, + PsbtBumpFee, PsbtBumpFeeError, Send, SendError, SendMany, SendManyVerbose, Softfork, + SoftforkType, UnloadWallet, UpgradeWallet, }, ScriptPubkey, }; diff --git a/types/src/v23/mod.rs b/types/src/v23/mod.rs index 2d7b6e48..6745dad1 100644 --- a/types/src/v23/mod.rs +++ b/types/src/v23/mod.rs @@ -179,7 +179,7 @@ //! | getreceivedbylabel | version + model | | //! | gettransaction | version + model | | //! | getunconfirmedbalance | version + model | | -//! | getwalletinfo | version + model | UNTESTED | +//! | getwalletinfo | version + model | | //! | importaddress | returns nothing | | //! | importdescriptors | version | | //! | importmulti | version | | @@ -207,7 +207,7 @@ //! | rescanblockchain | version + model | | //! | restorewallet | version | | //! | send | version + model | | -//! | sendmany | version + model | UNTESTED | +//! | sendmany | version + model | | //! | sendtoaddress | version + model | | //! | sethdseed | returns nothing | | //! | setlabel | returns nothing | | @@ -231,7 +231,7 @@ //! //! | JSON-RPC Method Name | Returns | Notes | //! |:-----------------------------------|:---------------:|:--------------------------------------:| -//! | getzmqnotifications | version | UNTESTED | +//! | getzmqnotifications | version | | //! //! @@ -258,7 +258,10 @@ pub use self::{ PsbtInput, PsbtOutput, }, util::CreateMultisig, - wallet::{AddMultisigAddress, GetTransaction, GetTransactionError, RestoreWallet}, + wallet::{ + AddMultisigAddress, GetTransaction, GetTransactionError, GetWalletInfo, + GetWalletInfoScanning, RestoreWallet, + }, }; #[doc(inline)] pub use crate::{ @@ -278,26 +281,26 @@ pub use crate::{ GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, GetRawTransaction, GetRawTransactionVerbose, GetRawTransactionVerboseError, GetReceivedByAddress, GetTransactionDetailError, GetTxOut, - GetTxOutError, GetTxOutSetInfo, GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfo, - GetWalletInfoError, GetZmqNotifications, ListAddressGroupings, ListAddressGroupingsError, + GetTxOutError, GetTxOutSetInfo, GetTxOutSetInfoError, GetUnconfirmedBalance, + GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListSinceBlock, ListSinceBlockError, ListSinceBlockTransaction, ListSinceBlockTransactionError, ListTransactions, ListTransactionsItem, ListTransactionsItemError, ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, - RawTransactionOutput, RescanBlockchain, ScriptType, SendMany, SendRawTransaction, - SendToAddress, SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, - SignRawTransaction, SignRawTransactionError, SoftforkReject, TransactionCategory, - UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, - VerifyTxOutProof, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WalletProcessPsbt, - WitnessUtxo, + RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, + SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, + SignRawTransactionError, SoftforkReject, TransactionCategory, UploadTarget, + ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof, + WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, AnalyzePsbtInputMissingError, DeriveAddresses, GetAddressInfoError, GetReceivedByLabel, - ImportMulti, ImportMultiEntry, JoinPsbts, JsonRpcError, ListReceivedByAddress, - ListReceivedByAddressItem, ListReceivedByLabel, ListReceivedByLabelError, ListUnspent, - ListUnspentItem, ListWalletDir, ListWalletDirWallet, UtxoUpdatePsbt, + GetZmqNotifications, ImportMulti, ImportMultiEntry, JoinPsbts, JsonRpcError, + ListReceivedByAddress, ListReceivedByAddressItem, ListReceivedByLabel, + ListReceivedByLabelError, ListUnspent, ListUnspentItem, ListWalletDir, ListWalletDirWallet, + UtxoUpdatePsbt, }, v19::{ Bip9SoftforkInfo, Bip9SoftforkStatistics, Bip9SoftforkStatus, GetBalances, @@ -310,7 +313,7 @@ pub use crate::{ v21::{ AddPeerAddress, GenerateBlock, GetIndexInfo, GetIndexInfoName, GetNetworkInfo, ImportDescriptors, ImportDescriptorsResult, PsbtBumpFee, PsbtBumpFeeError, Send, SendError, - UnloadWallet, UpgradeWallet, + SendMany, SendManyVerbose, UnloadWallet, UpgradeWallet, }, v22::{ Banned, EnumerateSigners, GetAddressInfo, GetAddressInfoEmbedded, GetMempoolInfo, diff --git a/types/src/v23/wallet/into.rs b/types/src/v23/wallet/into.rs index eca06854..899f9365 100644 --- a/types/src/v23/wallet/into.rs +++ b/types/src/v23/wallet/into.rs @@ -3,7 +3,10 @@ use bitcoin::consensus::encode; use bitcoin::{Address, BlockHash, ScriptBuf, SignedAmount, Transaction, Txid}; -use super::{AddMultisigAddress, AddMultisigAddressError, GetTransaction, GetTransactionError}; +use super::{ + AddMultisigAddress, AddMultisigAddressError, GetTransaction, GetTransactionError, + GetWalletInfo, GetWalletInfoError, GetWalletInfoScanning, +}; use crate::model; impl AddMultisigAddress { @@ -84,3 +87,58 @@ impl GetTransaction { }) } } + +impl GetWalletInfo { + /// Converts version specific type to a version nonspecific, more strongly typed type. + pub fn into_model(self) -> Result { + use GetWalletInfoError as E; + + let wallet_version = crate::to_u32(self.wallet_version, "wallet_version")?; + let balance = bitcoin::Amount::from_btc(self.balance).map_err(E::Balance)?; + let unconfirmed_balance = + bitcoin::Amount::from_btc(self.unconfirmed_balance).map_err(E::UnconfirmedBalance)?; + let immature_balance = + bitcoin::Amount::from_btc(self.immature_balance).map_err(E::ImmatureBalance)?; + let tx_count = crate::to_u32(self.tx_count, "tx_count")?; + let keypool_oldest = + self.keypool_oldest.map(|v| crate::to_u32(v, "keypool_oldest")).transpose()?; + let keypool_size = crate::to_u32(self.keypool_size, "keypool_size")?; + let keypool_size_hd_internal = self + .keypool_size_hd_internal + .map(|v| crate::to_u32(v, "keypool_size_hd_internal")) + .transpose()?; + let pay_tx_fee = crate::btc_per_kb(self.pay_tx_fee).map_err(E::PayTxFee)?; + let hd_seed_id = self.hd_seed_id.map(|s| s.parse()).transpose().map_err(E::HdSeedId)?; + + let scanning = match self.scanning { + GetWalletInfoScanning::Details { duration, progress } => + Some(model::GetWalletInfoScanning::Details { duration, progress }), + GetWalletInfoScanning::NotScanning(b) => + Some(model::GetWalletInfoScanning::NotScanning(b)), + }; + + Ok(model::GetWalletInfo { + wallet_name: self.wallet_name, + wallet_version, + balance, + unconfirmed_balance, + immature_balance, + tx_count, + keypool_oldest: keypool_oldest.unwrap_or(0), + keypool_size, + keypool_size_hd_internal: keypool_size_hd_internal.unwrap_or(0), + unlocked_until: self.unlocked_until, + pay_tx_fee, + hd_seed_id, + private_keys_enabled: self.private_keys_enabled, + avoid_reuse: Some(self.avoid_reuse), + scanning, + format: Some(self.format), + descriptors: Some(self.descriptors), + external_signer: Some(self.external_signer), + blank: None, + birthtime: None, + last_processed_block: None, + }) + } +} diff --git a/types/src/v23/wallet/mod.rs b/types/src/v23/wallet/mod.rs index e6145c9d..f25d6fcc 100644 --- a/types/src/v23/wallet/mod.rs +++ b/types/src/v23/wallet/mod.rs @@ -13,6 +13,7 @@ use serde::{Deserialize, Serialize}; pub use self::error::GetTransactionError; pub use super::{ AddMultisigAddressError, Bip125Replaceable, GetTransactionDetail, GetTransactionDetailError, + GetWalletInfoError, }; /// Result of the JSON-RPC method `addmultisigaddress`. @@ -124,3 +125,67 @@ pub struct RestoreWallet { /// Warning message if wallet was not loaded cleanly. pub warning: Option, } + +/// Result of the JSON-RPC method `getwalletinfo`. +/// +/// > getwalletinfo +/// > +/// > Returns an object containing various wallet state info. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] +pub struct GetWalletInfo { + /// the wallet name + #[serde(rename = "walletname")] + pub wallet_name: String, + /// the wallet version + #[serde(rename = "walletversion")] + pub wallet_version: i64, + /// the database format (bdb or sqlite) + pub format: String, + /// DEPRECATED. Identical to getbalances().mine.trusted + pub balance: f64, + /// DEPRECATED. Identical to getbalances().mine.untrusted_pending + pub unconfirmed_balance: f64, + /// DEPRECATED. Identical to getbalances().mine.immature + pub immature_balance: f64, + /// the total number of transactions in the wallet + #[serde(rename = "txcount")] + pub tx_count: i64, + /// the UNIX epoch time of the oldest pre-generated key in the key pool. Legacy wallets only. + #[serde(rename = "keypoololdest")] + pub keypool_oldest: Option, + /// how many new keys are pre-generated (only counts external keys) + #[serde(rename = "keypoolsize")] + pub keypool_size: i64, + /// how many new keys are pre-generated for internal use (used for change outputs, only appears if the wallet is using this feature, otherwise external keys are used) + #[serde(rename = "keypoolsize_hd_internal")] + pub keypool_size_hd_internal: Option, + /// the UNIX epoch time until which the wallet is unlocked for transfers, or 0 if the wallet is locked (only present for passphrase-encrypted wallets) + pub unlocked_until: Option, + /// the transaction fee configuration, set in BTC/kvB + #[serde(rename = "paytxfee")] + pub pay_tx_fee: f64, + /// the Hash160 of the HD seed (only present when HD is enabled) + #[serde(rename = "hdseedid")] + pub hd_seed_id: Option, + /// false if privatekeys are disabled for this wallet (enforced watch-only wallet) + pub private_keys_enabled: bool, + /// whether this wallet tracks clean/dirty coins in terms of reuse + pub avoid_reuse: bool, + /// current scanning details, or false if no scan is in progress + pub scanning: GetWalletInfoScanning, + /// whether this wallet uses descriptors for scriptPubKey management + pub descriptors: bool, + /// whether this wallet is configured to use an external signer such as a hardware wallet + pub external_signer: bool, +} + +/// The `scanning` field of the `getwalletinfo` RPC in v23. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[serde(untagged)] +pub enum GetWalletInfoScanning { + /// Scanning details. + Details { duration: u64, progress: f64 }, + /// Not scanning (false). + NotScanning(bool), +} diff --git a/types/src/v24/mod.rs b/types/src/v24/mod.rs index 2a9fbd3f..bf630f9b 100644 --- a/types/src/v24/mod.rs +++ b/types/src/v24/mod.rs @@ -180,7 +180,7 @@ //! | getreceivedbylabel | version + model | | //! | gettransaction | version + model | | //! | getunconfirmedbalance | version + model | | -//! | getwalletinfo | version + model | UNTESTED | +//! | getwalletinfo | version + model | | //! | importaddress | returns nothing | | //! | importdescriptors | version | | //! | importmulti | version | | @@ -210,7 +210,7 @@ //! | restorewallet | version | | //! | send | version + model | | //! | sendall | version + model | | -//! | sendmany | version + model | UNTESTED | +//! | sendmany | version + model | | //! | sendtoaddress | version + model | | //! | sethdseed | returns nothing | | //! | setlabel | returns nothing | | @@ -235,7 +235,7 @@ //! //! | JSON-RPC Method Name | Returns | Notes | //! |:-----------------------------------|:---------------:|:--------------------------------------:| -//! | getzmqnotifications | version | UNTESTED | +//! | getzmqnotifications | version | | //! //! @@ -280,26 +280,25 @@ pub use crate::{ GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, GetRawTransaction, GetRawTransactionVerbose, GetRawTransactionVerboseError, GetReceivedByAddress, GetTransactionDetailError, GetTxOut, - GetTxOutError, GetTxOutSetInfo, GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfo, - GetWalletInfoError, GetZmqNotifications, ListAddressGroupings, ListAddressGroupingsError, + GetTxOutError, GetTxOutSetInfo, GetTxOutSetInfoError, GetUnconfirmedBalance, + GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListSinceBlock, ListSinceBlockError, ListSinceBlockTransaction, ListSinceBlockTransactionError, ListTransactions, ListTransactionsItem, ListTransactionsItemError, ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, - RawTransactionOutput, RescanBlockchain, ScriptType, SendMany, SendRawTransaction, - SendToAddress, SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, - SignRawTransaction, SignRawTransactionError, SoftforkReject, TransactionCategory, - UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, - VerifyTxOutProof, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WalletProcessPsbt, - WitnessUtxo, + RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, + SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, + SignRawTransactionError, SoftforkReject, TransactionCategory, UploadTarget, + ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof, + WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, AnalyzePsbtInputMissingError, DeriveAddresses, GetAddressInfoError, GetReceivedByLabel, - ImportMulti, ImportMultiEntry, JoinPsbts, JsonRpcError, ListReceivedByAddress, - ListReceivedByAddressItem, ListReceivedByLabel, ListReceivedByLabelError, ListWalletDir, - ListWalletDirWallet, UtxoUpdatePsbt, + GetZmqNotifications, ImportMulti, ImportMultiEntry, JoinPsbts, JsonRpcError, + ListReceivedByAddress, ListReceivedByAddressItem, ListReceivedByLabel, + ListReceivedByLabelError, ListWalletDir, ListWalletDirWallet, UtxoUpdatePsbt, }, v19::{ Bip9SoftforkInfo, Bip9SoftforkStatistics, Bip9SoftforkStatus, GetBalances, @@ -312,7 +311,7 @@ pub use crate::{ v21::{ AddPeerAddress, GenerateBlock, GetIndexInfo, GetIndexInfoName, GetNetworkInfo, ImportDescriptors, ImportDescriptorsResult, PsbtBumpFee, PsbtBumpFeeError, Send, SendError, - UnloadWallet, UpgradeWallet, + SendMany, SendManyVerbose, UnloadWallet, UpgradeWallet, }, v22::{ Banned, EnumerateSigners, GetAddressInfo, GetAddressInfoEmbedded, GetNodeAddresses, @@ -322,6 +321,7 @@ pub use crate::{ v23::{ AddMultisigAddress, Bip9Info, Bip9Statistics, CreateMultisig, DecodeScript, DecodeScriptError, DeploymentInfo, GetBlockchainInfo, GetDeploymentInfo, - GetDeploymentInfoError, Logging, RestoreWallet, SaveMempool, + GetDeploymentInfoError, GetWalletInfo, GetWalletInfoScanning, Logging, RestoreWallet, + SaveMempool, }, }; diff --git a/types/src/v25/mod.rs b/types/src/v25/mod.rs index a49d4743..87ff2b85 100644 --- a/types/src/v25/mod.rs +++ b/types/src/v25/mod.rs @@ -181,7 +181,7 @@ //! | getreceivedbylabel | version + model | | //! | gettransaction | version + model | | //! | getunconfirmedbalance | version + model | | -//! | getwalletinfo | version + model | UNTESTED | +//! | getwalletinfo | version + model | | //! | importaddress | returns nothing | | //! | importdescriptors | version | | //! | importmulti | version | | @@ -211,7 +211,7 @@ //! | restorewallet | version | | //! | send | version + model | | //! | sendall | version + model | | -//! | sendmany | version + model | UNTESTED | +//! | sendmany | version + model | | //! | sendtoaddress | version + model | | //! | sethdseed | returns nothing | | //! | setlabel | returns nothing | | @@ -236,7 +236,7 @@ //! //! | JSON-RPC Method Name | Returns | Notes | //! |:-----------------------------------|:---------------:|:--------------------------------------:| -//! | getzmqnotifications | version | UNTESTED | +//! | getzmqnotifications | version | | //! //! @@ -276,26 +276,25 @@ pub use crate::{ GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, GetRawTransaction, GetRawTransactionVerbose, GetRawTransactionVerboseError, GetReceivedByAddress, GetTransactionDetailError, GetTxOut, - GetTxOutError, GetTxOutSetInfo, GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfo, - GetWalletInfoError, GetZmqNotifications, ListAddressGroupings, ListAddressGroupingsError, + GetTxOutError, GetTxOutSetInfo, GetTxOutSetInfoError, GetUnconfirmedBalance, + GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListSinceBlock, ListSinceBlockError, ListSinceBlockTransaction, ListSinceBlockTransactionError, ListTransactions, ListTransactionsItem, ListTransactionsItemError, ListUnspentItemError, ListWallets, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, - RawTransactionOutput, RescanBlockchain, ScriptType, SendMany, SendRawTransaction, - SendToAddress, SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, - SignRawTransaction, SignRawTransactionError, SoftforkReject, TransactionCategory, - UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, - VerifyTxOutProof, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WalletProcessPsbt, - WitnessUtxo, + RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, + SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, + SignRawTransactionError, SoftforkReject, TransactionCategory, UploadTarget, + ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof, + WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, AnalyzePsbtInputMissingError, DeriveAddresses, GetAddressInfoError, GetReceivedByLabel, - ImportMulti, ImportMultiEntry, JoinPsbts, JsonRpcError, ListReceivedByAddress, - ListReceivedByAddressItem, ListReceivedByLabel, ListReceivedByLabelError, ListWalletDir, - ListWalletDirWallet, UtxoUpdatePsbt, + GetZmqNotifications, ImportMulti, ImportMultiEntry, JoinPsbts, JsonRpcError, + ListReceivedByAddress, ListReceivedByAddressItem, ListReceivedByLabel, + ListReceivedByLabelError, ListWalletDir, ListWalletDirWallet, UtxoUpdatePsbt, }, v19::{ Bip9SoftforkInfo, Bip9SoftforkStatistics, Bip9SoftforkStatus, GetBalances, @@ -307,7 +306,8 @@ pub use crate::{ v20::GenerateToDescriptor, v21::{ AddPeerAddress, GetIndexInfo, GetIndexInfoName, GetNetworkInfo, ImportDescriptors, - ImportDescriptorsResult, PsbtBumpFee, PsbtBumpFeeError, Send, SendError, UpgradeWallet, + ImportDescriptorsResult, PsbtBumpFee, PsbtBumpFeeError, Send, SendError, SendMany, + SendManyVerbose, UpgradeWallet, }, v22::{ Banned, EnumerateSigners, GetAddressInfo, GetAddressInfoEmbedded, GetNodeAddresses, @@ -316,7 +316,7 @@ pub use crate::{ v23::{ AddMultisigAddress, Bip9Info, Bip9Statistics, CreateMultisig, DecodeScript, DecodeScriptError, DeploymentInfo, GetBlockchainInfo, GetDeploymentInfo, - GetDeploymentInfoError, RestoreWallet, SaveMempool, + GetDeploymentInfoError, GetWalletInfo, GetWalletInfoScanning, RestoreWallet, SaveMempool, }, v24::{ DecodePsbt, DecodePsbtError, GetMempoolAncestors, GetMempoolAncestorsVerbose, diff --git a/types/src/v26/mod.rs b/types/src/v26/mod.rs index 31af8770..6f3fbbc6 100644 --- a/types/src/v26/mod.rs +++ b/types/src/v26/mod.rs @@ -189,7 +189,7 @@ //! | getreceivedbylabel | version + model | | //! | gettransaction | version + model | | //! | getunconfirmedbalance | version + model | | -//! | getwalletinfo | version + model | UNTESTED | +//! | getwalletinfo | version + model | | //! | importaddress | returns nothing | | //! | importdescriptors | version | | //! | importmulti | version | | @@ -219,7 +219,7 @@ //! | restorewallet | version | | //! | send | version + model | | //! | sendall | version + model | | -//! | sendmany | version + model | UNTESTED | +//! | sendmany | version + model | | //! | sendtoaddress | version + model | | //! | sethdseed | returns nothing | | //! | setlabel | returns nothing | | @@ -244,7 +244,7 @@ //! //! | JSON-RPC Method Name | Returns | Notes | //! |:-----------------------------------|:---------------:|:--------------------------------------:| -//! | getzmqnotifications | version | UNTESTED | +//! | getzmqnotifications | version | | //! //! @@ -271,7 +271,8 @@ pub use self::{ }, wallet::{ CreateWallet, GetBalances, GetBalancesError, GetTransaction, GetTransactionError, - LastProcessedBlock, LastProcessedBlockError, LoadWallet, UnloadWallet, WalletProcessPsbt, + GetWalletInfo, GetWalletInfoError, GetWalletInfoScanning, LastProcessedBlock, + LastProcessedBlockError, LoadWallet, UnloadWallet, WalletProcessPsbt, }, }; #[doc(inline)] @@ -292,25 +293,24 @@ pub use crate::{ GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, GetRawTransaction, GetRawTransactionVerbose, GetRawTransactionVerboseError, GetReceivedByAddress, GetTransactionDetailError, GetTxOut, - GetTxOutError, GetUnconfirmedBalance, GetWalletInfo, GetWalletInfoError, - GetZmqNotifications, ListAddressGroupings, ListAddressGroupingsError, + GetTxOutError, GetUnconfirmedBalance, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListSinceBlock, ListSinceBlockError, ListSinceBlockTransaction, ListSinceBlockTransactionError, ListTransactions, ListTransactionsItem, ListTransactionsItemError, ListUnspentItemError, ListWallets, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, - RawTransactionOutput, RescanBlockchain, ScriptType, SendMany, SendRawTransaction, - SendToAddress, SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, - SignRawTransaction, SignRawTransactionError, SoftforkReject, TransactionCategory, - UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, - VerifyTxOutProof, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WitnessUtxo, + RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, + SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, + SignRawTransactionError, SoftforkReject, TransactionCategory, UploadTarget, + ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof, + WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WitnessUtxo, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, AnalyzePsbtInputMissingError, DeriveAddresses, GetAddressInfoError, GetReceivedByLabel, - ImportMulti, ImportMultiEntry, JoinPsbts, JsonRpcError, ListReceivedByAddress, - ListReceivedByAddressItem, ListReceivedByLabel, ListReceivedByLabelError, ListWalletDir, - ListWalletDirWallet, UtxoUpdatePsbt, + GetZmqNotifications, ImportMulti, ImportMultiEntry, JoinPsbts, JsonRpcError, + ListReceivedByAddress, ListReceivedByAddressItem, ListReceivedByLabel, + ListReceivedByLabelError, ListWalletDir, ListWalletDirWallet, UtxoUpdatePsbt, }, v19::{ Bip9SoftforkInfo, Bip9SoftforkStatistics, Bip9SoftforkStatus, GetBalancesMine, @@ -321,7 +321,8 @@ pub use crate::{ v20::GenerateToDescriptor, v21::{ AddPeerAddress, GetIndexInfo, GetIndexInfoName, GetNetworkInfo, ImportDescriptors, - ImportDescriptorsResult, PsbtBumpFee, PsbtBumpFeeError, Send, SendError, UpgradeWallet, + ImportDescriptorsResult, PsbtBumpFee, PsbtBumpFeeError, Send, SendError, SendMany, + SendManyVerbose, UpgradeWallet, }, v22::{ Banned, EnumerateSigners, GetAddressInfo, GetAddressInfoEmbedded, GetNodeAddresses, diff --git a/types/src/v26/wallet/error.rs b/types/src/v26/wallet/error.rs index 75dbe8d0..ef22b2a7 100644 --- a/types/src/v26/wallet/error.rs +++ b/types/src/v26/wallet/error.rs @@ -132,6 +132,63 @@ impl From for GetTransactionError { fn from(e: NumericError) -> Self { Self::Numeric(e) } } +/// Error when converting a `GetWalletInfo` type into the model type. +#[derive(Debug)] +pub enum GetWalletInfoError { + /// Conversion of numeric type to expected type failed. + Numeric(NumericError), + /// Conversion of the `balance` field failed. + Balance(ParseAmountError), + /// Conversion of the `unconfirmed_balance` field failed. + UnconfirmedBalance(ParseAmountError), + /// Conversion of the `immature_balance` field failed. + ImmatureBalance(ParseAmountError), + /// Conversion of the `pay_tx_fee` field failed. + PayTxFee(ParseAmountError), + /// Conversion of the `hd_seed_id` field failed. + HdSeedId(hex::HexToArrayError), + /// Conversion of the `last_processed_block` field failed. + LastProcessedBlock(LastProcessedBlockError), +} + +impl fmt::Display for GetWalletInfoError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + use GetWalletInfoError::*; + match *self { + Numeric(ref e) => write_err!(f, "numeric"; e), + Balance(ref e) => write_err!(f, "conversion of the `balance` field failed"; e), + UnconfirmedBalance(ref e) => + write_err!(f, "conversion of the `unconfirmed_balance` field failed"; e), + ImmatureBalance(ref e) => + write_err!(f, "conversion of the `immature_balance` field failed"; e), + PayTxFee(ref e) => write_err!(f, "conversion of the `pay_tx_fee` field failed"; e), + HdSeedId(ref e) => write_err!(f, "conversion of the `hd_seed_id` field failed"; e), + LastProcessedBlock(ref e) => + write_err!(f, "conversion of the `last_processed_block` field failed"; e), + } + } +} + +#[cfg(feature = "std")] +impl std::error::Error for GetWalletInfoError { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + use GetWalletInfoError::*; + match *self { + Numeric(ref e) => Some(e), + Balance(ref e) => Some(e), + UnconfirmedBalance(ref e) => Some(e), + ImmatureBalance(ref e) => Some(e), + PayTxFee(ref e) => Some(e), + HdSeedId(ref e) => Some(e), + LastProcessedBlock(ref e) => Some(e), + } + } +} + +impl From for GetWalletInfoError { + fn from(e: NumericError) -> Self { Self::Numeric(e) } +} + /// Error when converting a `LastProcessedBlock` type into the model type. #[derive(Debug)] pub enum LastProcessedBlockError { diff --git a/types/src/v26/wallet/into.rs b/types/src/v26/wallet/into.rs index 706d71e0..a7b449b6 100644 --- a/types/src/v26/wallet/into.rs +++ b/types/src/v26/wallet/into.rs @@ -5,8 +5,8 @@ use bitcoin::{BlockHash, Psbt, SignedAmount, Transaction, Txid}; use super::{ CreateWallet, GetBalances, GetBalancesError, GetTransaction, GetTransactionError, - LastProcessedBlock, LastProcessedBlockError, LoadWallet, UnloadWallet, WalletProcessPsbt, - WalletProcessPsbtError, + GetWalletInfo, GetWalletInfoError, GetWalletInfoScanning, LastProcessedBlock, + LastProcessedBlockError, LoadWallet, UnloadWallet, WalletProcessPsbt, WalletProcessPsbtError, }; use crate::model; @@ -109,6 +109,66 @@ impl GetTransaction { } } +impl GetWalletInfo { + /// Converts version specific type to a version nonspecific, more strongly typed type. + pub fn into_model(self) -> Result { + use GetWalletInfoError as E; + + let wallet_version = crate::to_u32(self.wallet_version, "wallet_version")?; + let balance = bitcoin::Amount::from_btc(self.balance).map_err(E::Balance)?; + let unconfirmed_balance = + bitcoin::Amount::from_btc(self.unconfirmed_balance).map_err(E::UnconfirmedBalance)?; + let immature_balance = + bitcoin::Amount::from_btc(self.immature_balance).map_err(E::ImmatureBalance)?; + let tx_count = crate::to_u32(self.tx_count, "tx_count")?; + let keypool_oldest = + self.keypool_oldest.map(|v| crate::to_u32(v, "keypool_oldest")).transpose()?; + let keypool_size = crate::to_u32(self.keypool_size, "keypool_size")?; + let keypool_size_hd_internal = self + .keypool_size_hd_internal + .map(|v| crate::to_u32(v, "keypool_size_hd_internal")) + .transpose()?; + let pay_tx_fee = crate::btc_per_kb(self.pay_tx_fee).map_err(E::PayTxFee)?; + let hd_seed_id = self.hd_seed_id.map(|s| s.parse()).transpose().map_err(E::HdSeedId)?; + let last_processed_block = self + .last_processed_block + .map(|l| l.into_model()) + .transpose() + .map_err(E::LastProcessedBlock)?; + + let scanning = match self.scanning { + GetWalletInfoScanning::Details { duration, progress } => + Some(model::GetWalletInfoScanning::Details { duration, progress }), + GetWalletInfoScanning::NotScanning(b) => + Some(model::GetWalletInfoScanning::NotScanning(b)), + }; + + Ok(model::GetWalletInfo { + wallet_name: self.wallet_name, + wallet_version, + format: Some(self.format), + balance, + unconfirmed_balance, + immature_balance, + tx_count, + keypool_oldest: keypool_oldest.unwrap_or(0), + keypool_size, + keypool_size_hd_internal: keypool_size_hd_internal.unwrap_or(0), + unlocked_until: self.unlocked_until, + pay_tx_fee, + hd_seed_id, + private_keys_enabled: self.private_keys_enabled, + avoid_reuse: Some(self.avoid_reuse), + scanning, + descriptors: Some(self.descriptors), + external_signer: Some(self.external_signer), + blank: Some(self.blank), + birthtime: self.birthtime, + last_processed_block, + }) + } +} + impl LastProcessedBlock { /// Converts version specific type to a version nonspecific, more strongly typed type. pub fn into_model(self) -> Result { diff --git a/types/src/v26/wallet/mod.rs b/types/src/v26/wallet/mod.rs index 92ea8c2b..1ee68e22 100644 --- a/types/src/v26/wallet/mod.rs +++ b/types/src/v26/wallet/mod.rs @@ -11,7 +11,8 @@ use bitcoin::Transaction; use serde::{Deserialize, Serialize}; pub use self::error::{ - GetBalancesError, GetTransactionError, LastProcessedBlockError, WalletProcessPsbtError, + GetBalancesError, GetTransactionError, GetWalletInfoError, LastProcessedBlockError, + WalletProcessPsbtError, }; pub use super::{ Bip125Replaceable, GetBalancesMine, GetBalancesWatchOnly, GetTransactionDetail, @@ -145,6 +146,77 @@ pub struct LastProcessedBlock { pub height: i64, } +/// Result of the JSON-RPC method `getwalletinfo`. +/// +/// > getwalletinfo +/// > +/// > Returns an object containing various wallet state info. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] +pub struct GetWalletInfo { + /// the wallet name + #[serde(rename = "walletname")] + pub wallet_name: String, + /// the wallet version + #[serde(rename = "walletversion")] + pub wallet_version: i64, + /// the database format (bdb or sqlite) + pub format: String, + /// DEPRECATED. Identical to getbalances().mine.trusted + pub balance: f64, + /// DEPRECATED. Identical to getbalances().mine.untrusted_pending + pub unconfirmed_balance: f64, + /// DEPRECATED. Identical to getbalances().mine.immature + pub immature_balance: f64, + /// the total number of transactions in the wallet + #[serde(rename = "txcount")] + pub tx_count: i64, + /// the UNIX epoch time of the oldest pre-generated key in the key pool. Legacy wallets only. + #[serde(rename = "keypoololdest")] + pub keypool_oldest: Option, + /// how many new keys are pre-generated (only counts external keys) + #[serde(rename = "keypoolsize")] + pub keypool_size: i64, + /// how many new keys are pre-generated for internal use (used for change outputs, only appears if the wallet is using this feature, otherwise external keys are used) + #[serde(rename = "keypoolsize_hd_internal")] + pub keypool_size_hd_internal: Option, + /// the UNIX epoch time until which the wallet is unlocked for transfers, or 0 if the wallet is locked (only present for passphrase-encrypted wallets) + pub unlocked_until: Option, + /// the transaction fee configuration, set in BTC/kvB + #[serde(rename = "paytxfee")] + pub pay_tx_fee: f64, + /// the Hash160 of the HD seed (only present when HD is enabled) + #[serde(rename = "hdseedid")] + pub hd_seed_id: Option, + /// false if privatekeys are disabled for this wallet (enforced watch-only wallet) + pub private_keys_enabled: bool, + /// whether this wallet tracks clean/dirty coins in terms of reuse + pub avoid_reuse: bool, + /// current scanning details, or false if no scan is in progress + pub scanning: GetWalletInfoScanning, + /// whether this wallet uses descriptors for scriptPubKey management + pub descriptors: bool, + /// whether this wallet is configured to use an external signer such as a hardware wallet + pub external_signer: bool, + /// Whether this wallet intentionally does not contain any keys, scripts, or descriptors + pub blank: bool, + /// The start time for blocks scanning. It could be modified by (re)importing any descriptor with an earlier timestamp. + pub birthtime: Option, + /// hash and height of the block this information was generated on + #[serde(rename = "lastprocessedblock")] + pub last_processed_block: Option, +} + +/// The `scanning` field of the `getwalletinfo` RPC in v26. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[serde(untagged)] +pub enum GetWalletInfoScanning { + /// Scanning details. + Details { duration: u64, progress: f64 }, + /// Not scanning (false). + NotScanning(bool), +} + /// Result of the JSON-RPC method `loadwallet`. /// /// > loadwallet "filename" ( load_on_startup ) diff --git a/types/src/v27/mod.rs b/types/src/v27/mod.rs index 9fbebc08..a9975dea 100644 --- a/types/src/v27/mod.rs +++ b/types/src/v27/mod.rs @@ -189,7 +189,7 @@ //! | getreceivedbylabel | version + model | | //! | gettransaction | version + model | | //! | getunconfirmedbalance | version + model | | -//! | getwalletinfo | version + model | UNTESTED | +//! | getwalletinfo | version + model | | //! | importaddress | returns nothing | | //! | importdescriptors | version | | //! | importmulti | version | | @@ -219,7 +219,7 @@ //! | restorewallet | version | | //! | send | version + model | | //! | sendall | version + model | | -//! | sendmany | version + model | UNTESTED | +//! | sendmany | version + model | | //! | sendtoaddress | version + model | | //! | sethdseed | returns nothing | | //! | setlabel | returns nothing | | @@ -244,7 +244,7 @@ //! //! | JSON-RPC Method Name | Returns | Notes | //! |:-----------------------------------|:---------------:|:--------------------------------------:| -//! | getzmqnotifications | version | UNTESTED | +//! | getzmqnotifications | version | | //! //! @@ -270,25 +270,24 @@ pub use crate::{ GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, GetRawTransaction, GetRawTransactionVerbose, GetRawTransactionVerboseError, GetReceivedByAddress, GetTransactionDetailError, GetTxOut, - GetTxOutError, GetUnconfirmedBalance, GetWalletInfo, GetWalletInfoError, - GetZmqNotifications, ListAddressGroupings, ListAddressGroupingsError, + GetTxOutError, GetUnconfirmedBalance, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListSinceBlock, ListSinceBlockError, ListSinceBlockTransaction, ListSinceBlockTransactionError, ListTransactions, ListTransactionsItem, ListTransactionsItemError, ListUnspentItemError, ListWallets, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, - RawTransactionOutput, RescanBlockchain, ScriptType, SendMany, SendRawTransaction, - SendToAddress, SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, - SignRawTransaction, SignRawTransactionError, SoftforkReject, TransactionCategory, - UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, - VerifyTxOutProof, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WitnessUtxo, + RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, + SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, + SignRawTransactionError, SoftforkReject, TransactionCategory, UploadTarget, + ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof, + WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WitnessUtxo, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, AnalyzePsbtInputMissingError, DeriveAddresses, GetAddressInfoError, GetReceivedByLabel, - ImportMulti, ImportMultiEntry, JoinPsbts, JsonRpcError, ListReceivedByAddress, - ListReceivedByAddressItem, ListReceivedByLabel, ListReceivedByLabelError, ListWalletDir, - ListWalletDirWallet, UtxoUpdatePsbt, + GetZmqNotifications, ImportMulti, ImportMultiEntry, JoinPsbts, JsonRpcError, + ListReceivedByAddress, ListReceivedByAddressItem, ListReceivedByLabel, + ListReceivedByLabelError, ListWalletDir, ListWalletDirWallet, UtxoUpdatePsbt, }, v19::{ Bip9SoftforkInfo, Bip9SoftforkStatistics, Bip9SoftforkStatus, GetBalancesMine, @@ -299,7 +298,8 @@ pub use crate::{ v20::GenerateToDescriptor, v21::{ AddPeerAddress, GetIndexInfo, GetIndexInfoName, GetNetworkInfo, ImportDescriptors, - ImportDescriptorsResult, PsbtBumpFee, PsbtBumpFeeError, Send, SendError, UpgradeWallet, + ImportDescriptorsResult, PsbtBumpFee, PsbtBumpFeeError, Send, SendError, SendMany, + SendManyVerbose, UpgradeWallet, }, v22::{ Banned, EnumerateSigners, GetAddressInfo, GetAddressInfoEmbedded, GetNodeAddresses, @@ -327,9 +327,10 @@ pub use crate::{ AddrManInfoNetwork, ChainState, CreateWallet, DescriptorProcessPsbt, DescriptorProcessPsbtError, DumpTxOutSet, DumpTxOutSetError, GetAddrManInfo, GetBalances, GetBalancesError, GetChainStates, GetChainStatesError, GetPeerInfo, GetTransaction, - GetTransactionError, GetTxOutSetInfo, GetTxOutSetInfoError, LastProcessedBlock, - LastProcessedBlockError, LoadTxOutSet, LoadTxOutSetError, LoadWallet, Logging, PeerInfo, - SubmitPackage, SubmitPackageError, SubmitPackageTxResult, SubmitPackageTxResultError, + GetTransactionError, GetTxOutSetInfo, GetTxOutSetInfoError, GetWalletInfo, + GetWalletInfoError, GetWalletInfoScanning, LastProcessedBlock, LastProcessedBlockError, + LoadTxOutSet, LoadTxOutSetError, LoadWallet, Logging, PeerInfo, SubmitPackage, + SubmitPackageError, SubmitPackageTxResult, SubmitPackageTxResultError, SubmitPackageTxResultFees, SubmitPackageTxResultFeesError, UnloadWallet, WalletProcessPsbt, }, }; diff --git a/types/src/v28/mod.rs b/types/src/v28/mod.rs index 3e300966..9f748051 100644 --- a/types/src/v28/mod.rs +++ b/types/src/v28/mod.rs @@ -191,7 +191,7 @@ //! | getreceivedbylabel | version + model | | //! | gettransaction | version + model | | //! | getunconfirmedbalance | version + model | | -//! | getwalletinfo | version + model | UNTESTED | +//! | getwalletinfo | version + model | | //! | importaddress | returns nothing | | //! | importdescriptors | version | | //! | importmulti | version | | @@ -221,7 +221,7 @@ //! | restorewallet | version | | //! | send | version + model | | //! | sendall | version + model | | -//! | sendmany | version + model | UNTESTED | +//! | sendmany | version + model | | //! | sendtoaddress | version + model | | //! | sethdseed | returns nothing | | //! | setlabel | returns nothing | | @@ -246,7 +246,7 @@ //! //! | JSON-RPC Method Name | Returns | Notes | //! |:-----------------------------------|:---------------:|:--------------------------------------:| -//! | getzmqnotifications | version | UNTESTED | +//! | getzmqnotifications | version | | //! //! @@ -290,25 +290,24 @@ pub use crate::{ GetNetworkInfoNetwork, GetNewAddress, GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, GetRawTransaction, GetRawTransactionVerbose, GetRawTransactionVerboseError, GetReceivedByAddress, GetTransactionDetailError, GetTxOut, - GetTxOutError, GetUnconfirmedBalance, GetWalletInfo, GetWalletInfoError, - GetZmqNotifications, ListAddressGroupings, ListAddressGroupingsError, + GetTxOutError, GetUnconfirmedBalance, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListSinceBlock, ListSinceBlockError, ListSinceBlockTransaction, ListSinceBlockTransactionError, ListTransactions, ListTransactionsItem, ListTransactionsItemError, ListUnspentItemError, ListWallets, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, - RawTransactionOutput, RescanBlockchain, ScriptType, SendMany, SendRawTransaction, - SendToAddress, SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, - SignRawTransaction, SignRawTransactionError, SoftforkReject, TransactionCategory, - UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, - VerifyTxOutProof, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WitnessUtxo, + RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, + SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, + SignRawTransactionError, SoftforkReject, TransactionCategory, UploadTarget, + ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof, + WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WitnessUtxo, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, AnalyzePsbtInputMissingError, DeriveAddresses, GetAddressInfoError, GetReceivedByLabel, - ImportMulti, ImportMultiEntry, JoinPsbts, JsonRpcError, ListReceivedByAddress, - ListReceivedByAddressItem, ListReceivedByLabel, ListReceivedByLabelError, ListWalletDir, - ListWalletDirWallet, UtxoUpdatePsbt, + GetZmqNotifications, ImportMulti, ImportMultiEntry, JoinPsbts, JsonRpcError, + ListReceivedByAddress, ListReceivedByAddressItem, ListReceivedByLabel, + ListReceivedByLabelError, ListWalletDir, ListWalletDirWallet, UtxoUpdatePsbt, }, v19::{ Bip9SoftforkInfo, Bip9SoftforkStatistics, Bip9SoftforkStatus, GetBalancesMine, @@ -319,7 +318,7 @@ pub use crate::{ v20::GenerateToDescriptor, v21::{ AddPeerAddress, GetIndexInfo, GetIndexInfoName, ImportDescriptors, ImportDescriptorsResult, - PsbtBumpFee, PsbtBumpFeeError, Send, SendError, UpgradeWallet, + PsbtBumpFee, PsbtBumpFeeError, Send, SendError, SendMany, SendManyVerbose, UpgradeWallet, }, v22::{ Banned, EnumerateSigners, GetNodeAddresses, ListBanned, NodeAddress, ScriptPubkey, @@ -347,8 +346,9 @@ pub use crate::{ AddrManInfoNetwork, ChainState, CreateWallet, DescriptorProcessPsbt, DescriptorProcessPsbtError, DumpTxOutSet, DumpTxOutSetError, GetAddrManInfo, GetBalances, GetBalancesError, GetChainStates, GetChainStatesError, GetPeerInfo, GetTransactionError, - GetTxOutSetInfo, GetTxOutSetInfoError, LastProcessedBlock, LastProcessedBlockError, - LoadTxOutSet, LoadTxOutSetError, LoadWallet, PeerInfo, UnloadWallet, WalletProcessPsbt, + GetTxOutSetInfo, GetTxOutSetInfoError, GetWalletInfo, GetWalletInfoError, + GetWalletInfoScanning, LastProcessedBlock, LastProcessedBlockError, LoadTxOutSet, + LoadTxOutSetError, LoadWallet, PeerInfo, UnloadWallet, WalletProcessPsbt, }, v27::{GetPrioritisedTransactions, PrioritisedTransaction}, }; diff --git a/types/src/v29/mod.rs b/types/src/v29/mod.rs index 295bff69..56fc8a63 100644 --- a/types/src/v29/mod.rs +++ b/types/src/v29/mod.rs @@ -192,7 +192,7 @@ //! | getreceivedbylabel | version + model | | //! | gettransaction | version + model | | //! | getunconfirmedbalance | version + model | | -//! | getwalletinfo | version + model | UNTESTED | +//! | getwalletinfo | version + model | | //! | importaddress | returns nothing | | //! | importdescriptors | version | | //! | importmulti | version | | @@ -222,7 +222,7 @@ //! | restorewallet | version | | //! | send | version + model | | //! | sendall | version + model | | -//! | sendmany | version + model | UNTESTED | +//! | sendmany | version + model | | //! | sendtoaddress | version + model | | //! | sethdseed | returns nothing | | //! | setlabel | returns nothing | | @@ -247,7 +247,7 @@ //! //! | JSON-RPC Method Name | Returns | Notes | //! |:-----------------------------------|:---------------:|:--------------------------------------:| -//! | getzmqnotifications | version | UNTESTED | +//! | getzmqnotifications | version | | //! //! @@ -287,25 +287,24 @@ pub use crate::{ GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, GetRawTransaction, GetRawTransactionVerbose, GetRawTransactionVerboseError, GetReceivedByAddress, GetTransactionDetailError, GetTxOut, - GetTxOutError, GetUnconfirmedBalance, GetWalletInfo, GetWalletInfoError, - GetZmqNotifications, ListAddressGroupings, ListAddressGroupingsError, + GetTxOutError, GetUnconfirmedBalance, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListSinceBlock, ListSinceBlockError, ListSinceBlockTransaction, ListSinceBlockTransactionError, ListTransactions, ListTransactionsItem, ListTransactionsItemError, ListUnspentItemError, ListWallets, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, - RawTransactionOutput, RescanBlockchain, ScriptType, SendMany, SendRawTransaction, - SendToAddress, SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, - SignRawTransaction, SignRawTransactionError, TransactionCategory, UploadTarget, - ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof, - WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WitnessUtxo, + RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, + SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, + SignRawTransactionError, TransactionCategory, UploadTarget, ValidateAddress, + ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof, WalletCreateFundedPsbt, + WalletCreateFundedPsbtError, WitnessUtxo, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, AnalyzePsbtInputMissingError, DeriveAddresses, GetAddressInfoError, GetReceivedByLabel, - ImportMulti, ImportMultiEntry, JoinPsbts, JsonRpcError, ListReceivedByAddress, - ListReceivedByAddressItem, ListReceivedByLabel, ListReceivedByLabelError, ListWalletDir, - ListWalletDirWallet, UtxoUpdatePsbt, + GetZmqNotifications, ImportMulti, ImportMultiEntry, JoinPsbts, JsonRpcError, + ListReceivedByAddress, ListReceivedByAddressItem, ListReceivedByLabel, + ListReceivedByLabelError, ListWalletDir, ListWalletDirWallet, UtxoUpdatePsbt, }, v19::{ Bip9SoftforkInfo, Bip9SoftforkStatistics, Bip9SoftforkStatus, GetBalancesMine, @@ -316,7 +315,7 @@ pub use crate::{ v20::GenerateToDescriptor, v21::{ AddPeerAddress, GetIndexInfo, GetIndexInfoName, ImportDescriptors, ImportDescriptorsResult, - PsbtBumpFee, PsbtBumpFeeError, Send, SendError, UpgradeWallet, + PsbtBumpFee, PsbtBumpFeeError, Send, SendError, SendMany, SendManyVerbose, UpgradeWallet, }, v22::{ Banned, EnumerateSigners, GetNodeAddresses, ListBanned, NodeAddress, ScriptPubkey, @@ -343,9 +342,9 @@ pub use crate::{ v26::{ AddrManInfoNetwork, CreateWallet, DescriptorProcessPsbt, DescriptorProcessPsbtError, DumpTxOutSet, DumpTxOutSetError, GetAddrManInfo, GetBalances, GetBalancesError, - GetPeerInfo, GetTransactionError, GetTxOutSetInfo, GetTxOutSetInfoError, - LastProcessedBlock, LastProcessedBlockError, LoadTxOutSet, LoadTxOutSetError, LoadWallet, - PeerInfo, UnloadWallet, WalletProcessPsbt, + GetPeerInfo, GetTransactionError, GetTxOutSetInfo, GetTxOutSetInfoError, GetWalletInfo, + GetWalletInfoError, GetWalletInfoScanning, LastProcessedBlock, LastProcessedBlockError, + LoadTxOutSet, LoadTxOutSetError, LoadWallet, PeerInfo, UnloadWallet, WalletProcessPsbt, }, v27::{GetPrioritisedTransactions, PrioritisedTransaction}, v28::{