pub struct Client {
pub(crate) baseurl: String,
pub(crate) client: Client,
}Expand description
Client for hoprd-api
API enabling developers to interact with a hoprd node programatically through HTTP REST API.
Version: 4.11.0
Fields§
§baseurl: String§client: ClientImplementations§
Source§impl Client
impl Client
Sourcepub fn new(baseurl: &str) -> Self
pub fn new(baseurl: &str) -> Self
Create a new client.
baseurl is the base URL provided to the internal
reqwest::Client, and should include a scheme and hostname,
as well as port and a path stem if applicable.
Sourcepub fn new_with_client(baseurl: &str, client: Client) -> Self
pub fn new_with_client(baseurl: &str, client: Client) -> Self
Construct a new client with an existing reqwest::Client,
allowing more control over its configuration.
baseurl is the base URL provided to the internal
reqwest::Client, and should include a scheme and hostname,
as well as port and a path stem if applicable.
Source§impl Client
impl Client
Sourcepub async fn addresses<'a>(
&'a self,
) -> Result<ResponseValue<AccountAddressesResponse>, Error<()>>
pub async fn addresses<'a>( &'a self, ) -> Result<ResponseValue<AccountAddressesResponse>, Error<()>>
Get node’s native addresses
Sends a GET request to /api/v4/account/addresses
Sourcepub async fn balances<'a>(
&'a self,
) -> Result<ResponseValue<AccountBalancesResponse>, Error<()>>
pub async fn balances<'a>( &'a self, ) -> Result<ResponseValue<AccountBalancesResponse>, Error<()>>
Get node’s and associated Safe’s HOPR and native balances as the allowance for HOPR tokens to be drawn by HoprChannels from Safe
HOPR tokens from the Safe balance are used to fund the payment channels between this node and other nodes on the network. NATIVE balance of the Node is used to pay for the gas fees for the blockchain.
Sends a GET request to /api/v4/account/balances
Sourcepub async fn withdraw<'a>(
&'a self,
body: &'a WithdrawBodyRequest,
) -> Result<ResponseValue<WithdrawResponse>, Error<()>>
pub async fn withdraw<'a>( &'a self, body: &'a WithdrawBodyRequest, ) -> Result<ResponseValue<WithdrawResponse>, Error<()>>
Withdraw funds from this node to the ethereum wallet address
Withdraw funds from this node to the ethereum wallet address
Sends a POST request to /api/v4/account/withdraw
Arguments:
body: Request body for the withdraw endpoint
Sourcepub async fn list_channels<'a>(
&'a self,
full_topology: Option<bool>,
including_closed: Option<bool>,
) -> Result<ResponseValue<NodeChannelsResponse>, Error<()>>
pub async fn list_channels<'a>( &'a self, full_topology: Option<bool>, including_closed: Option<bool>, ) -> Result<ResponseValue<NodeChannelsResponse>, Error<()>>
Lists channels opened to/from this node. Alternatively, it can print all the channels in the network as this node sees them
List channels opened to/from this node. Alternatively, it can print all the channels in the network as this node sees them.
Sends a GET request to /api/v4/channels
Arguments:
full_topology: Should all channels (not only the ones concerning this node) be enumerated?including_closed: Should be the closed channels included?
Sourcepub async fn open_channel<'a>(
&'a self,
body: &'a OpenChannelBodyRequest,
) -> Result<ResponseValue<OpenChannelResponse>, Error<()>>
pub async fn open_channel<'a>( &'a self, body: &'a OpenChannelBodyRequest, ) -> Result<ResponseValue<OpenChannelResponse>, Error<()>>
Opens a channel to the given on-chain address with the given initial stake of HOPR tokens
Opens a channel to the given on-chain address with the given initial stake of HOPR tokens.
Sends a POST request to /api/v4/channels
Arguments:
body: Open channel request specification: on-chain address of the counterparty and the initial HOPR token stake.
Sourcepub async fn show_channel<'a>(
&'a self,
address: &'a str,
direction: Option<ChannelDirection>,
) -> Result<ResponseValue<ChannelInfoResponse>, Error<()>>
pub async fn show_channel<'a>( &'a self, address: &'a str, direction: Option<ChannelDirection>, ) -> Result<ResponseValue<ChannelInfoResponse>, Error<()>>
Returns information about the channel with the given counterparty address in the given direction
Returns information about the channel with the given counterparty address. Use the direction query parameter to choose between the outgoing (this node → counterparty, default) and incoming (counterparty → this node) channel.
Sends a GET request to /api/v4/channels/{address}
Arguments:
address: On-chain address of the counterparty.direction: Direction of the channel relative to this node. Defaults tooutgoing.
Sourcepub async fn close_channel<'a>(
&'a self,
address: &'a str,
direction: Option<ChannelDirection>,
) -> Result<ResponseValue<CloseChannelResponse>, Error<()>>
pub async fn close_channel<'a>( &'a self, address: &'a str, direction: Option<ChannelDirection>, ) -> Result<ResponseValue<CloseChannelResponse>, Error<()>>
Closes the channel with the given counterparty in the given direction
Closes the channel with the given counterparty. Use the direction query parameter to choose between the outgoing (this node → counterparty, default) and incoming (counterparty → this node) channel.
Sends a DELETE request to /api/v4/channels/{address}
Arguments:
address: On-chain address of the counterparty.direction: Direction of the channel relative to this node. Defaults tooutgoing.
Sourcepub async fn fund_channel<'a>(
&'a self,
address: &'a str,
body: &'a FundBodyRequest,
) -> Result<ResponseValue<FundChannelResponse>, Error<()>>
pub async fn fund_channel<'a>( &'a self, address: &'a str, body: &'a FundBodyRequest, ) -> Result<ResponseValue<FundChannelResponse>, Error<()>>
Funds the outgoing channel to the given counterparty with the given amount of HOPR tokens
Funds the outgoing channel to the given counterparty with the given amount of HOPR tokens.
Sends a POST request to /api/v4/channels/{address}/fund
Arguments:
address: On-chain address of the counterparty.body: Specifies the amount of HOPR tokens to fund a channel with.
Sourcepub async fn announced<'a>(
&'a self,
) -> Result<ResponseValue<Vec<AnnouncedPeerResponse>>, Error<()>>
pub async fn announced<'a>( &'a self, ) -> Result<ResponseValue<Vec<AnnouncedPeerResponse>>, Error<()>>
Lists all announced peers
List all announced peers
Sends a GET request to /api/v4/network/announced
Sourcepub async fn connected<'a>(
&'a self,
) -> Result<ResponseValue<Vec<ConnectedPeerResponse>>, Error<()>>
pub async fn connected<'a>( &'a self, ) -> Result<ResponseValue<Vec<ConnectedPeerResponse>>, Error<()>>
Lists peers with immediate observation data from the network graph
List connected peers with immediate observation data from the network graph
Sends a GET request to /api/v4/network/connected
Sourcepub async fn graph<'a>(
&'a self,
reachable_only: Option<bool>,
) -> Result<ResponseValue<ByteStream>, Error<()>>
pub async fn graph<'a>( &'a self, reachable_only: Option<bool>, ) -> Result<ResponseValue<ByteStream>, Error<()>>
Returns the network graph in DOT (Graphviz) format
Get the network graph in DOT (Graphviz) format
Sends a GET request to /api/v4/network/graph
Arguments:
reachable_only: When true, only include edges reachable from this node via directed traversal. Disconnected subgraphs that cannot be routed through are excluded.
Sourcepub async fn price<'a>(
&'a self,
) -> Result<ResponseValue<TicketPriceResponse>, Error<()>>
pub async fn price<'a>( &'a self, ) -> Result<ResponseValue<TicketPriceResponse>, Error<()>>
Gets the current ticket price
Get the current ticket price
Sends a GET request to /api/v4/network/price
Sourcepub async fn probability<'a>(
&'a self,
) -> Result<ResponseValue<TicketProbabilityResponse>, Error<()>>
pub async fn probability<'a>( &'a self, ) -> Result<ResponseValue<TicketProbabilityResponse>, Error<()>>
Gets the current minimum incoming ticket winning probability defined by the network
Get the current minimum incoming ticket winning probability defined by the network
Sends a GET request to /api/v4/network/probability
Sourcepub async fn configuration<'a>(
&'a self,
) -> Result<ResponseValue<HashMap<String, String>>, Error<()>>
pub async fn configuration<'a>( &'a self, ) -> Result<ResponseValue<HashMap<String, String>>, Error<()>>
Get the configuration of the running node
Get the configuration of the running node
Sends a GET request to /api/v4/node/configuration
Sourcepub async fn info<'a>(
&'a self,
) -> Result<ResponseValue<NodeInfoResponse>, Error<()>>
pub async fn info<'a>( &'a self, ) -> Result<ResponseValue<NodeInfoResponse>, Error<()>>
Get information about this HOPR Node
Get information about this HOPR Node
Sends a GET request to /api/v4/node/info
Sourcepub async fn version<'a>(
&'a self,
) -> Result<ResponseValue<NodeVersionResponse>, Error<()>>
pub async fn version<'a>( &'a self, ) -> Result<ResponseValue<NodeVersionResponse>, Error<()>>
Get the release version of the running node
Get the release version of the running node
Sends a GET request to /api/v4/node/version
Sourcepub async fn show_peer_info<'a>(
&'a self,
address: &'a str,
) -> Result<ResponseValue<NodePeerInfoResponse>, Error<()>>
pub async fn show_peer_info<'a>( &'a self, address: &'a str, ) -> Result<ResponseValue<NodePeerInfoResponse>, Error<()>>
Returns comprehensive information about the given peer
Includes announced and observed multiaddresses, QoS observation data from the network graph, and the state of any channels between this node and the peer.
Sends a GET request to /api/v4/peers/{address}
Arguments:
address: On-chain address of the requested peer
Sourcepub async fn ping_peer<'a>(
&'a self,
address: &'a str,
) -> Result<ResponseValue<PingResponse>, Error<()>>
pub async fn ping_peer<'a>( &'a self, address: &'a str, ) -> Result<ResponseValue<PingResponse>, Error<()>>
Directly pings the given peer
Directly ping the given peer
Sends a POST request to /api/v4/peers/{address}/ping
Arguments:
address: On-chain address of the requested peer
Sourcepub async fn session_config<'a>(
&'a self,
id: &'a str,
) -> Result<ResponseValue<SessionConfig>, Error<()>>
pub async fn session_config<'a>( &'a self, id: &'a str, ) -> Result<ResponseValue<SessionConfig>, Error<()>>
Gets configuration of an existing active session.
Sends a GET request to /api/v4/session/config/{id}
Arguments:
id: Session ID
Sourcepub async fn adjust_session<'a>(
&'a self,
id: &'a str,
body: &'a SessionConfig,
) -> Result<ResponseValue<ByteStream>, Error<ApiError>>
pub async fn adjust_session<'a>( &'a self, id: &'a str, body: &'a SessionConfig, ) -> Result<ResponseValue<ByteStream>, Error<ApiError>>
Updates configuration of an existing active session.
Sends a POST request to /api/v4/session/config/{id}
Arguments:
id: Session IDbody: Allows updating of several parameters of an existing active session.
Sourcepub async fn list_clients<'a>(
&'a self,
protocol: &'a str,
) -> Result<ResponseValue<Vec<SessionClientResponse>>, Error<()>>
pub async fn list_clients<'a>( &'a self, protocol: &'a str, ) -> Result<ResponseValue<Vec<SessionClientResponse>>, Error<()>>
Lists existing Session listeners for the given IP protocol
Lists existing Session listeners for the given IP protocol.
Sends a GET request to /api/v4/session/{protocol}
Arguments:
protocol: IP transport protocol
Sourcepub async fn create_client<'a>(
&'a self,
protocol: &'a str,
body: &'a SessionClientRequest,
) -> Result<ResponseValue<SessionClientResponse>, Error<()>>
pub async fn create_client<'a>( &'a self, protocol: &'a str, body: &'a SessionClientRequest, ) -> Result<ResponseValue<SessionClientResponse>, Error<()>>
Creates a new client session returning the given session listening host and port over TCP or UDP. If no listening port is given in the request, the socket will be bound to a random free port and returned in the response. Different capabilities can be configured for the session, such as data segmentation or retransmission
Creates a new client HOPR session that will start listening on a dedicated port. Once the port is bound, it is possible to use the socket for bidirectional read and write communication.
Sends a POST request to /api/v4/session/{protocol}
Arguments:
protocol: IP transport protocolbody: Creates a new client HOPR session that will start listening on a dedicated port. Once the port is bound, it is possible to use the socket for bidirectional read and write communication.
Sourcepub async fn close_client<'a>(
&'a self,
protocol: IpProtocol,
ip: &'a str,
port: i32,
) -> Result<ResponseValue<ByteStream>, Error<ApiError>>
pub async fn close_client<'a>( &'a self, protocol: IpProtocol, ip: &'a str, port: i32, ) -> Result<ResponseValue<ByteStream>, Error<ApiError>>
Closes an existing Session listener. The listener must’ve been previously created and bound for the given IP protocol. Once a listener is closed, no more socket connections can be made to it. If the passed port number is 0, listeners on all ports of the given listening IP and protocol will be closed
Closes an existing Session listener.
Sends a DELETE request to /api/v4/session/{protocol}/{ip}/{port}
Arguments:
protocol: IP transport protocolip: Listening IP address of the Session.port: Session port used for the listener.
Sourcepub async fn redeem_tickets<'a>(
&'a self,
body: &'a RedeemTicketsRequest,
) -> Result<ResponseValue<ByteStream>, Error<ApiError>>
pub async fn redeem_tickets<'a>( &'a self, body: &'a RedeemTicketsRequest, ) -> Result<ResponseValue<ByteStream>, Error<ApiError>>
Starts redeeming tickets
Starts redeeming tickets. When a counterparty address is specified, only tickets from that counterparty are redeemed.
Sends a POST request to /api/v4/tickets/redeem
Arguments:
body: Optional counterparty address to scope ticket redemption.
Sourcepub async fn show_ticket_statistics<'a>(
&'a self,
) -> Result<ResponseValue<NodeTicketStatisticsResponse>, Error<()>>
pub async fn show_ticket_statistics<'a>( &'a self, ) -> Result<ResponseValue<NodeTicketStatisticsResponse>, Error<()>>
Returns current complete statistics on tickets
Returns current complete statistics on tickets.
Sends a GET request to /api/v4/tickets/statistics
Sourcepub async fn eligiblez<'a>(&'a self) -> Result<ResponseValue<()>, Error<()>>
pub async fn eligiblez<'a>(&'a self) -> Result<ResponseValue<()>, Error<()>>
Check whether the node is eligible in the network
Check whether the node is eligible in the network
Sends a GET request to /eligiblez
Sourcepub async fn healthyz<'a>(&'a self) -> Result<ResponseValue<()>, Error<()>>
pub async fn healthyz<'a>(&'a self) -> Result<ResponseValue<()>, Error<()>>
Check whether the node is healthy
Check whether the node is healthy
Sends a GET request to /healthyz
Sourcepub async fn metrics<'a>(
&'a self,
) -> Result<ResponseValue<ByteStream>, Error<()>>
pub async fn metrics<'a>( &'a self, ) -> Result<ResponseValue<ByteStream>, Error<()>>
Retrieve Prometheus metrics from the running node
Retrieve Prometheus metrics from the running node
Sends a GET request to /metrics
Trait Implementations§
Source§impl ClientHooks for &Client
impl ClientHooks for &Client
§async fn pre<E>(
&self,
request: &mut Request,
info: &OperationInfo,
) -> Result<(), Error<E>>
async fn pre<E>( &self, request: &mut Request, info: &OperationInfo, ) -> Result<(), Error<E>>
Source§impl ClientInfo<()> for Client
impl ClientInfo<()> for Client
Source§fn api_version() -> &'static str
fn api_version() -> &'static str
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more