Skip to main content

OtsClient

Struct OtsClient 

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

OTS client.

Implementations§

Source§

impl OtsClient

Source

pub fn new() -> Self

Construct a new client with default calendar servers.

Source

pub fn with_servers(servers: Vec<String>) -> Self

Construct with custom calendar servers.

Source

pub fn calendar_servers(&self) -> &[String]

Available calendar servers.

Source

pub async fn stamp(&self, hash: [u8; 32]) -> Result<OtsProof, OtsError>

Submit a hash for timestamping. Returns a mock proof immediately; real implementation would poll the calendar server until Bitcoin confirmation arrives (typically 1-12 hours).

Source

pub async fn verify<F>( &self, proof: &OtsProof, bitcoin_block_at_height: F, ) -> Result<OtsVerification, OtsError>
where F: Fn(u32) -> Result<[u8; 32], String>,

Verify a proof against Bitcoin block headers.

Caller provides a bitcoin_block_header_hash callback that returns the block hash at the given height (real impl: query Bitcoin Core RPC, or use a public blockchain API).

Trait Implementations§

Source§

impl Default for OtsClient

Source§

fn default() -> Self

Returns the “default value” for a type. 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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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.