pub struct Client { /* private fields */ }Expand description
Client for hoprd-api
API enabling developers to interact with a hoprd node programatically through HTTP REST API.
Version: 4.6.0
Implementations§
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,
channel_id: &'a str,
) -> Result<ResponseValue<ChannelInfoResponse>, Error<()>>
pub async fn show_channel<'a>( &'a self, channel_id: &'a str, ) -> Result<ResponseValue<ChannelInfoResponse>, Error<()>>
Returns information about the given channel
Returns information about the given channel.
Sends a GET request to /api/v4/channels/{channelId}
Arguments:
channel_id: ID of the channel.
Sourcepub async fn close_channel<'a>(
&'a self,
channel_id: &'a str,
) -> Result<ResponseValue<CloseChannelResponse>, Error<()>>
pub async fn close_channel<'a>( &'a self, channel_id: &'a str, ) -> Result<ResponseValue<CloseChannelResponse>, Error<()>>
Closes the given channel
Closes the given channel.
Sends a DELETE request to /api/v4/channels/{channelId}
Arguments:
channel_id: ID of the channel.
Sourcepub async fn fund_channel<'a>(
&'a self,
channel_id: &'a str,
body: &'a FundBodyRequest,
) -> Result<ResponseValue<FundChannelResponse>, Error<()>>
pub async fn fund_channel<'a>( &'a self, channel_id: &'a str, body: &'a FundBodyRequest, ) -> Result<ResponseValue<FundChannelResponse>, Error<()>>
Funds the given channel with the given amount of HOPR tokens
Funds the given channel with the given amount of HOPR tokens.
Sends a POST request to /api/v4/channels/{channelId}/fund
Arguments:
channel_id: ID of the channel.body: Specifies the amount of HOPR tokens to fund a channel with.
Sourcepub async fn show_channel_tickets<'a>(
&'a self,
channel_id: &'a str,
) -> Result<ResponseValue<Vec<ChannelTicket>>, Error<()>>
pub async fn show_channel_tickets<'a>( &'a self, channel_id: &'a str, ) -> Result<ResponseValue<Vec<ChannelTicket>>, Error<()>>
Lists all tickets for the given channel ID
Lists all tickets for the given channel ID.
Sends a GET request to /api/v4/channels/{channelId}/tickets
Arguments:
channel_id: ID of the channel.
Sourcepub async fn redeem_tickets_in_channel<'a>(
&'a self,
channel_id: &'a str,
) -> Result<ResponseValue<ByteStream>, Error<ApiError>>
pub async fn redeem_tickets_in_channel<'a>( &'a self, channel_id: &'a str, ) -> Result<ResponseValue<ByteStream>, Error<ApiError>>
Starts redeeming all tickets in the given channel
Starts redeeming all tickets in the given channel.
Sends a POST request to /api/v4/channels/{channelId}/tickets/redeem
Arguments:
channel_id: ID of the channel.
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 entry_nodes<'a>(
&'a self,
) -> Result<ResponseValue<HashMap<String, EntryNode>>, Error<()>>
pub async fn entry_nodes<'a>( &'a self, ) -> Result<ResponseValue<HashMap<String, EntryNode>>, Error<()>>
List all known entry nodes with multiaddrs and eligibility
List all known entry nodes with multiaddrs and eligibility
Sends a GET request to /api/v4/node/entry-nodes
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 peers<'a>(
&'a self,
score: Option<f64>,
) -> Result<ResponseValue<NodePeersResponse>, Error<()>>
pub async fn peers<'a>( &'a self, score: Option<f64>, ) -> Result<ResponseValue<NodePeersResponse>, Error<()>>
Lists information for connected peers and announced peers
Lists information for connected and announced peers
Sends a GET request to /api/v4/node/peers
Arguments:
score: Minimum peer quality to be included in the response.
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,
destination: &'a str,
) -> Result<ResponseValue<NodePeerInfoResponse>, Error<()>>
pub async fn show_peer_info<'a>( &'a self, destination: &'a str, ) -> Result<ResponseValue<NodePeerInfoResponse>, Error<()>>
Returns transport-related information about the given peer
This includes the peer ids that the given peer has announced on-chain
and peer ids that are actually observed by the transport layer.
Sends a GET request to /api/v4/peers/{destination}
Arguments:
destination: Address of the requested peer
Sourcepub async fn ping_peer<'a>(
&'a self,
destination: &'a str,
) -> Result<ResponseValue<PingResponse>, Error<()>>
pub async fn ping_peer<'a>( &'a self, destination: &'a str, ) -> Result<ResponseValue<PingResponse>, Error<()>>
Directly pings the given peer
Directly ping the given peer
Sends a POST request to /api/v4/peers/{destination}/ping
Arguments:
destination: Address of the requested peer
Sourcepub async fn peer_stats<'a>(
&'a self,
destination: &'a str,
) -> Result<ResponseValue<PeerPacketStatsResponse>, Error<()>>
pub async fn peer_stats<'a>( &'a self, destination: &'a str, ) -> Result<ResponseValue<PeerPacketStatsResponse>, Error<()>>
Get packet statistics for a specific connected peer
Get packet statistics for a specific connected peer
Sends a GET request to /api/v4/peers/{destination}/stats
Arguments:
destination: 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 session_stats<'a>(
&'a self,
id: &'a str,
) -> Result<ResponseValue<SessionStatsResponse>, Error<()>>
pub async fn session_stats<'a>( &'a self, id: &'a str, ) -> Result<ResponseValue<SessionStatsResponse>, Error<()>>
Gets stats for an existing active session.
Sends a GET request to /api/v4/session/stats/{id}
Arguments:
id: Session ID
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 show_all_tickets<'a>(
&'a self,
) -> Result<ResponseValue<Vec<ChannelTicket>>, Error<()>>
pub async fn show_all_tickets<'a>( &'a self, ) -> Result<ResponseValue<Vec<ChannelTicket>>, Error<()>>
Endpoint is deprecated and will be removed in the future. Returns an empty array
(deprecated) Returns an empty array.
Sends a GET request to /api/v4/tickets
Sourcepub async fn redeem_all_tickets<'a>(
&'a self,
) -> Result<ResponseValue<ByteStream>, Error<ApiError>>
pub async fn redeem_all_tickets<'a>( &'a self, ) -> Result<ResponseValue<ByteStream>, Error<ApiError>>
Starts redeeming of all tickets in all channels
Starts redeeming of all tickets in all channels.
Sends a POST request to /api/v4/tickets/redeem
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 reset_ticket_statistics<'a>(
&'a self,
) -> Result<ResponseValue<ByteStream>, Error<ApiError>>
pub async fn reset_ticket_statistics<'a>( &'a self, ) -> Result<ResponseValue<ByteStream>, Error<ApiError>>
Resets the ticket metrics
Resets the ticket metrics.
Sends a DELETE 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