Skip to main content

BlocktrailTxo

Struct BlocktrailTxo 

Source
pub struct BlocktrailTxo {
    pub chain: Option<String>,
    pub txid: String,
    pub vout: u32,
    pub amount: Option<u64>,
    pub commit: Option<String>,
    pub pubkey: Option<String>,
    pub blockheight: Option<u64>,
}
Expand description

One mark of a trail: the output that commits to a state.

Written as a TXO URI, txo:<chain>:<txid>:<vout>?amount=<sats>&commit=<hash>[&pubkey=<x>] (blocktrails/spec gitmark profile §3; blocktrails/git-mark b852d7d formatTxoUri, which writes amount, then pubkey, then commit, each only when it is set). chain is None only for an entry read from the earlier {outpoint, blockheight} form, which carries no chain and is written back in that form.

§Examples

use solid_pod_rs::blocktrail::BlocktrailTxo;

let uri = "txo:tbtc4:51d87101b7cbb01cc5a68785bf3141ec6fd00894d71ab1168d4daa20420eeacf:0\
           ?amount=999700&commit=9adc596cfd1100333393a12f2f41b2d820f16d0b";
let txo: BlocktrailTxo = uri.parse().unwrap();
assert_eq!(txo.chain.as_deref(), Some("tbtc4"));
assert_eq!(txo.vout, 0);
assert_eq!(txo.amount, Some(999_700));
assert_eq!(txo.to_string(), uri);

Fields§

§chain: Option<String>

The chain token (tbtc4, mainnet, gitmark, …); None for an entry in the earlier {outpoint, blockheight} form.

§txid: String

The transaction id, 64 hex characters.

§vout: u32

The output index within txid.

§amount: Option<u64>

The output’s value in sats, when recorded.

§commit: Option<String>

The state this mark commits to, for a git-mark trail its commit hash.

§pubkey: Option<String>

The output’s x-only key (64 hex), when recorded. A verifier recomputes it from the base key and the states, so it is optional.

§blockheight: Option<u64>

The confirmation height, kept only by the earlier entry form; a TXO URI carries no height (a verifier reads it from the chain).

Implementations§

Source§

impl BlocktrailTxo

Source

pub fn new(chain: impl Into<String>, txid: impl Into<String>, vout: u32) -> Self

A mark at txid:vout on chain, with nothing else recorded.

Source

pub fn with_amount(self, amount: u64) -> Self

This mark with its output value recorded.

Source

pub fn with_commit(self, commit: impl Into<String>) -> Self

This mark with the state it commits to recorded (commit=).

Source

pub fn outpoint(&self) -> String

<txid>:<vout>.

Source

pub fn is_legacy(&self) -> bool

Whether this entry was read from the earlier {outpoint, blockheight} form (it has no chain).

Source

pub fn to_uri(&self) -> Option<String>

The TXO URI, or None for an entry with no chain.

Source

pub fn parse_uri(uri: &str) -> Result<Self, TxoUriError>

Parse a TXO URI.

The chain is letters and digits and the txid 64 hex characters, as blocktrails/verify requires; the vout a non-negative integer. Query parameters are read as blocktrails/git-mark reads them: amount as an integer, commit and pubkey as given (percent-decoded), an empty value as absent; any other parameter is ignored.

§Errors

TxoUriError for a URI that does not start with txo:, lacks the chain, txid or vout, or has a malformed one of them or of amount.

Trait Implementations§

Source§

impl Clone for BlocktrailTxo

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for BlocktrailTxo

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for BlocktrailTxo

Source§

fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for BlocktrailTxo

Source§

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

The TXO URI, or <txid>:<vout> for an entry with no chain.

Source§

impl Eq for BlocktrailTxo

Source§

impl FromStr for BlocktrailTxo

Source§

type Err = TxoUriError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl PartialEq for BlocktrailTxo

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for BlocktrailTxo

Source§

fn serialize<S: Serializer>(&self, s: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for BlocktrailTxo

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + 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
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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, !>

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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