use thiserror::Error;
#[derive(Debug, Error)]
pub enum WalletError {
#[error("invalid mnemonic: {0}")]
Mnemonic(String),
#[error("invalid seed length {0}: BIP32 master seeds must be 16..=64 bytes")]
SeedLength(usize),
#[error("invalid seed encoding: {0}")]
InvalidSeed(String),
#[error("BIP32 derivation error: {0}")]
Derivation(String),
#[error("BIP32 derivation produced an out-of-bounds key")]
KeyOutOfBounds,
#[error("invalid Bech32 address: {0}")]
Bech32(String),
#[error("insufficient funds: could not balance token `{token}`")]
InsufficientFunds { token: String },
#[error("amount arithmetic overflow")]
AmountOverflow,
#[error(
"insufficient dust for the registration fee: {fee_payment} generated, fee {fee} ({estimate:?})"
)]
InsufficientDustForFee {
fee: u128,
fee_payment: u128,
estimate: crate::dust::transacting::FeeCoverageEstimate,
},
#[error(
"unshielded UTXO not found: intent_hash=0x{} output_no={}",
hex::encode(id.intent_hash),
id.output_no
)]
UtxoNotFound { id: crate::unshielded::UtxoId },
#[error("invalid update status: expected {expected}, got {got}")]
InvalidUpdateStatus {
expected: &'static str,
got: &'static str,
},
#[error("invalid token type: {0}")]
InvalidTokenType(String),
#[error("signing failed: {0}")]
SigningFailed(String),
#[error("serialization failed: {0}")]
Serialization(String),
#[error("transaction submission failed: {0}")]
Submission(String),
#[error("invalid amount `{0}`: not a valid signed 128-bit integer")]
InvalidAmount(String),
#[error("dust replay error: {0}")]
DustReplay(String),
#[error("dust spend error: {0}")]
DustSpend(String),
#[error("dust wallet error: {0}")]
Dust(String),
#[error("unshielded sync error: {0}")]
UnshieldedSync(String),
#[error("shielded offer build error: {0}")]
ShieldedOffer(String),
#[error("shielded sync error: {0}")]
ShieldedSync(String),
#[error(
"stale snapshot: chain reports highest {scope} index {chain_highest} below the \
snapshot's applied index {snapshot_applied} — the chain was reset or the snapshot \
belongs to a different chain instance"
)]
StaleSnapshot {
scope: &'static str,
snapshot_applied: i64,
chain_highest: i64,
},
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
}
pub type Result<T> = std::result::Result<T, WalletError>;