2020-01-27 22:02:55 +01:00
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum Error {
|
|
|
|
KeyMismatch(bitcoin::secp256k1::PublicKey, bitcoin::secp256k1::PublicKey),
|
|
|
|
MissingInputUTXO(usize),
|
2020-02-05 11:59:02 +01:00
|
|
|
InvalidU32Bytes(Vec<u8>),
|
|
|
|
Generic(String),
|
2020-01-27 22:02:55 +01:00
|
|
|
|
2020-02-05 11:59:02 +01:00
|
|
|
Encode(bitcoin::consensus::encode::Error),
|
2020-01-27 22:02:55 +01:00
|
|
|
BIP32(bitcoin::util::bip32::Error),
|
|
|
|
Secp256k1(bitcoin::secp256k1::Error),
|
2020-02-05 11:59:02 +01:00
|
|
|
JSON(serde_json::Error),
|
|
|
|
|
|
|
|
#[cfg(any(feature = "key-value-db", feature = "default"))]
|
|
|
|
Sled(sled::Error),
|
2020-01-27 22:02:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! impl_error {
|
|
|
|
( $from:ty, $to:ident ) => {
|
|
|
|
impl std::convert::From<$from> for Error {
|
|
|
|
fn from(err: $from) -> Self {
|
|
|
|
Error::$to(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-02-05 11:59:02 +01:00
|
|
|
impl_error!(bitcoin::consensus::encode::Error, Encode);
|
2020-01-27 22:02:55 +01:00
|
|
|
impl_error!(bitcoin::util::bip32::Error, BIP32);
|
|
|
|
impl_error!(bitcoin::secp256k1::Error, Secp256k1);
|
2020-02-05 11:59:02 +01:00
|
|
|
impl_error!(serde_json::Error, JSON);
|
|
|
|
|
|
|
|
#[cfg(any(feature = "key-value-db", feature = "default"))]
|
|
|
|
impl_error!(sled::Error, Sled);
|