|
| 1 | +// SPDX-License-Identifier: CC0-1.0 |
| 2 | + |
| 3 | +//! Types for methods found under the `== Network ==` section of the API docs. |
| 4 | +//! |
| 5 | +//! These structs model the types returned by the JSON-RPC API but have concrete types |
| 6 | +//! and are not specific to a specific version of Bitcoin Core. |
| 7 | +
|
| 8 | +use bitcoin::FeeRate; |
| 9 | +use serde::{Deserialize, Serialize}; |
| 10 | + |
| 11 | +/// Models the result of JSON-RPC method `getnetworkinfo`. |
| 12 | +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] |
| 13 | +pub struct GetNetworkInfo { |
| 14 | + /// The server version. |
| 15 | + pub version: usize, |
| 16 | + /// The server subversion string. |
| 17 | + pub subversion: String, |
| 18 | + /// The protocol version. |
| 19 | + pub protocol_version: usize, |
| 20 | + /// The services we offer to the network (hex string). |
| 21 | + pub local_services: String, |
| 22 | + /// `true` if transaction relay is requested from peers. |
| 23 | + pub local_relay: bool, |
| 24 | + /// The time offset. |
| 25 | + pub time_offset: isize, |
| 26 | + /// The total number of connections. |
| 27 | + pub connections: usize, |
| 28 | + /// Whether p2p networking is enabled. |
| 29 | + pub network_active: bool, |
| 30 | + /// Information per network. |
| 31 | + pub networks: Vec<GetNetworkInfoNetwork>, |
| 32 | + /// Minimum relay fee rate for transactions. |
| 33 | + pub relay_fee: Option<FeeRate>, // `Some` if parsing succeeds. |
| 34 | + /// Minimum fee rate increment for mempool limiting or replacement. |
| 35 | + pub incremental_fee: Option<FeeRate>, // `Some` if parsing succeeds. |
| 36 | + /// List of local addresses. |
| 37 | + pub local_addresses: Vec<GetNetworkInfoAddress>, |
| 38 | + /// Any network and blockchain warnings. |
| 39 | + pub warnings: String, |
| 40 | +} |
| 41 | + |
| 42 | +/// Part of the result of the JSON-RPC method `getnetworkinfo` (information per network). |
| 43 | +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] |
| 44 | +pub struct GetNetworkInfoNetwork { |
| 45 | + /// Network (ipv4, ipv6, onion, i2p, cjdns). |
| 46 | + pub name: String, |
| 47 | + /// Is the network limited using -onlynet?. |
| 48 | + pub limited: bool, |
| 49 | + /// Is the network reachable? |
| 50 | + pub reachable: bool, |
| 51 | + /// ("host:port"): The proxy that is used for this network, or empty if none. |
| 52 | + pub proxy: String, |
| 53 | + /// Whether randomized credentials are used. |
| 54 | + pub proxy_randomize_credentials: bool, |
| 55 | +} |
| 56 | + |
| 57 | +/// Part of the result of the JSON-RPC method `getnetworkinfo` (local address info). |
| 58 | +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] |
| 59 | +pub struct GetNetworkInfoAddress { |
| 60 | + /// Network address. |
| 61 | + pub address: String, |
| 62 | + /// Network port. |
| 63 | + pub port: u16, |
| 64 | + /// Relative score. |
| 65 | + pub score: u32, |
| 66 | +} |
0 commit comments