Skip to main content

Vtxo

Struct Vtxo 

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

All the information needed to spend a VTXO.

Implementations§

Source§

impl Vtxo

Source

pub fn new_with_custom_scripts<C>( secp: &Secp256k1<C>, server_forfeit: XOnlyPublicKey, owner: XOnlyPublicKey, scripts: Vec<ScriptBuf>, exit_delay: Sequence, network: Network, ) -> Result<Self, Error>
where C: Verification,

Build a VTXO, by providing all the scripts to be included in the Taproot tree.

The provided scripts must follow the following rules:

  • All unilateral spend paths MUST be timelocked.
  • All other spend paths MUST involve the Ark server’s signature.
Source

pub fn new_with_custom_scripts_and_split_owner_keys<C>( secp: &Secp256k1<C>, server_forfeit: XOnlyPublicKey, owner: XOnlyPublicKey, owner_unilateral_exit: XOnlyPublicKey, scripts: Vec<ScriptBuf>, exit_delay: Sequence, network: Network, ) -> Result<Self, Error>
where C: Verification,

Source

pub fn new_default<C>( secp: &Secp256k1<C>, server_signer: XOnlyPublicKey, owner: XOnlyPublicKey, exit_delay: Sequence, network: Network, ) -> Result<Self, Error>
where C: Verification,

Build a default VTXO.

Source

pub fn new_with_delegator<C>( secp: &Secp256k1<C>, server_signer: XOnlyPublicKey, owner: XOnlyPublicKey, delegator: XOnlyPublicKey, exit_delay: Sequence, network: Network, ) -> Result<Self, Error>
where C: Verification,

Build a VTXO with a delegate spending path.

This creates a 3-leaf Taproot tree:

  1. Forfeit: 2-of-2 multisig (server + owner)
  2. Exit: CSV-timelocked owner signature
  3. Delegate: 3-of-3 multisig (owner + delegator + server)

The delegate path allows a third-party delegator service to cooperate with the owner and the server to renew VTXOs before they expire.

Source

pub fn script_pubkey(&self) -> ScriptBuf

Source

pub fn address(&self) -> &Address

Source

pub fn owner_pk(&self) -> XOnlyPublicKey

Source

pub fn server_pk(&self) -> XOnlyPublicKey

Source

pub fn delegator_pk(&self) -> Option<XOnlyPublicKey>

Source

pub fn exit_delay(&self) -> Sequence

Source

pub fn to_ark_address(&self) -> ArkAddress

Source

pub fn get_spend_info(&self, script: ScriptBuf) -> Result<ControlBlock, Error>

The spend info of an arbitrary branch of a VTXO.

Source

pub fn forfeit_spend_info(&self) -> Result<(ScriptBuf, ControlBlock), Error>

The spend info for the forfeit branch of a default VTXO.

This method can fail because Vtxos constructed with the method Vtxo::new_with_custom_scripts may not contain this script exactly.

Source

pub fn exit_spend_info(&self) -> Result<(ScriptBuf, ControlBlock), Error>

The spend info for the unilateral exit branch of a default VTXO.

This method can fail because Vtxos constructed with the method Vtxo::new_with_custom_scripts may not contain this script exactly.

Source

pub fn delegate_spend_info(&self) -> Result<(ScriptBuf, ControlBlock), Error>

The spend info for the delegate branch of a VTXO constructed with Vtxo::new_with_delegator.

Returns an error if the VTXO was not built with a delegator.

Source

pub fn tapscripts(&self) -> Vec<ScriptBuf>

Source

pub fn can_be_claimed_unilaterally_by_owner( &self, now: Duration, confirmation_blocktime: Duration, confirmations: u64, ) -> bool

Whether the VTXO can be claimed unilaterally by the owner or not, given the confirmation_blocktime of the transaction that included this VTXO as an output.

Trait Implementations§

Source§

impl Clone for Vtxo

Source§

fn clone(&self) -> Vtxo

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 Vtxo

Source§

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

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

impl Hash for Vtxo

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Vtxo

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Vtxo

Source§

impl StructuralPartialEq for Vtxo

Auto Trait Implementations§

§

impl Freeze for Vtxo

§

impl RefUnwindSafe for Vtxo

§

impl Send for Vtxo

§

impl Sync for Vtxo

§

impl Unpin for Vtxo

§

impl UnsafeUnpin for Vtxo

§

impl UnwindSafe for Vtxo

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> 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> 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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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