pub struct Vtxo { /* private fields */ }Expand description
All the information needed to spend a VTXO.
Implementations§
Source§impl Vtxo
impl Vtxo
Sourcepub 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,
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.
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,
Sourcepub fn new_default<C>(
secp: &Secp256k1<C>,
server_signer: XOnlyPublicKey,
owner: XOnlyPublicKey,
exit_delay: Sequence,
network: Network,
) -> Result<Self, Error>where
C: Verification,
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.
Sourcepub 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,
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:
- Forfeit: 2-of-2 multisig (server + owner)
- Exit: CSV-timelocked owner signature
- 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.
pub fn script_pubkey(&self) -> ScriptBuf
pub fn address(&self) -> &Address
pub fn owner_pk(&self) -> XOnlyPublicKey
pub fn server_pk(&self) -> XOnlyPublicKey
pub fn delegator_pk(&self) -> Option<XOnlyPublicKey>
pub fn exit_delay(&self) -> Sequence
pub fn to_ark_address(&self) -> ArkAddress
Sourcepub fn get_spend_info(&self, script: ScriptBuf) -> Result<ControlBlock, Error>
pub fn get_spend_info(&self, script: ScriptBuf) -> Result<ControlBlock, Error>
The spend info of an arbitrary branch of a VTXO.
Sourcepub fn forfeit_spend_info(&self) -> Result<(ScriptBuf, ControlBlock), Error>
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.
Sourcepub fn exit_spend_info(&self) -> Result<(ScriptBuf, ControlBlock), Error>
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.
Sourcepub fn delegate_spend_info(&self) -> Result<(ScriptBuf, ControlBlock), Error>
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.