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
impl Client
Sourcepub fn new(base_url: impl Into<String>) -> Self
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/");Sourcepub fn base_url(&self) -> &str
pub fn base_url(&self) -> &str
Return the base URL the client was constructed with (verbatim; no normalisation).
Sourcepub fn replace(&self, inputs: &[String], outputs: &[String]) -> ClientResult<()>
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).
Sourcepub fn replace_with_htlc(
&self,
inputs: &[String],
outputs: &[String],
htlc_locks: &[HtlcLockEntry],
htlc_witnesses: &[HtlcWitnessEntry],
) -> ClientResult<()>
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.
Sourcepub fn burn(&self, secret_token: &str) -> ClientResult<()>
pub fn burn(&self, secret_token: &str) -> ClientResult<()>
POST /api/v1/burn — mark a single secret spent permanently.
Sourcepub fn health_check(&self, public_tokens: &[String]) -> ClientResult<String>
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).
Sourcepub fn mining_report(&self, preimage: &str) -> ClientResult<()>
pub fn mining_report(&self, preimage: &str) -> ClientResult<()>
POST /api/v1/mining_report — submit a PoW preimage.
Sourcepub fn issue(&self, body: &[u8], sig_hex: &str) -> ClientResult<()>
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.
Sourcepub fn target(&self) -> ClientResult<String>
pub fn target(&self) -> ClientResult<String>
GET /api/v1/target — current mining target.
Sourcepub fn stats(&self) -> ClientResult<String>
pub fn stats(&self) -> ClientResult<String>
GET /api/v1/stats — economy statistics (circulation, epoch,
mining report count, current difficulty, mining/subsidy amounts).