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(e) => write!(f, "Bitcoin address: {e}"),
25 Hex(e) => write!(f, "Decoding hex-formatted script: {e}"),
26 UnknownOutputScriptType => write!(f, "Unknown script type in config"),
27 InvalidOutputScript => write!(
28 f,
29 "Invalid output_script_value for your script type. It must be a valid public key/script"
30 ),
31 Miniscript(e) => write!(f, "Miniscript: {e}"),
32 }
33 }
34}
35
36impl From<address::ParseError> for Error {
37 fn from(e: address::ParseError) -> Self {
38 Error::Address(e)
39 }
40}
41
42impl From<hex::HexToBytesError> for Error {
43 fn from(e: hex::HexToBytesError) -> Self {
44 Error::Hex(e)
45 }
46}
47
48impl From<miniscript::Error> for Error {
49 fn from(e: miniscript::Error) -> Self {
50 Error::Miniscript(e)
51 }
52}