pub struct Exit { /* private fields */ }Expand description
Public handle to the exit subsystem. Wraps [ExitInner] in an Arc
Implementations§
Source§impl Exit
impl Exit
Sourcepub async fn progress_exits_with_bdk(
&self,
wallet: &Wallet,
onchain: &mut dyn ExitUnilaterally,
fee_rate_override: Option<FeeRate>,
) -> Result<Option<Vec<ExitProgressStatus>>>
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
impl Exit
Sourcepub async fn get_exit_status(
&self,
vtxo_id: VtxoId,
include_history: bool,
include_transactions: bool,
) -> Result<Option<ExitTransactionStatus>, ExitError>
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.
Sourcepub async fn get_exit_vtxo(&self, vtxo_id: VtxoId) -> Option<ExitVtxo>
pub async fn get_exit_vtxo(&self, vtxo_id: VtxoId) -> Option<ExitVtxo>
Returns a clone of the tracked ExitVtxo if it exists.
Sourcepub async fn get_exit_vtxos(&self) -> Vec<ExitVtxo>
pub async fn get_exit_vtxos(&self) -> Vec<ExitVtxo>
Returns clones of all known unilateral exits in this wallet.
Sourcepub async fn has_pending_exits(&self) -> bool
pub async fn has_pending_exits(&self) -> bool
True if there are any unilateral exits which have been started but are not yet claimable.
Sourcepub fn try_pending_total(&self) -> Option<Amount>
pub fn try_pending_total(&self) -> Option<Amount>
Returns None if the lock is currently held by a writer.
Sourcepub async fn all_claimable_at_height(&self) -> Option<BlockHeight>
pub async fn all_claimable_at_height(&self) -> Option<BlockHeight>
Returns the earliest block height at which all tracked exits will be claimable
Sourcepub async fn start_exit_for_entire_wallet(&self) -> Result<()>
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.
Sourcepub async fn start_exit_for_vtxos(
&self,
vtxos: &[impl Borrow<Vtxo<Bare>>],
) -> Result<()>
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.
Sourcepub async fn progress_exits(
&self,
wallet: &Wallet,
) -> Result<Option<Vec<ExitProgressStatus>>>
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
Sourcepub async fn sync(&self, wallet: &Wallet) -> Result<()>
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.
Sourcepub async fn exits_needing_cpfp(&self) -> Vec<ExitCpfpRequest>
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.
Sourcepub async fn provide_cpfp_tx(
&self,
wallet: &Wallet,
exit_txid: Txid,
child_tx: Transaction,
) -> Result<(), ExitError>
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.
Sourcepub async fn list_claimable(&self) -> Vec<ExitVtxo>
pub async fn list_claimable(&self) -> Vec<ExitVtxo>
Lists all exits that are claimable
Sourcepub async fn sign_exit_claim_inputs(
&self,
psbt: &mut Psbt,
wallet: &Wallet,
) -> Result<()>
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
Sourcepub async fn drain_exits(
&self,
inputs: &[impl Borrow<ExitVtxo>],
wallet: &Wallet,
address: Address,
fee_rate_override: Option<FeeRate>,
) -> Result<Psbt, ExitError>
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 Freeze for Exit
impl !RefUnwindSafe for Exit
impl Send for Exit
impl Sync for Exit
impl Unpin for Exit
impl UnsafeUnpin for Exit
impl !UnwindSafe for Exit
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> 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