1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use std::error;
use std::fmt;
#[derive(Debug, PartialEq)]
pub enum Error {
AnchorMismatch,
BindingSig,
ChangeIsNegative,
InvalidAddress,
InvalidAddressFormat,
InvalidAddressHash,
InvalidAmount,
NoChangeAddress,
SpendProof,
SpendSig,
TranspararentSig,
Finalization,
MinShieldedOuputs,
BuilderNoKeys,
ReadWriteError,
InvalidOVKHashSeed,
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Error::AnchorMismatch => {
write!(f, "Anchor mismatch (anchors for all spends must be equal)")
}
Error::BindingSig => write!(f, "Failed to create bindingSig"),
Error::ChangeIsNegative => write!(f, "Change is negative"),
Error::InvalidAddress => write!(f, "Invalid address"),
Error::InvalidAmount => write!(f, "Invalid amount"),
Error::NoChangeAddress => write!(f, "No change address specified or discoverable"),
Error::SpendProof => write!(f, "Failed to create Sapling spend proof"),
Error::SpendSig => write!(f, "Failed to get Sapling spend signature"),
Error::InvalidAddressFormat => write!(f, "Incorrect format of address"),
Error::InvalidAddressHash => write!(f, "Incorrect hash of address"),
Error::TranspararentSig => write!(f, "Failed to sign transparent inputs"),
Error::Finalization => write!(f, "Failed to build complete transaction"),
Error::MinShieldedOuputs => write!(f, "Not enough shielded outputs for transaction"),
Error::BuilderNoKeys => write!(f, "Builder does not have any keys set"),
Error::ReadWriteError => write!(f, "Error writing/reading bytes to/from vector"),
Error::InvalidOVKHashSeed => write!(f, "Error: either OVK or hashseed should be some"),
}
}
}
impl error::Error for Error {}
impl From<std::io::Error> for Error {
fn from(e: std::io::Error) -> Error {
Error::ReadWriteError
}
}