Skip to content
This repository was archived by the owner on Apr 13, 2021. It is now read-only.

Fix linter nits #10

Merged
merged 2 commits into from
Nov 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,7 @@ mod hrp_sm {
}

fn is_final(&self) -> bool {
if *self == States::ParseL || *self == States::ParseN {
false
} else {
true
}
!(*self == States::ParseL || *self == States::ParseN)
}
}

Expand Down Expand Up @@ -586,6 +582,9 @@ impl FromBase32 for Route {
}
}

/// 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),
Expand All @@ -605,13 +604,22 @@ pub enum ParseError {
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,
TimestampOverflow,
}

/// 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),
}

Expand Down Expand Up @@ -710,7 +718,6 @@ mod test {
use de::ParseError;
use secp256k1::{PublicKey, Secp256k1};
use bech32::u5;
use SignedRawInvoice;
use bitcoin_hashes::hex::FromHex;
use bitcoin_hashes::sha256::Sha256Hash;

Expand Down
Loading