fedimint_mint_client/
error.rs1use fedimint_api_client::api::{FederationError, OutputOutcomeError, ServerError};
8use fedimint_client_module::error::{
9 AddStateMachinesError, OperationLookupError, TransactionSubmitError,
10};
11use fedimint_core::config::FederationIdPrefix;
12use fedimint_core::db::DatabaseError;
13use fedimint_core::encoding::DecodeError;
14use fedimint_core::{Amount, PeerId};
15use thiserror::Error;
16
17pub use crate::{InsufficientBalanceError, ReissueExternalNotesError};
18
19#[derive(Debug, Error)]
21#[non_exhaustive]
22pub enum SelectNotesError {
23 #[error("The wallet does not hold enough notes")]
25 InsufficientBalance(#[from] InsufficientBalanceError),
26
27 #[error("The amount {requested} cannot be made exactly; the closest selection is {selected}")]
30 NoExactAmount {
31 requested: Amount,
33 selected: Amount,
35 },
36
37 #[error("A stored note could not be decoded")]
39 Decode(#[from] DecodeError),
40
41 #[error("The note selector failed")]
44 Custom(#[source] Box<dyn std::error::Error + Send + Sync>),
45}
46
47#[derive(Debug, Error)]
49#[non_exhaustive]
50pub enum SpendOOBError {
51 #[error("Zero-amount out-of-band spends are not supported")]
53 ZeroAmount,
54
55 #[error("The notes to spend could not be selected")]
57 NoteSelection(#[from] SelectNotesError),
58
59 #[error("Failed to add the spend's state machines")]
61 StateMachines(#[from] AddStateMachinesError),
62
63 #[error("Database error")]
65 Database(#[from] DatabaseError),
66}
67
68#[derive(Debug, Error)]
70#[non_exhaustive]
71pub enum AwaitOutputFinalizedError {
72 #[error("The transaction was rejected")]
74 TransactionRejected,
75
76 #[error("The notes could not be issued: {reason}")]
81 Failed {
82 reason: String,
84 },
85}
86
87#[derive(Debug, Error)]
89#[non_exhaustive]
90pub enum SendOOBNotesError {
91 #[error("The federation could not be reached")]
94 Federation(#[source] Box<FederationError>),
95
96 #[error("The reissue that would make the right denominations failed")]
98 Transaction(#[from] TransactionSubmitError),
99
100 #[error("Database error")]
102 Database(#[from] DatabaseError),
103}
104
105impl From<FederationError> for SendOOBNotesError {
106 fn from(source: FederationError) -> Self {
107 Self::Federation(Box::new(source))
108 }
109}
110
111#[derive(Debug, Error)]
113#[non_exhaustive]
114pub enum SubscribeReissueExternalNotesError {
115 #[error("The operation could not be looked up")]
117 Operation(#[from] OperationLookupError),
118
119 #[error("The operation is an out-of-band spend, not a reissuance")]
121 NotAReissuance,
122
123 #[error("The reissue operation records no transaction")]
125 NoTransaction,
126}
127
128#[derive(Debug, Error)]
130#[non_exhaustive]
131pub enum SubscribeSpendNotesError {
132 #[error("The operation could not be looked up")]
134 Operation(#[from] OperationLookupError),
135
136 #[error("The operation is a reissuance, not an out-of-band spend")]
138 NotAnOutOfBandSpend,
139}
140
141#[derive(Debug, Error)]
146#[non_exhaustive]
147pub enum ValidateNotesError {
148 #[error("The notes were issued by federation {found}, not {expected}")]
150 WrongFederationId {
151 expected: FederationIdPrefix,
153 found: FederationIdPrefix,
155 },
156
157 #[error("Note {index} claims the amount tier {amount}, which the federation does not issue")]
159 InvalidAmountTier {
160 index: usize,
162 amount: Amount,
164 },
165
166 #[error("Note {index} does not carry a valid federation signature")]
168 InvalidSignature {
169 index: usize,
171 },
172
173 #[error("Note {index} cannot be spent with the supplied spend key")]
175 WrongSpendKey {
176 index: usize,
178 },
179
180 #[error("A stored note could not be decoded")]
182 Decode(#[from] DecodeError),
183}
184
185#[derive(Debug, Error)]
192#[non_exhaustive]
193pub enum OOBNotesParseError {
194 #[error("The e-cash notes are not a well-formed base32 or base64 string")]
196 Encoding,
197
198 #[error("The e-cash notes could not be decoded: {0}")]
200 Decode(#[from] DecodeError),
201
202 #[error("The e-cash notes are empty")]
204 Empty,
205}
206
207#[derive(Debug, Error)]
209#[non_exhaustive]
210pub enum FetchRecoverySliceError {
211 #[error("The peer did not serve the recovery slice")]
213 Peer(#[from] ServerError),
214
215 #[error("The recovery slice could not be decoded")]
217 Decode(#[from] DecodeError),
218}
219
220#[derive(Debug, Error)]
222#[non_exhaustive]
223pub enum PrepareEcashBackupError {
224 #[error("The federation could not be reached")]
227 Federation(#[source] Box<FederationError>),
228
229 #[error("A stored note could not be decoded")]
231 Decode(#[from] DecodeError),
232}
233
234impl From<FederationError> for PrepareEcashBackupError {
235 fn from(source: FederationError) -> Self {
236 Self::Federation(Box::new(source))
237 }
238}
239
240#[derive(Debug, Error)]
242#[non_exhaustive]
243pub enum RepairWalletError {
244 #[error("The federation could not be reached")]
246 Federation(#[source] Box<FederationError>),
247
248 #[error("Database error")]
250 Database(#[from] DatabaseError),
251}
252
253impl From<FederationError> for RepairWalletError {
254 fn from(source: FederationError) -> Self {
255 Self::Federation(Box::new(source))
256 }
257}
258
259#[derive(Debug, Error)]
261#[non_exhaustive]
262pub enum VerifyBlindShareError {
263 #[error("The output outcome could not be read")]
265 Outcome(#[source] Box<OutputOutcomeError>),
266
267 #[error("No public key share is known for peer {peer}")]
269 UnknownPeer {
270 peer: PeerId,
272 },
273
274 #[error("The federation issues no notes of the amount tier {amount}")]
276 InvalidAmountTier {
277 amount: Amount,
279 },
280
281 #[error("The blind signature share does not verify")]
283 InvalidSignature,
284}
285
286impl From<OutputOutcomeError> for VerifyBlindShareError {
287 fn from(source: OutputOutcomeError) -> Self {
288 Self::Outcome(Box::new(source))
289 }
290}