Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions client/src/client_sync/v17/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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`.
Expand Down
15 changes: 15 additions & 0 deletions client/src/client_sync/v17/zmq.rs
Original file line number Diff line number Diff line change
@@ -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<Vec<GetZmqNotifications>> {
self.call("getzmqnotifications", &[])
}
}
};
}
3 changes: 3 additions & 0 deletions client/src/client_sync/v18/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!();
3 changes: 3 additions & 0 deletions client/src/client_sync/v19/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!();
3 changes: 3 additions & 0 deletions client/src/client_sync/v20/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!();
3 changes: 3 additions & 0 deletions client/src/client_sync/v21/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,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)]
Expand Down
3 changes: 3 additions & 0 deletions client/src/client_sync/v22/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,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!();
3 changes: 3 additions & 0 deletions client/src/client_sync/v23/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,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`.
Expand Down
3 changes: 3 additions & 0 deletions client/src/client_sync/v24/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,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!();
3 changes: 3 additions & 0 deletions client/src/client_sync/v25/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,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!();
3 changes: 3 additions & 0 deletions client/src/client_sync/v26/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,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!();
3 changes: 3 additions & 0 deletions client/src/client_sync/v27/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,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!();
3 changes: 3 additions & 0 deletions client/src/client_sync/v28/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,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!();
3 changes: 3 additions & 0 deletions client/src/client_sync/v29/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,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 {
Expand Down
22 changes: 22 additions & 0 deletions integration_test/tests/zmq.rs
Original file line number Diff line number Diff line change
@@ -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<GetZmqNotifications> = node.client.get_zmq_notifications().expect("getzmqnotifications");
let zmq_notification = &list[0];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will panic if the list is empty. While that does prove that its not, and since its a test, panic is ok for fail. It would be nicer to use first and call unwrap or expect.

assert_eq!(zmq_notification.type_, "pubhashblock");
assert_eq!(zmq_notification.address, "tcp://127.0.0.1:29000");
}
2 changes: 1 addition & 1 deletion types/src/v17/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@
//!
//! | JSON-RPC Method Name | Returns | Notes |
//! |:-----------------------------------|:---------------:|:--------------------------------------:|
//! | getzmqnotifications | version | UNTESTED |
//! | getzmqnotifications | version | |
//!
//! </details>
Expand Down
8 changes: 5 additions & 3 deletions types/src/v18/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@
//!
//! | JSON-RPC Method Name | Returns | Notes |
//! |:-----------------------------------|:---------------:|:--------------------------------------:|
//! | getzmqnotifications | version | UNTESTED |
//! | getzmqnotifications | version | |
//!
//! </details>

Expand All @@ -229,6 +229,7 @@ mod network;
mod raw_transactions;
mod util;
mod wallet;
mod zmq;

#[doc(inline)]
pub use self::{
Expand All @@ -249,6 +250,7 @@ pub use self::{
ListReceivedByAddressItem, ListReceivedByLabel, ListReceivedByLabelError, ListUnspent,
ListUnspentItem, ListWalletDir, ListWalletDirWallet,
},
zmq::GetZmqNotifications,
};
#[doc(inline)]
pub use crate::v17::{
Expand All @@ -271,8 +273,8 @@ pub use crate::v17::{
GetRawTransactionVerboseError, GetReceivedByAddress, GetTransaction, GetTransactionDetail,
GetTransactionDetailError, GetTransactionError, GetTxOut, GetTxOutError, GetTxOutSetInfo,
GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfo, GetWalletInfoError,
GetZmqNotifications, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem,
ListBanned, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError,
ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListBanned,
ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError,
ListReceivedByAddressError, ListSinceBlock, ListSinceBlockError, ListSinceBlockTransaction,
ListSinceBlockTransactionError, ListTransactions, ListTransactionsItem,
ListTransactionsItemError, ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked,
Expand Down
24 changes: 24 additions & 0 deletions types/src/v18/zmq.rs
Original file line number Diff line number Diff line change
@@ -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,
}
14 changes: 7 additions & 7 deletions types/src/v19/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
//!
//! | JSON-RPC Method Name | Returns | Notes |
//! |:-----------------------------------|:---------------:|:--------------------------------------:|
//! | getzmqnotifications | version | UNTESTED |
//! | getzmqnotifications | version | |
//!
//! </details>

Expand Down Expand Up @@ -269,8 +269,8 @@ pub use crate::v17::{
GetRawTransactionVerboseError, GetReceivedByAddress, GetTransactionDetail,
GetTransactionDetailError, GetTransactionError, GetTxOut, GetTxOutError, GetTxOutSetInfo,
GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfo, GetWalletInfoError,
GetZmqNotifications, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem,
ListBanned, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError,
ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListBanned,
ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError,
ListReceivedByAddressError, ListSinceBlock, ListSinceBlockError, ListSinceBlockTransaction,
ListSinceBlockTransactionError, ListTransactions, ListTransactionsItem,
ListTransactionsItemError, ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked,
Expand All @@ -285,8 +285,8 @@ pub use crate::v17::{
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,
};
30 changes: 15 additions & 15 deletions types/src/v20/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@
//!
//! | JSON-RPC Method Name | Returns | Notes |
//! |:-----------------------------------|:---------------:|:--------------------------------------:|
//! | getzmqnotifications | version | UNTESTED |
//! | getzmqnotifications | version | |
//!
//! </details>

Expand Down Expand Up @@ -263,24 +263,24 @@ pub use crate::{
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,
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,
},
Expand Down
29 changes: 14 additions & 15 deletions types/src/v21/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@
//!
//! | JSON-RPC Method Name | Returns | Notes |
//! |:-----------------------------------|:---------------:|:--------------------------------------:|
//! | getzmqnotifications | version | UNTESTED |
//! | getzmqnotifications | version | |
//!
//! </details>

Expand Down Expand Up @@ -279,24 +279,23 @@ pub use crate::{
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,
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,
},
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,
},
Expand Down
Loading