Skip to content

Commit

Permalink
Save vertical space.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanknowles committed May 17, 2019
1 parent 6420d90 commit e8eaf34
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions lib/bech32/src/Codec/Binary/Bech32/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,8 @@ data EncodingError = EncodedStringTooLong

decode :: ByteString -> Either DecodingError (HumanReadablePart, ByteString)
decode bech32 = do
guardE (BS.length bech32 <= encodedStringMaxLength)
StringToDecodeTooLong
guardE (BS.length bech32 >= encodedStringMinLength)
StringToDecodeTooShort
guardE (BS.length bech32 <= encodedStringMaxLength) StringToDecodeTooLong
guardE (BS.length bech32 >= encodedStringMinLength) StringToDecodeTooShort
guardE (B8.map toUpper bech32 == bech32 || B8.map toLower bech32 == bech32)
StringToDecodeHasMixedCase
(hrpUnparsed , dcpUnparsed) <-
Expand All @@ -163,10 +161,8 @@ decode bech32 = do
(\(CharPosition p) -> StringToDecodeContainsInvalidChar $
CharPosition $ p + BS.length hrpUnparsed + separatorLength)
(parseDataWithChecksumPart $ B8.unpack dcpUnparsed)
guardE (length dcp >= checksumLength)
StringToDecodeTooShort
guardE (bech32VerifyChecksum hrp dcp)
StringToDecodeContainsInvalidChars
guardE (length dcp >= checksumLength) StringToDecodeTooShort
guardE (bech32VerifyChecksum hrp dcp) StringToDecodeContainsInvalidChars
dp <- maybeToEither StringToDecodeContainsInvalidChars $
toBase256 (take (length dcp - checksumLength) dcp)
return (hrp, BS.pack dp)
Expand Down

0 comments on commit e8eaf34

Please sign in to comment.