Skip to main content

Client

Struct Client 

Source
pub struct Client { /* private fields */ }
Expand description

Minimal asset-agnostic HTTP client. One instance per server URL; methods correspond 1:1 to the server’s endpoint set.

Implementations§

Source§

impl Client

Source

pub fn new(base_url: impl Into<String>) -> Self

Construct a client bound to a server base URL, e.g. http://localhost:8181 or https://webcash.org.

use webylib_server_client::Client;
// Trailing slash on the base is normalised away.
let c = Client::new("http://localhost:8181/");
assert_eq!(c.base_url(), "http://localhost:8181/");
Source

pub fn base_url(&self) -> &str

Return the base URL the client was constructed with (verbatim; no normalisation).

Source

pub fn replace(&self, inputs: &[String], outputs: &[String]) -> ClientResult<()>

POST /api/v1/replace — splittable: N inputs → M outputs with amount conservation. Non-splittable: 1:1 (same body shape; the server enforces arity per its compiled flavor).

Source

pub fn replace_with_htlc( &self, inputs: &[String], outputs: &[String], htlc_locks: &[HtlcLockEntry], htlc_witnesses: &[HtlcWitnessEntry], ) -> ClientResult<()>

POST /api/v1/replace — same as Client::replace but with the HTLC extensions wired up. Use this when an output should be HTLC-locked, or when an input is locked and a witness must be supplied.

htlc_locks and htlc_witnesses are typed structs (see HtlcLockEntry / HtlcWitnessEntry) that serialize into the JSON shape documented in webycash-server/docs/referee-zkp-based-swap.md §7.1. Pass empty slices when not used.

The HTLC extensions are accepted by the RGB server only; webcash and voucher servers ignore them (their ReplaceHook impl is a no-op accept). Per docs §1, this is by design.

Source

pub fn burn(&self, secret_token: &str) -> ClientResult<()>

POST /api/v1/burn — mark a single secret spent permanently.

Source

pub fn health_check(&self, public_tokens: &[String]) -> ClientResult<String>

POST /api/v1/health_check — bare-array body of public tokens. Returns the raw response body (caller parses).

Source

pub fn mining_report(&self, preimage: &str) -> ClientResult<()>

POST /api/v1/mining_report — submit a PoW preimage.

Source

pub fn issue(&self, body: &[u8], sig_hex: &str) -> ClientResult<()>

POST /api/v1/issue — operator-signed mint (RGB / Voucher only). Caller supplies the canonical request body bytes AND the detached Ed25519 signature over those bytes.

Source

pub fn target(&self) -> ClientResult<String>

GET /api/v1/target — current mining target.

Source

pub fn stats(&self) -> ClientResult<String>

GET /api/v1/stats — economy statistics (circulation, epoch, mining report count, current difficulty, mining/subsidy amounts).

Trait Implementations§

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§

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.

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> Same for T

Source§

type Output = T

Should always be Self
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.