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: StringThe transaction id, 64 hex characters.
vout: u32The 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
impl BlocktrailTxo
Sourcepub fn new(chain: impl Into<String>, txid: impl Into<String>, vout: u32) -> Self
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.
Sourcepub fn with_amount(self, amount: u64) -> Self
pub fn with_amount(self, amount: u64) -> Self
This mark with its output value recorded.
Sourcepub fn with_commit(self, commit: impl Into<String>) -> Self
pub fn with_commit(self, commit: impl Into<String>) -> Self
This mark with the state it commits to recorded (commit=).
Sourcepub fn is_legacy(&self) -> bool
pub fn is_legacy(&self) -> bool
Whether this entry was read from the earlier {outpoint, blockheight}
form (it has no chain).
Sourcepub fn parse_uri(uri: &str) -> Result<Self, TxoUriError>
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.