stratum_apps/config_helpers/coinbase_output/
errors.rs1use core::fmt;
2
3use miniscript::bitcoin::{address, hex};
4
5#[derive(Debug)]
7pub enum Error {
8 Address(address::ParseError),
10 Hex(hex::HexToBytesError),
12 InvalidOutputScript,
14 UnknownOutputScriptType,
16 Miniscript(miniscript::Error),
18}
19
20impl fmt::Display for Error {
21 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
22 use Error::*;
23 match self {
24 Address(ref e) => write!(f, "Bitcoin address: {e}"),
25 Hex(ref e) => write!(f, "Decoding hex-formatted script: {e}"),
26 UnknownOutputScriptType => write!(f, "Unknown script type in config"),
27 InvalidOutputScript => write!(f, "Invalid output_script_value for your script type. It must be a valid public key/script"),
28 Miniscript(ref e) => write!(f, "Miniscript: {e}"),
29 }
30 }
31}
32
33impl From<address::ParseError> for Error {
34 fn from(e: address::ParseError) -> Self {
35 Error::Address(e)
36 }
37}
38
39impl From<hex::HexToBytesError> for Error {
40 fn from(e: hex::HexToBytesError) -> Self {
41 Error::Hex(e)
42 }
43}
44
45impl From<miniscript::Error> for Error {
46 fn from(e: miniscript::Error) -> Self {
47 Error::Miniscript(e)
48 }
49}