commit 0dce9e12ec59791cadd624f24394b9a2a0280332
parent 7ca80e017a3abe600fc83495b182dadd016fcd78
Author: Jared Tobin <jared@jtobin.io>
Date: Sat, 14 Dec 2024 05:49:30 -0330
lib: haddock stuff
Diffstat:
2 files changed, 48 insertions(+), 22 deletions(-)
diff --git a/lib/Data/ByteString/Bech32.hs b/lib/Data/ByteString/Bech32.hs
@@ -1,7 +1,20 @@
{-# LANGUAGE ViewPatterns #-}
+-- |
+-- Module: Data.ByteString.Bech32
+-- Copyright: (c) 2024 Jared Tobin
+-- License: MIT
+-- Maintainer: Jared Tobin <jared@ppad.tech>
+--
+-- The
+-- [BIP0173](https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki)
+-- bech32 checksummed base32 encoding, with checksum verification.
+
module Data.ByteString.Bech32 (
+ -- * encoding
encode
+
+ -- * checksum verification
, verify
) where
@@ -22,17 +35,6 @@ toStrict = BS.toStrict
create_checksum :: BS.ByteString -> BS.ByteString -> BS.ByteString
create_checksum = B32.create_checksum Bech32
--- | Verify that a bech32 string has a valid checksum.
---
--- >>> verify "bc1d4ujqum5wf5kuecmu02w2"
--- True
--- >>> verify "bc1d4ujquw5wf5kuecmu02w2" -- s/m/w
--- False
-verify
- :: BS.ByteString -- ^ bech32-encoded bytestring
- -> Bool
-verify = B32.verify Bech32
-
-- | Encode a base255 human-readable part and input as bech32.
--
-- >>> let Just bech32 = encode "bc" "my string"
@@ -53,3 +55,14 @@ encode hrp (B32.encode -> dat) = do
guard (BS.length res < 91)
pure res
+-- | Verify that a bech32 string has a valid checksum.
+--
+-- >>> verify "bc1d4ujqum5wf5kuecmu02w2"
+-- True
+-- >>> verify "bc1d4ujquw5wf5kuecmu02w2" -- s/m/w
+-- False
+verify
+ :: BS.ByteString -- ^ bech32-encoded bytestring
+ -> Bool
+verify = B32.verify Bech32
+
diff --git a/lib/Data/ByteString/Bech32m.hs b/lib/Data/ByteString/Bech32m.hs
@@ -1,7 +1,20 @@
{-# LANGUAGE ViewPatterns #-}
+-- |
+-- Module: Data.ByteString.Bech32m
+-- Copyright: (c) 2024 Jared Tobin
+-- License: MIT
+-- Maintainer: Jared Tobin <jared@ppad.tech>
+--
+-- The
+-- [BIP350](https://github.com/bitcoin/bips/blob/master/bip-0350.mediawiki)
+-- bech32m checksummed base32 encoding, with checksum verification.
+
module Data.ByteString.Bech32m (
+ -- * encoding
encode
+
+ -- * checksum verification
, verify
) where
@@ -22,17 +35,6 @@ toStrict = BS.toStrict
create_checksum :: BS.ByteString -> BS.ByteString -> BS.ByteString
create_checksum = B32.create_checksum Bech32m
--- | Verify that a bech32m string has a valid checksum.
---
--- >>> verify "bc1d4ujqum5wf5kuecwqlxtg"
--- True
--- >>> verify "bc1d4ujquw5wf5kuecwqlxtg" -- s/m/w
--- False
-verify
- :: BS.ByteString -- ^ bech32m-encoded bytestring
- -> Bool
-verify = B32.verify Bech32m
-
-- | Encode a base255 human-readable part and input as bech32m.
--
-- >>> let Just bech32m = encode "bc" "my string"
@@ -53,3 +55,14 @@ encode hrp (B32.encode -> dat) = do
guard (BS.length res < 91)
pure res
+-- | Verify that a bech32m string has a valid checksum.
+--
+-- >>> verify "bc1d4ujqum5wf5kuecwqlxtg"
+-- True
+-- >>> verify "bc1d4ujquw5wf5kuecwqlxtg" -- s/m/w
+-- False
+verify
+ :: BS.ByteString -- ^ bech32m-encoded bytestring
+ -> Bool
+verify = B32.verify Bech32m
+