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