X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning-invoice%2Fsrc%2Fde.rs;h=5de2b038e8b2d29a25df42705d5d7d378009a7fb;hb=ce5a9f528a96d1c10a992a1e89a27d58e5aecf86;hp=9e96849a274c24d9ba1a08845b8d69622c75a4ff;hpb=0a0f87c00f3c5e30965751fb46502ebc1f110333;p=rust-lightning diff --git a/lightning-invoice/src/de.rs b/lightning-invoice/src/de.rs index 9e96849a..5de2b038 100644 --- a/lightning-invoice/src/de.rs +++ b/lightning-invoice/src/de.rs @@ -23,8 +23,8 @@ use secp256k1::recovery::{RecoveryId, RecoverableSignature}; use secp256k1::key::PublicKey; use super::{Invoice, Sha256, TaggedField, ExpiryTime, MinFinalCltvExpiry, Fallback, PayeePubKey, InvoiceSignature, PositiveTimestamp, - SemanticError, PrivateRoute, Description, RawTaggedField, Currency, RawHrp, SiPrefix, RawInvoice, constants, SignedRawInvoice, - RawDataPart, InvoiceFeatures}; + SemanticError, PrivateRoute, ParseError, ParseOrSemanticError, Description, RawTaggedField, Currency, RawHrp, SiPrefix, RawInvoice, + constants, SignedRawInvoice, RawDataPart, InvoiceFeatures}; use self::hrp_sm::parse_hrp; @@ -619,46 +619,6 @@ impl FromBase32 for PrivateRoute { } } -/// Errors that indicate what is wrong with the invoice. They have some granularity for debug -/// reasons, but should generally result in an "invalid BOLT11 invoice" message for the user. -#[allow(missing_docs)] -#[derive(PartialEq, Debug, Clone)] -pub enum ParseError { - Bech32Error(bech32::Error), - ParseAmountError(ParseIntError), - MalformedSignature(secp256k1::Error), - BadPrefix, - UnknownCurrency, - UnknownSiPrefix, - MalformedHRP, - TooShortDataPart, - UnexpectedEndOfTaggedFields, - DescriptionDecodeError(str::Utf8Error), - PaddingError, - IntegerOverflowError, - InvalidSegWitProgramLength, - InvalidPubKeyHashLength, - InvalidScriptHashLength, - InvalidRecoveryId, - InvalidSliceLength(String), - - /// Not an error, but used internally to signal that a part of the invoice should be ignored - /// according to BOLT11 - Skip, -} - -/// Indicates that something went wrong while parsing or validating the invoice. Parsing errors -/// should be mostly seen as opaque and are only there for debugging reasons. Semantic errors -/// like wrong signatures, missing fields etc. could mean that someone tampered with the invoice. -#[derive(PartialEq, Debug, Clone)] -pub enum ParseOrSemanticError { - /// The invoice couldn't be decoded - ParseError(ParseError), - - /// The invoice could be decoded but violates the BOLT11 standard - SemanticError(::SemanticError), -} - impl Display for ParseError { fn fmt(&self, f: &mut Formatter) -> fmt::Result { match *self {