pub struct Vtxo<G = Full, P = VtxoPolicy> { /* private fields */ }Expand description
Represents a VTXO in the Ark.
The correctness of the return values of methods on this type is conditional on the VTXO being valid. For invalid VTXOs, the methods should never panic, but can return incorrect values. It is advised to always validate a VTXO upon receipt using Vtxo::validate.
Be mindful of calling Clone on a Vtxo, as they can be of non-negligible size. It is advised to use references where possible or use an std::rc::Rc or std::sync::Arc if needed.
Implementations of PartialEq, Eq, PartialOrd, Ord and Hash are proxied to the implementation on Vtxo::id.
Implementations§
Source§impl<G, P: Policy> Vtxo<G, P>
impl<G, P: Policy> Vtxo<G, P>
Sourcepub fn id(&self) -> VtxoId
pub fn id(&self) -> VtxoId
Get the identifier for this Vtxo.
This is the same as Vtxo::point but encoded as a byte array.
Sourcepub fn point(&self) -> OutPoint
pub fn point(&self) -> OutPoint
The outpoint from which to build forfeit or arkoor txs.
This can be an on-chain utxo or an off-chain vtxo.
Sourcepub fn chain_anchor(&self) -> OutPoint
pub fn chain_anchor(&self) -> OutPoint
The UTXO that should be confirmed for this Vtxo to be valid.
It is the very root of the VTXO.
Sourcepub fn policy_type(&self) -> VtxoPolicyKind
pub fn policy_type(&self) -> VtxoPolicyKind
The output policy type of this VTXO.
Sourcepub fn expiry_height(&self) -> BlockHeight
pub fn expiry_height(&self) -> BlockHeight
The expiry height of the Vtxo.
Sourcepub fn server_pubkey(&self) -> PublicKey
pub fn server_pubkey(&self) -> PublicKey
The server pubkey used in arkoor transitions.
Sourcepub fn exit_delta(&self) -> BlockDelta
pub fn exit_delta(&self) -> BlockDelta
The relative timelock block delta used for exits.
Sourcepub fn output_taproot(&self) -> TaprootSpendInfo
pub fn output_taproot(&self) -> TaprootSpendInfo
The taproot spend info for the output of this Vtxo.
Sourcepub fn output_script_pubkey(&self) -> ScriptBuf
pub fn output_script_pubkey(&self) -> ScriptBuf
The scriptPubkey of the output of this Vtxo.
Source§impl<P: Policy> Vtxo<Bare, P>
impl<P: Policy> Vtxo<Bare, P>
Sourcepub fn new(
point: OutPoint,
policy: P,
amount: Amount,
expiry_height: BlockHeight,
server_pubkey: PublicKey,
exit_delta: BlockDelta,
anchor_point: OutPoint,
) -> Self
pub fn new( point: OutPoint, policy: P, amount: Amount, expiry_height: BlockHeight, server_pubkey: PublicKey, exit_delta: BlockDelta, anchor_point: OutPoint, ) -> Self
Construct a bare VTXO from its individual fields.
Source§impl<P: Policy> Vtxo<Full, P>
impl<P: Policy> Vtxo<Full, P>
Sourcepub fn exit_depth(&self) -> u16
pub fn exit_depth(&self) -> u16
Returns the total exit depth (including OOR depth) of the vtxo.
Sourcepub fn past_arkoor_pubkeys(&self) -> Vec<Vec<PublicKey>>
pub fn past_arkoor_pubkeys(&self) -> Vec<Vec<PublicKey>>
Iterate over all oor transitions in this VTXO
The outer Vec cointains one element for each transition.
The inner Vec contains all pubkeys within that transition.
This does not include the current arkoor pubkey, for that use Vtxo::arkoor_pubkey.
Sourcepub fn has_all_witnesses(&self) -> bool
pub fn has_all_witnesses(&self) -> bool
Whether all transaction witnesses are present
It is possible to represent unsigned or otherwise unfinished VTXOs, for which this method will return false.
Sourcepub fn is_standard(&self) -> bool
pub fn is_standard(&self) -> bool
Check if this VTXO is standard for relay purposes
A VTXO is standard if:
- Its own output is standard
- all sibling outputs in the exit path are standard
- each part of the exit path should have a P2A output
Sourcepub fn unlock_hash(&self) -> Option<UnlockHash>
pub fn unlock_hash(&self) -> Option<UnlockHash>
Returns the “hArk” unlock hash if this is a hArk leaf VTXO
Sourcepub fn provide_unlock_signature(&mut self, signature: Signature) -> bool
pub fn provide_unlock_signature(&mut self, signature: Signature) -> bool
Provide the leaf signature for an unfinalized hArk VTXO
Returns true if this VTXO was an unfinalized hArk VTXO.
Sourcepub fn provide_unlock_preimage(&mut self, preimage: UnlockPreimage) -> bool
pub fn provide_unlock_preimage(&mut self, preimage: UnlockPreimage) -> bool
Provide the unlock preimage for an unfinalized hArk VTXO
Returns true if this VTXO was an unfinalized hArk VTXO and the preimage matched.
Sourcepub fn transactions(&self) -> VtxoTxIter<'_, P> ⓘ
pub fn transactions(&self) -> VtxoTxIter<'_, P> ⓘ
Iterator that constructs all the exit txs for this Vtxo.
Sourcepub fn validate(
&self,
chain_anchor_tx: &Transaction,
) -> Result<(), VtxoValidationError>
pub fn validate( &self, chain_anchor_tx: &Transaction, ) -> Result<(), VtxoValidationError>
Fully validate this VTXO and its entire transaction chain.
The chain_anchor_tx must be the tx with txid matching
Vtxo::chain_anchor.
Sourcepub fn validate_unsigned(
&self,
chain_anchor_tx: &Transaction,
) -> Result<(), VtxoValidationError>
pub fn validate_unsigned( &self, chain_anchor_tx: &Transaction, ) -> Result<(), VtxoValidationError>
Validate VTXO structure without checking signatures.
Source§impl<G> Vtxo<G, VtxoPolicy>
impl<G> Vtxo<G, VtxoPolicy>
Sourcepub fn user_pubkey(&self) -> PublicKey
pub fn user_pubkey(&self) -> PublicKey
Returns the user pubkey associated with this Vtxo.
Sourcepub fn arkoor_pubkey(&self) -> Option<PublicKey>
pub fn arkoor_pubkey(&self) -> Option<PublicKey>
The public key used to cosign arkoor txs spending this Vtxo. This will return None if VtxoPolicy::is_arkoor_compatible returns false for this VTXO’s policy.
Source§impl<G> Vtxo<G, ServerVtxoPolicy>
impl<G> Vtxo<G, ServerVtxoPolicy>
Sourcepub fn try_into_user_vtxo(self) -> Result<Vtxo<G, VtxoPolicy>, ServerVtxo<G>>
pub fn try_into_user_vtxo(self) -> Result<Vtxo<G, VtxoPolicy>, ServerVtxo<G>>
Try to convert into a user Vtxo
Returns the original value on failure.