Skip to main content

Client

Struct Client 

Source
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

Source

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.

Source

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

Source

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

Source

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

Source

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
Source

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?
Source

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.
Source

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.
Source

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.
Source

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.
Source

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.
Source

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.
Source

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

Source

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

Source

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

Source

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

Source

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

Source

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.
Source

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

Source

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
Source

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
Source

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
Source

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
Source

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 ID
  • body: Allows updating of several parameters of an existing active session.
Source

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
Source

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
Source

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 protocol
  • body: 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.
Source

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 protocol
  • ip: Listening IP address of the Session.
  • port: Session port used for the listener.
Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

pub async fn readyz<'a>(&'a self) -> Result<ResponseValue<()>, Error<()>>

Check whether the node is ready to accept connections

Check whether the node is ready to accept connections

Sends a GET request to /readyz

Source

pub async fn startedz<'a>(&'a self) -> Result<ResponseValue<()>, Error<()>>

Check whether the node is started

Check whether the node is started

Sends a GET request to /startedz

Trait Implementations§

Source§

impl ClientHooks for &Client

§

async fn pre<E>( &self, request: &mut Request, info: &OperationInfo, ) -> Result<(), Error<E>>

Runs prior to the execution of the request. This may be used to modify the request before it is transmitted.
§

async fn post<E>( &self, result: &Result<Response, Error>, info: &OperationInfo, ) -> Result<(), Error<E>>

Runs after completion of the request.
§

async fn exec( &self, request: Request, info: &OperationInfo, ) -> Result<Response, Error>

Execute the request. Note that for almost any reasonable implementation this will include code equivalent to this: Read more
Source§

impl ClientInfo<()> for Client

Source§

fn api_version() -> &'static str

Get the version of this API. Read more
Source§

fn baseurl(&self) -> &str

Get the base URL to which requests are made.
Source§

fn client(&self) -> &Client

Get the internal reqwest::Client used to make requests.
Source§

fn inner(&self) -> &()

Get the inner value of type T if one is specified.
Source§

impl Clone for Client

Source§

fn clone(&self) -> Client

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Client

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more