pub struct OtsClient { /* private fields */ }timestamps-ots only.Expand description
OpenTimestamps client for acquiring timestamps.
The client communicates with calendar servers to submit hashes and retrieve timestamp proofs. The proofs are initially “pending” and need to be upgraded later once the Bitcoin transaction is confirmed.
Implementations§
Source§impl OtsClient
impl OtsClient
Sourcepub fn with_calendars(calendars: Vec<String>) -> Self
pub fn with_calendars(calendars: Vec<String>) -> Self
Create a new OTS client with custom calendar servers.
Sourcepub fn with_timeout(self, timeout_secs: u64) -> Self
pub fn with_timeout(self, timeout_secs: u64) -> Self
Set the request timeout.
Sourcepub async fn acquire_timestamp(
&self,
document_id: &DocumentId,
) -> Result<TimestampRecord>
pub async fn acquire_timestamp( &self, document_id: &DocumentId, ) -> Result<TimestampRecord>
Acquire a timestamp for a document.
This submits the document’s hash to an OpenTimestamps calendar server
and returns a timestamp record containing the proof.
§Note
The returned timestamp is initially “pending” - it contains a commitment
from the calendar server but is not yet anchored to Bitcoin. Use
upgrade_timestamp after sufficient time (typically 1-2 hours) to get
the full Bitcoin-anchored proof.
§Errors
Returns an error if:
- No calendar servers are reachable
- The document ID has an unsupported hash algorithm (must be SHA-256)
- Network errors occur
Sourcepub async fn upgrade_timestamp(
&self,
timestamp: &TimestampRecord,
) -> Result<UpgradeResult>
pub async fn upgrade_timestamp( &self, timestamp: &TimestampRecord, ) -> Result<UpgradeResult>
Upgrade a pending timestamp to a complete Bitcoin-anchored proof.
This contacts the calendar server to check if the timestamp has been anchored to Bitcoin and returns an upgraded proof if available.
§Note
Bitcoin block confirmation typically takes 10-60 minutes. The calendar servers usually include the hash in a transaction within a few hours. Call this method periodically until the proof is upgraded.
§Errors
Returns an error if:
- The proof is not yet ready (still pending)
- Network errors occur
- The proof format is invalid
Sourcepub async fn check_status(
&self,
timestamp: &TimestampRecord,
) -> Result<TimestampStatus>
pub async fn check_status( &self, timestamp: &TimestampRecord, ) -> Result<TimestampStatus>
Check the status of a timestamp without upgrading.
Returns the current status of the timestamp proof.
§Errors
Returns an error if the timestamp token is invalid.
Sourcepub fn verify_timestamp(
&self,
timestamp: &TimestampRecord,
document_id: &DocumentId,
) -> Result<TimestampVerification>
pub fn verify_timestamp( &self, timestamp: &TimestampRecord, document_id: &DocumentId, ) -> Result<TimestampVerification>
Verify a timestamp proof.
This verifies that the proof is well-formed and, if complete, that it correctly anchors to a Bitcoin block.
§Errors
Returns an error if:
- The proof format is invalid
- Verification fails