diff --git a/integration_test/tests/network.rs b/integration_test/tests/network.rs index 956ca99e..f145aa30 100644 --- a/integration_test/tests/network.rs +++ b/integration_test/tests/network.rs @@ -86,18 +86,15 @@ fn network__get_network_info__modelled() { } #[test] -// Core version 18 onwards. #[cfg(not(feature = "v17"))] fn network__get_node_addresses() { - let node = Node::with_wallet(Wallet::None, &[]); - let json: GetNodeAddresses = node.client.get_node_addresses().expect("getnodeaddresses"); - let res: Result = json.into_model(); - let model = res.expect("GetNodeAddresses into model"); - assert!(model.0.len() <= 2500); - if let Some(addr) = model.0.first() { - assert!(addr.port > 0); - assert!(addr.time > 1231006505); - } + let (node1, node2, node3) = integration_test::three_node_network(); + + node1.mine_a_block(); + node2.mine_a_block(); + node3.mine_a_block(); + + let _: GetNodeAddresses = node1.client.get_node_addresses().expect("getnodeaddresses"); } #[test] diff --git a/types/src/model/mod.rs b/types/src/model/mod.rs index cfb76977..4ae73829 100644 --- a/types/src/model/mod.rs +++ b/types/src/model/mod.rs @@ -37,9 +37,7 @@ pub use self::{ BlockTemplateTransaction, GetBlockTemplate, GetMiningInfo, GetPrioritisedTransactions, NextBlockInfo, PrioritisedTransaction, }, - network::{ - GetNetworkInfo, GetNetworkInfoAddress, GetNetworkInfoNetwork, GetNodeAddresses, NodeAddress, - }, + network::{GetNetworkInfo, GetNetworkInfoAddress, GetNetworkInfoNetwork}, raw_transactions::{ AnalyzePsbt, AnalyzePsbtInput, AnalyzePsbtInputMissing, CombinePsbt, CombineRawTransaction, ConvertToPsbt, CreatePsbt, CreateRawTransaction, DecodePsbt, DecodeRawTransaction, diff --git a/types/src/model/network.rs b/types/src/model/network.rs index cef8a88e..a91ebed9 100644 --- a/types/src/model/network.rs +++ b/types/src/model/network.rs @@ -5,8 +5,7 @@ //! These structs model the types returned by the JSON-RPC API but have concrete types //! and are not specific to a specific version of Bitcoin Core. -use bitcoin::address::NetworkUnchecked; -use bitcoin::{Address, FeeRate}; +use bitcoin::FeeRate; use serde::{Deserialize, Serialize}; /// Models the result of JSON-RPC method `getnetworkinfo`. @@ -74,26 +73,3 @@ pub struct GetNetworkInfoAddress { /// Relative score. pub score: u32, } - -/// Result of JSON-RPC method `getnodeaddresses`. -/// -/// > getnodeaddresses ( count ) -/// > -/// > Return known addresses which can potentially be used to find new nodes in the network. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] -#[serde(deny_unknown_fields)] -pub struct GetNodeAddresses(pub Vec); - -/// An item from the list returned by the JSON-RPC method `getnodeaddresses`. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] -#[serde(deny_unknown_fields)] -pub struct NodeAddress { - /// Timestamp in seconds since epoch (Jan 1 1970 GMT) when the node was last seen. - pub time: u64, - /// The services offered. - pub services: u64, - /// The address of the node. - pub address: Address, - /// The port of the node. - pub port: u16, -} diff --git a/types/src/v18/mod.rs b/types/src/v18/mod.rs index 441ffac0..36daf431 100644 --- a/types/src/v18/mod.rs +++ b/types/src/v18/mod.rs @@ -103,7 +103,7 @@ //! | getconnectioncount | version | | //! | getnettotals | version | | //! | getnetworkinfo | version + model | | -//! | getnodeaddresses | version + model | | +//! | getnodeaddresses | version | | //! | getpeerinfo | version | | //! | listbanned | version | | //! | ping | returns nothing | | diff --git a/types/src/v18/network/into.rs b/types/src/v18/network/into.rs deleted file mode 100644 index a91ef35f..00000000 --- a/types/src/v18/network/into.rs +++ /dev/null @@ -1,28 +0,0 @@ -// SPDX-License-Identifier: CC0-1.0 - -use bitcoin::address::NetworkUnchecked; -use bitcoin::{address, Address}; - -use super::{GetNodeAddresses, NodeAddress}; -use crate::model; - -impl GetNodeAddresses { - /// Converts version specific type to a version nonspecific, more strongly typed type. - pub fn into_model(self) -> Result { - let nodes = self.0.into_iter().map(|n| n.into_model()).collect::>()?; - Ok(model::GetNodeAddresses(nodes)) - } -} - -impl NodeAddress { - /// Converts version specific type to a version nonspecific, more strongly typed type. - pub fn into_model(self) -> Result { - let address = self.address.parse::>()?; - Ok(model::NodeAddress { - time: self.time, - services: self.services, - address, - port: self.port, - }) - } -} diff --git a/types/src/v18/network/mod.rs b/types/src/v18/network/mod.rs index 3fd7aa5d..942bc73a 100644 --- a/types/src/v18/network/mod.rs +++ b/types/src/v18/network/mod.rs @@ -4,8 +4,6 @@ //! //! Types for methods found under the `== Network ==` section of the API docs. -mod into; - use alloc::collections::BTreeMap; use serde::{Deserialize, Serialize}; diff --git a/types/src/v19/mod.rs b/types/src/v19/mod.rs index 376ced98..12be738e 100644 --- a/types/src/v19/mod.rs +++ b/types/src/v19/mod.rs @@ -103,7 +103,7 @@ //! | getconnectioncount | version | | //! | getnettotals | version | | //! | getnetworkinfo | version + model | | -//! | getnodeaddresses | version + model | | +//! | getnodeaddresses | version | | //! | getpeerinfo | version | | //! | listbanned | version | | //! | ping | returns nothing | | diff --git a/types/src/v20/mod.rs b/types/src/v20/mod.rs index 878c8b3b..f3b7816a 100644 --- a/types/src/v20/mod.rs +++ b/types/src/v20/mod.rs @@ -104,7 +104,7 @@ //! | getconnectioncount | version | | //! | getnettotals | version | | //! | getnetworkinfo | version + model | | -//! | getnodeaddresses | version + model | | +//! | getnodeaddresses | version | | //! | getpeerinfo | version | | //! | listbanned | version | | //! | ping | returns nothing | | diff --git a/types/src/v21/mod.rs b/types/src/v21/mod.rs index c71dc1f9..b3d7e8c4 100644 --- a/types/src/v21/mod.rs +++ b/types/src/v21/mod.rs @@ -105,7 +105,7 @@ //! | getconnectioncount | version | | //! | getnettotals | version | | //! | getnetworkinfo | version + model | | -//! | getnodeaddresses | version + model | | +//! | getnodeaddresses | version | | //! | getpeerinfo | version | | //! | listbanned | version | | //! | ping | returns nothing | | diff --git a/types/src/v22/mod.rs b/types/src/v22/mod.rs index 6506fef0..c3f7ac30 100644 --- a/types/src/v22/mod.rs +++ b/types/src/v22/mod.rs @@ -105,7 +105,7 @@ //! | getconnectioncount | version | | //! | getnettotals | version | | //! | getnetworkinfo | version + model | | -//! | getnodeaddresses | version + model | | +//! | getnodeaddresses | version | | //! | getpeerinfo | version | | //! | listbanned | version | | //! | ping | returns nothing | | diff --git a/types/src/v23/mod.rs b/types/src/v23/mod.rs index 6976d98b..94aa8a30 100644 --- a/types/src/v23/mod.rs +++ b/types/src/v23/mod.rs @@ -96,7 +96,7 @@ //! | getconnectioncount | version | | //! | getnettotals | version | | //! | getnetworkinfo | version + model | | -//! | getnodeaddresses | version + model | | +//! | getnodeaddresses | version | | //! | getpeerinfo | version | | //! | listbanned | version | | //! | ping | returns nothing | | diff --git a/types/src/v24/mod.rs b/types/src/v24/mod.rs index a6e165c6..1ea9701e 100644 --- a/types/src/v24/mod.rs +++ b/types/src/v24/mod.rs @@ -97,7 +97,7 @@ //! | getconnectioncount | version | | //! | getnettotals | version | | //! | getnetworkinfo | version + model | | -//! | getnodeaddresses | version + model | | +//! | getnodeaddresses | version | | //! | getpeerinfo | version | | //! | listbanned | version | | //! | ping | returns nothing | | diff --git a/types/src/v25/mod.rs b/types/src/v25/mod.rs index 68863d24..2facb710 100644 --- a/types/src/v25/mod.rs +++ b/types/src/v25/mod.rs @@ -98,7 +98,7 @@ //! | getconnectioncount | version | | //! | getnettotals | version | | //! | getnetworkinfo | version + model | | -//! | getnodeaddresses | version + model | | +//! | getnodeaddresses | version | | //! | getpeerinfo | version | | //! | listbanned | version | | //! | ping | returns nothing | | diff --git a/types/src/v26/mod.rs b/types/src/v26/mod.rs index a679065e..4edad3c7 100644 --- a/types/src/v26/mod.rs +++ b/types/src/v26/mod.rs @@ -104,7 +104,7 @@ //! | getconnectioncount | version | | //! | getnettotals | version | | //! | getnetworkinfo | version + model | | -//! | getnodeaddresses | version + model | | +//! | getnodeaddresses | version | | //! | getpeerinfo | version | | //! | listbanned | version | | //! | ping | returns nothing | | diff --git a/types/src/v27/mod.rs b/types/src/v27/mod.rs index 5054ff65..fc04ef35 100644 --- a/types/src/v27/mod.rs +++ b/types/src/v27/mod.rs @@ -104,7 +104,7 @@ //! | getconnectioncount | version | | //! | getnettotals | version | | //! | getnetworkinfo | version + model | | -//! | getnodeaddresses | version + model | TODO | +//! | getnodeaddresses | version | TODO | //! | getpeerinfo | version | | //! | listbanned | version | | //! | ping | returns nothing | | diff --git a/types/src/v28/mod.rs b/types/src/v28/mod.rs index 8991dc17..501e3aac 100644 --- a/types/src/v28/mod.rs +++ b/types/src/v28/mod.rs @@ -104,7 +104,7 @@ //! | getconnectioncount | version | | //! | getnettotals | version | | //! | getnetworkinfo | version + model | | -//! | getnodeaddresses | version + model | | +//! | getnodeaddresses | version | | //! | getpeerinfo | version | | //! | listbanned | version | | //! | ping | returns nothing | | diff --git a/types/src/v29/mod.rs b/types/src/v29/mod.rs index 1ed2d453..158ac36e 100644 --- a/types/src/v29/mod.rs +++ b/types/src/v29/mod.rs @@ -105,7 +105,7 @@ //! | getconnectioncount | version | | //! | getnettotals | version | | //! | getnetworkinfo | version + model | | -//! | getnodeaddresses | version + model | | +//! | getnodeaddresses | version | | //! | getpeerinfo | version | | //! | listbanned | version | | //! | ping | returns nothing | | diff --git a/verify/src/method/v18.rs b/verify/src/method/v18.rs index 13fa3a27..8c8194c2 100644 --- a/verify/src/method/v18.rs +++ b/verify/src/method/v18.rs @@ -60,7 +60,7 @@ pub const METHODS: &[Method] = &[ Method::new_no_model("getconnectioncount", "GetConnectionCount", "get_connection_count"), Method::new_no_model("getnettotals", "GetNetTotals", "get_net_totals"), Method::new_modelled("getnetworkinfo", "GetNetworkInfo", "get_network_info"), - Method::new_modelled("getnodeaddresses", "GetNodeAddresses", "get_node_addresses"), + Method::new_no_model("getnodeaddresses", "GetNodeAddresses", "get_node_addresses"), Method::new_no_model("getpeerinfo", "GetPeerInfo", "get_peer_info"), Method::new_no_model("listbanned", "ListBanned", "list_banned"), Method::new_nothing("ping", "ping"), diff --git a/verify/src/method/v19.rs b/verify/src/method/v19.rs index 19b0ff4a..c74207b9 100644 --- a/verify/src/method/v19.rs +++ b/verify/src/method/v19.rs @@ -60,7 +60,7 @@ pub const METHODS: &[Method] = &[ Method::new_no_model("getconnectioncount", "GetConnectionCount", "get_connection_count"), Method::new_no_model("getnettotals", "GetNetTotals", "get_net_totals"), Method::new_modelled("getnetworkinfo", "GetNetworkInfo", "get_network_info"), - Method::new_modelled("getnodeaddresses", "GetNodeAddresses", "get_node_addresses"), + Method::new_no_model("getnodeaddresses", "GetNodeAddresses", "get_node_addresses"), Method::new_no_model("getpeerinfo", "GetPeerInfo", "get_peer_info"), Method::new_no_model("listbanned", "ListBanned", "list_banned"), Method::new_nothing("ping", "ping"), diff --git a/verify/src/method/v20.rs b/verify/src/method/v20.rs index 4c11b843..f207c9aa 100644 --- a/verify/src/method/v20.rs +++ b/verify/src/method/v20.rs @@ -61,7 +61,7 @@ pub const METHODS: &[Method] = &[ Method::new_no_model("getconnectioncount", "GetConnectionCount", "get_connection_count"), Method::new_no_model("getnettotals", "GetNetTotals", "get_net_totals"), Method::new_modelled("getnetworkinfo", "GetNetworkInfo", "get_network_info"), - Method::new_modelled("getnodeaddresses", "GetNodeAddresses", "get_node_addresses"), + Method::new_no_model("getnodeaddresses", "GetNodeAddresses", "get_node_addresses"), Method::new_no_model("getpeerinfo", "GetPeerInfo", "get_peer_info"), Method::new_no_model("listbanned", "ListBanned", "list_banned"), Method::new_nothing("ping", "ping"), diff --git a/verify/src/method/v21.rs b/verify/src/method/v21.rs index 1ec5652d..fa225299 100644 --- a/verify/src/method/v21.rs +++ b/verify/src/method/v21.rs @@ -62,7 +62,7 @@ pub const METHODS: &[Method] = &[ Method::new_no_model("getconnectioncount", "GetConnectionCount", "get_connection_count"), Method::new_no_model("getnettotals", "GetNetTotals", "get_net_totals"), Method::new_modelled("getnetworkinfo", "GetNetworkInfo", "get_network_info"), - Method::new_modelled("getnodeaddresses", "GetNodeAddresses", "get_node_addresses"), + Method::new_no_model("getnodeaddresses", "GetNodeAddresses", "get_node_addresses"), Method::new_no_model("getpeerinfo", "GetPeerInfo", "get_peer_info"), Method::new_no_model("listbanned", "ListBanned", "list_banned"), Method::new_nothing("ping", "ping"), diff --git a/verify/src/method/v22.rs b/verify/src/method/v22.rs index c4a54e09..7d4f6f26 100644 --- a/verify/src/method/v22.rs +++ b/verify/src/method/v22.rs @@ -62,7 +62,7 @@ pub const METHODS: &[Method] = &[ Method::new_no_model("getconnectioncount", "GetConnectionCount", "get_connection_count"), Method::new_no_model("getnettotals", "GetNetTotals", "get_net_totals"), Method::new_modelled("getnetworkinfo", "GetNetworkInfo", "get_network_info"), - Method::new_modelled("getnodeaddresses", "GetNodeAddresses", "get_node_addresses"), + Method::new_no_model("getnodeaddresses", "GetNodeAddresses", "get_node_addresses"), Method::new_no_model("getpeerinfo", "GetPeerInfo", "get_peer_info"), Method::new_no_model("listbanned", "ListBanned", "list_banned"), Method::new_nothing("ping", "ping"), diff --git a/verify/src/method/v23.rs b/verify/src/method/v23.rs index 6b7d3548..97b30788 100644 --- a/verify/src/method/v23.rs +++ b/verify/src/method/v23.rs @@ -60,7 +60,7 @@ pub const METHODS: &[Method] = &[ Method::new_no_model("getconnectioncount", "GetConnectionCount", "get_connection_count"), Method::new_no_model("getnettotals", "GetNetTotals", "get_net_totals"), Method::new_modelled("getnetworkinfo", "GetNetworkInfo", "get_network_info"), - Method::new_modelled("getnodeaddresses", "GetNodeAddresses", "get_node_addresses"), + Method::new_no_model("getnodeaddresses", "GetNodeAddresses", "get_node_addresses"), Method::new_no_model("getpeerinfo", "GetPeerInfo", "get_peer_info"), Method::new_no_model("listbanned", "ListBanned", "list_banned"), Method::new_nothing("ping", "ping"), diff --git a/verify/src/method/v24.rs b/verify/src/method/v24.rs index ef65a60a..50e0a634 100644 --- a/verify/src/method/v24.rs +++ b/verify/src/method/v24.rs @@ -61,7 +61,7 @@ pub const METHODS: &[Method] = &[ Method::new_no_model("getconnectioncount", "GetConnectionCount", "get_connection_count"), Method::new_no_model("getnettotals", "GetNetTotals", "get_net_totals"), Method::new_modelled("getnetworkinfo", "GetNetworkInfo", "get_network_info"), - Method::new_modelled("getnodeaddresses", "GetNodeAddresses", "get_node_addresses"), + Method::new_no_model("getnodeaddresses", "GetNodeAddresses", "get_node_addresses"), Method::new_no_model("getpeerinfo", "GetPeerInfo", "get_peer_info"), Method::new_no_model("listbanned", "ListBanned", "list_banned"), Method::new_nothing("ping", "ping"), diff --git a/verify/src/method/v25.rs b/verify/src/method/v25.rs index f61be54f..cd7f90eb 100644 --- a/verify/src/method/v25.rs +++ b/verify/src/method/v25.rs @@ -62,7 +62,7 @@ pub const METHODS: &[Method] = &[ Method::new_no_model("getconnectioncount", "GetConnectionCount", "get_connection_count"), Method::new_no_model("getnettotals", "GetNetTotals", "get_net_totals"), Method::new_modelled("getnetworkinfo", "GetNetworkInfo", "get_network_info"), - Method::new_modelled("getnodeaddresses", "GetNodeAddresses", "get_node_addresses"), + Method::new_no_model("getnodeaddresses", "GetNodeAddresses", "get_node_addresses"), Method::new_no_model("getpeerinfo", "GetPeerInfo", "get_peer_info"), Method::new_no_model("listbanned", "ListBanned", "list_banned"), Method::new_nothing("ping", "ping"), diff --git a/verify/src/method/v26.rs b/verify/src/method/v26.rs index f2f15efc..e4e4e3fb 100644 --- a/verify/src/method/v26.rs +++ b/verify/src/method/v26.rs @@ -68,7 +68,7 @@ pub const METHODS: &[Method] = &[ Method::new_no_model("getconnectioncount", "GetConnectionCount", "get_connection_count"), Method::new_no_model("getnettotals", "GetNetTotals", "get_net_totals"), Method::new_modelled("getnetworkinfo", "GetNetworkInfo", "get_network_info"), - Method::new_modelled("getnodeaddresses", "GetNodeAddresses", "get_node_addresses"), + Method::new_no_model("getnodeaddresses", "GetNodeAddresses", "get_node_addresses"), Method::new_no_model("getpeerinfo", "GetPeerInfo", "get_peer_info"), Method::new_no_model("listbanned", "ListBanned", "list_banned"), Method::new_nothing("ping", "ping"), diff --git a/verify/src/method/v27.rs b/verify/src/method/v27.rs index 6aeb4e33..b3bd1132 100644 --- a/verify/src/method/v27.rs +++ b/verify/src/method/v27.rs @@ -70,7 +70,7 @@ pub const METHODS: &[Method] = &[ Method::new_no_model("getconnectioncount", "GetConnectionCount", "get_connection_count"), Method::new_no_model("getnettotals", "GetNetTotals", "get_net_totals"), Method::new_modelled("getnetworkinfo", "GetNetworkInfo", "get_network_info"), - Method::new_modelled("getnodeaddresses", "GetNodeAddresses", "get_node_addresses"), + Method::new_no_model("getnodeaddresses", "GetNodeAddresses", "get_node_addresses"), Method::new_no_model("getpeerinfo", "GetPeerInfo", "get_peer_info"), Method::new_no_model("listbanned", "ListBanned", "list_banned"), Method::new_nothing("ping", "ping"), diff --git a/verify/src/method/v28.rs b/verify/src/method/v28.rs index 5cda224c..267ca812 100644 --- a/verify/src/method/v28.rs +++ b/verify/src/method/v28.rs @@ -70,7 +70,7 @@ pub const METHODS: &[Method] = &[ Method::new_no_model("getconnectioncount", "GetConnectionCount", "get_connection_count"), Method::new_no_model("getnettotals", "GetNetTotals", "get_net_totals"), Method::new_modelled("getnetworkinfo", "GetNetworkInfo", "get_network_info"), - Method::new_modelled("getnodeaddresses", "GetNodeAddresses", "get_node_addresses"), + Method::new_no_model("getnodeaddresses", "GetNodeAddresses", "get_node_addresses"), Method::new_no_model("getpeerinfo", "GetPeerInfo", "get_peer_info"), Method::new_no_model("listbanned", "ListBanned", "list_banned"), Method::new_nothing("ping", "ping"), diff --git a/verify/src/method/v29.rs b/verify/src/method/v29.rs index 8ece8f4b..54fb907f 100644 --- a/verify/src/method/v29.rs +++ b/verify/src/method/v29.rs @@ -71,7 +71,7 @@ pub const METHODS: &[Method] = &[ Method::new_no_model("getconnectioncount", "GetConnectionCount", "get_connection_count"), Method::new_no_model("getnettotals", "GetNetTotals", "get_net_totals"), Method::new_modelled("getnetworkinfo", "GetNetworkInfo", "get_network_info"), - Method::new_modelled("getnodeaddresses", "GetNodeAddresses", "get_node_addresses"), + Method::new_no_model("getnodeaddresses", "GetNodeAddresses", "get_node_addresses"), Method::new_no_model("getpeerinfo", "GetPeerInfo", "get_peer_info"), Method::new_no_model("listbanned", "ListBanned", "list_banned"), Method::new_nothing("ping", "ping"),