Skip to main content

Exit

Struct Exit 

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

Public handle to the exit subsystem. Wraps [ExitInner] in an Arc so all locking is internal — callers never need to acquire the lock directly.

Implementations§

Source§

impl Exit

Source

pub async fn progress_exits_with_bdk( &self, wallet: &Wallet, onchain: &mut dyn ExitUnilaterally, fee_rate_override: Option<FeeRate>, ) -> Result<Option<Vec<ExitProgressStatus>>>

Advance ongoing exits by one step, handling CPFP fee-bumping via an onchain wallet.

This makes progress on each exit but does not run an exit to completion — exits span many blocks (broadcasting, confirmations, CSV timelocks, claim spends), so this must be called repeatedly (e.g. once per block) until all exits reach a terminal state.

It calls Exit::progress_exits, creates CPFP transactions via onchain for any exits in [ExitTxStatus::AwaitingCpfpBroadcast], then calls Exit::progress_exits again so those exits advance to [ExitTxStatus::AwaitingConfirmation].

Callers with external or hardware wallets should use Exit::exits_needing_cpfp and Exit::provide_cpfp_tx directly instead.

Source§

impl Exit

Source

pub async fn get_exit_status( &self, vtxo_id: VtxoId, include_history: bool, include_transactions: bool, ) -> Result<Option<ExitTransactionStatus>, ExitError>

Returns the unilateral exit status for a given VTXO, if any.

§Parameters
  • vtxo_id: The ID of the VTXO to check.
  • include_history: Whether to include the full state machine history of the exit
  • include_transactions: Whether to include the full set of transactions related to the exit.
Source

pub async fn get_exit_vtxo(&self, vtxo_id: VtxoId) -> Option<ExitVtxo>

Returns a clone of the tracked ExitVtxo if it exists.

Source

pub async fn get_exit_vtxos(&self) -> Vec<ExitVtxo>

Returns clones of all known unilateral exits in this wallet.

Source

pub async fn has_pending_exits(&self) -> bool

True if there are any unilateral exits which have been started but are not yet claimable.

Source

pub fn try_pending_total(&self) -> Option<Amount>

Returns None if the lock is currently held by a writer.

Source

pub async fn all_claimable_at_height(&self) -> Option<BlockHeight>

Returns the earliest block height at which all tracked exits will be claimable

Source

pub async fn start_exit_for_entire_wallet(&self) -> Result<()>

Starts the unilateral exit process for the entire wallet (all eligible VTXOs).

It does not block until completion, you must use Exit::progress_exits to advance each exit.

It’s recommended to sync the wallet, by using something like Wallet::maintenance being doing this.

Source

pub async fn start_exit_for_vtxos( &self, vtxos: &[impl Borrow<Vtxo<Bare>>], ) -> Result<()>

Starts the unilateral exit process for the given VTXOs.

It does not block until completion, you must use Exit::progress_exits to advance each exit.

It’s recommended to sync the wallet, by using something like Wallet::maintenance being doing this.

Source

pub async fn progress_exits( &self, wallet: &Wallet, ) -> Result<Option<Vec<ExitProgressStatus>>>

Iterates over each registered VTXO and attempts to progress their unilateral exit.

Initializes any pending exits and refreshes the chain view of exit transactions before advancing state.

If you need to create CPFP transactions using a BDK-backed wallet, call Exit::exits_needing_cpfp after this, supply the signed CPFPs via Exit::provide_cpfp_tx, then call this method again to advance the state past ExitTxStatus::AwaitingCpfpBroadcast.

§Returns

The exit status of each VTXO being exited which has also not yet been spent

Source

pub async fn sync(&self, wallet: &Wallet) -> Result<()>

For use when syncing. Pending exits will be initialized, the network status of each ExitTransactionPackage will be updated, and finally, any unilateral exits that are waiting for network updates will be progressed.

Source

pub async fn exits_needing_cpfp(&self) -> Vec<ExitCpfpRequest>

Returns one ExitCpfpRequest for each exit transaction that needs a CPFP child.

A request with rbf_requirement = None means no CPFP exists yet. A request with rbf_requirement = Some(...) means a third-party CPFP is already in the mempool; the caller can optionally provide a replacement with a higher fee rate. Call Exit::provide_cpfp_tx to submit the child.

Source

pub async fn provide_cpfp_tx( &self, wallet: &Wallet, exit_txid: Txid, child_tx: Transaction, ) -> Result<(), ExitError>

Submit a signed CPFP child transaction for a given exit transaction.

The child must spend the P2A anchor output of the parent exit transaction identified by exit_txid. The package is broadcast immediately and the state advances to ExitTxStatus::AwaitingConfirmation. The child is persisted so it survives restarts.

§TODO

wallet is required here only because ExitVtxo::progress calls get_vtxo(&wallet.db) and tip_height() unconditionally, even though neither is needed for the AwaitingCpfpBroadcast → AwaitingConfirmation transition. The fix is to make ExitVtxo::progress take persister and chain_source separately instead of the full wallet, and call tip_height() lazily only where needed.

Source

pub async fn list_claimable(&self) -> Vec<ExitVtxo>

Lists all exits that are claimable

Source

pub async fn sign_exit_claim_inputs( &self, psbt: &mut Psbt, wallet: &Wallet, ) -> Result<()>

Sign any inputs of the PSBT that is an exit claim input

Can take the result PSBT of bdk_wallet::TxBuilder::finish on which [crate::onchain::TxBuilderExt::add_exit_claim_inputs] has been used

Note: This doesn’t mark the exit output as spent, it’s up to the caller to do that, or it will be done once the transaction is seen in the network

Source

pub async fn drain_exits( &self, inputs: &[impl Borrow<ExitVtxo>], wallet: &Wallet, address: Address, fee_rate_override: Option<FeeRate>, ) -> Result<Psbt, ExitError>

Builds a PSBT that drains the provided claimable unilateral exits to the given address.

  • inputs: Claimable unilateral exits.
  • wallet: The bark wallet containing the keys needed to spend the unilateral exits.
  • address: Destination address for the claim.
  • fee_rate_override: Optional fee rate to use.

Returns a PSBT ready to be broadcast.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Exit

§

impl !UnwindSafe for Exit

§

impl Freeze for Exit

§

impl Send for Exit

§

impl Sync for Exit

§

impl Unpin for Exit

§

impl UnsafeUnpin for Exit

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> 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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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