bark/exit/models/
error.rs1use bitcoin::{Amount, Txid};
2use bitcoin::address::FromScriptError;
3use thiserror::Error;
4
5use ark::VtxoId;
6use bitcoin_ext::BlockHeight;
7
8use crate::chain::BroadcastError;
9use crate::exit::models::states::ExitTxStatus;
10
11#[derive(Clone, Debug, Error, PartialEq, Eq)]
12pub enum ExitError {
13 #[error("Transaction Retrieval Failure: Unable to retrieve ancestral data for TX {txid}: {error}")]
14 AncestorRetrievalFailure {
15 txid: Txid,
16 error: String
17 },
18
19 #[error("Block Retrieval Failure: Unable to retrieve a block at height {height}: {error}")]
20 BlockRetrievalFailure { height: BlockHeight, error: String },
21
22 #[error("Claim Missing Inputs: No inputs given to claim")]
23 ClaimMissingInputs,
24
25 #[error("Claim Fee Exceeds Output: Cost to claim exits was {needed}, but the total output was {output}")]
26 ClaimFeeExceedsOutput {
27 needed: Amount,
28 output: Amount,
29 },
30
31 #[error("Claim Missing Signable Clause: Couldn't find a signable clause for VTXO {vtxo}")]
32 ClaimMissingSignableClause { vtxo: VtxoId },
33
34 #[error("Claim Signing Error: Unable to sign claim: {error}")]
35 ClaimSigningError { error: String },
36
37 #[error("Cyclic Exit Transactions Error: The exit transactions for VTXO {vtxo} are cyclic")]
38 CyclicExitTransactions {
39 vtxo: VtxoId
40 },
41
42 #[error("Database Store Failure: Unable to update exit VTXO {vtxo_id} in the database: {error}")]
43 DatabaseVtxoStoreFailure {
44 vtxo_id: VtxoId,
45 error: String
46 },
47
48 #[error("Database Retrieval Failure: Unable to get child tx: {error}")]
49 DatabaseChildRetrievalFailure { error: String },
50
51 #[error("Database Store Failure: Unable to store child tx: {error}")]
52 DatabaseChildStoreFailure { error: String },
53
54 #[error("Dust Limit Error: The dust limit for a VTXO is {dust} but the balance is only {vtxo}")]
55 DustLimit {
56 vtxo: Amount,
57 dust: Amount
58 },
59
60 #[error("Exit Package Broadcast Failure: Unable to broadcast exit transaction package {txid}: {error}")]
61 ExitPackageBroadcastFailure {
62 txid: Txid,
63 error: BroadcastError,
64 },
65
66 #[error("Exit Package Finalize Failure: Unable to create exit transaction package: {error}")]
67 ExitPackageFinalizeFailure { error: String },
68
69 #[error("Exit Package Store Failure: Unable to store exit transaction package {txid}: {error}")]
70 ExitPackageStoreFailure {
71 txid: Txid,
72 error: String
73 },
74
75 #[error("Insufficient Confirmed Funds: {needed} is needed but only {available} is available")]
76 InsufficientConfirmedFunds {
77 needed: Amount,
78 available: Amount
79 },
80
81 #[error("Internal Error: An unexpected problem occurred, {error}")]
82 InternalError { error: String },
83
84 #[error("Invalid Exit Transaction Status: Exit tx {txid} has an invalid status ({status}): {error}")]
85 InvalidExitTransactionStatus {
86 txid: Txid,
87 status: ExitTxStatus,
88 error: String
89 },
90
91 #[error("Invalid Locktime ({tip}): {error}")]
92 InvalidLocktime { tip: BlockHeight, error: String },
93
94 #[error("Invalid Wallet State: {error}")]
95 InvalidWalletState { error: String },
96
97 #[error("Missing Anchor Output: Malformed exit tx {txid}")]
98 MissingAnchorOutput { txid: Txid },
99
100 #[error("Missing VTXO Transaction: Couldn't find exit tx {txid}")]
101 MissingExitTransaction { txid: Txid },
102
103 #[error("Movement Registration Failure: {error}")]
104 MovementRegistrationFailure { error: String },
105
106 #[error("Tip Retrieval Failure: Unable to retrieve the blockchain tip height: {error}")]
107 TipRetrievalFailure { error: String },
108
109 #[error("Transaction Retrieval Failure: Unable to check the status of TX {txid}: {error}")]
110 TransactionRetrievalFailure { txid: Txid, error: String },
111
112 #[error("VTXO Not Spendable Error: Attempted to claim a VTXO which is not in a spendable state: {vtxo}")]
113 VtxoNotClaimable { vtxo: VtxoId },
114
115 #[error("VTXO ScriptPubKey Invalid: {error}")]
116 VtxoScriptPubKeyInvalid { error: String },
117}
118
119impl From<FromScriptError> for ExitError {
120 fn from(e: FromScriptError) -> Self {
121 ExitError::VtxoScriptPubKeyInvalid { error: e.to_string() }
122 }
123}