pub struct ExitVtxo { /* private fields */ }Expand description
Tracks the exit lifecycle for a single Vtxo.
An ExitVtxo maintains:
- the underlying Vtxo being exited,
- the set of related onchain transaction IDs in topographical order,
- the current state ExitState,
- and a history of prior states for debugging and auditing.
Use ExitVtxo::progress to drive the state machine forward. The method is idempotent and will only persist when a logical state transition occurs.
Implementations§
Source§impl ExitVtxo
impl ExitVtxo
Sourcepub fn new(vtxo: &Vtxo, tip: u32) -> Self
pub fn new(vtxo: &Vtxo, tip: u32) -> Self
Create a new instance for the given VtxoId with an initial state of ExitState::Start. The unilateral exit can’t progress until ExitVtxo::initialize is called.
§Parameters
vtxo_id: the VtxoId being exited.tip: current chain tip used to initialize the starting state.
Sourcepub fn from_entry(entry: StoredExit, vtxo: &Vtxo) -> Self
pub fn from_entry(entry: StoredExit, vtxo: &Vtxo) -> Self
Sourcepub fn history(&self) -> &Vec<ExitState>
pub fn history(&self) -> &Vec<ExitState>
Returns the history of the exit machine in the order that states were observed.
Sourcepub fn txids(&self) -> Option<&Vec<Txid>>
pub fn txids(&self) -> Option<&Vec<Txid>>
Returns the set of exit-related transaction IDs, these may not be broadcast yet. If the instance is not yet initialized, None will be returned.
Sourcepub fn is_claimable(&self) -> bool
pub fn is_claimable(&self) -> bool
True if the exit is currently ExitState::Claimable and can be claimed/spent.
Sourcepub fn is_initialized(&self) -> bool
pub fn is_initialized(&self) -> bool
True if ExitVtxo::initialize has been called and the exit is ready to progress.
Sourcepub async fn initialize(
&mut self,
tx_manager: &mut ExitTransactionManager,
persister: &dyn BarkPersister,
onchain: &dyn ExitUnilaterally,
) -> Result<(), ExitError>
pub async fn initialize( &mut self, tx_manager: &mut ExitTransactionManager, persister: &dyn BarkPersister, onchain: &dyn ExitUnilaterally, ) -> Result<(), ExitError>
Prepares an ExitVtxo for progression by querying the list of transactions required to process the unilateral exit and adds them to the exit transaction manager.
Sourcepub async fn progress(
&mut self,
wallet: &Wallet,
tx_manager: &mut ExitTransactionManager,
onchain: &mut dyn ExitUnilaterally,
fee_rate_override: Option<FeeRate>,
continue_until_finished: bool,
) -> Result<(), ExitError>
pub async fn progress( &mut self, wallet: &Wallet, tx_manager: &mut ExitTransactionManager, onchain: &mut dyn ExitUnilaterally, fee_rate_override: Option<FeeRate>, continue_until_finished: bool, ) -> Result<(), ExitError>
Advances the exit state machine for this Vtxo.
The method:
- Attempts to transition the unilateral exit state machine.
- Persists only when a logical state change occurs.
Returns:
Ok(())when no more immediate work is required, such as when we’re waiting for a confirmation or when the exit is complete.Err(ExitError)when an unrecoverable issue occurs, such as requiring more onchain funds or if an exit transaction fails to broadcast; if the error includes a newer state, it will be committed before returning.
Notes:
- If
fee_rate_overrideisNone, a suitable fee rate will be calculated.
pub async fn get_vtxo( &self, persister: &dyn BarkPersister, ) -> Result<WalletVtxo, ExitError>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ExitVtxo
impl RefUnwindSafe for ExitVtxo
impl Send for ExitVtxo
impl Sync for ExitVtxo
impl Unpin for ExitVtxo
impl UnwindSafe for ExitVtxo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request