commit 2d90bc5fd4cbe291a8baa33307bc15b874ac5888
parent 8023377605abcf906dfb209cf085ba1f6485c39f
Author: Jared Tobin <jared@jtobin.io>
Date: Sat, 18 Jan 2025 22:05:03 +0400
lib: exports
Diffstat:
2 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/lib/Bitcoin/Prim/Script.hs b/lib/Bitcoin/Prim/Script.hs
@@ -4,7 +4,30 @@
{-# LANGUAGE NumericUnderscores #-}
{-# LANGUAGE OverloadedStrings #-}
-module Bitcoin.Prim.Script where
+module Bitcoin.Prim.Script (
+ -- * Script and Script Terms
+ Script(..)
+ , Term(..)
+ , Opcode(..)
+
+ -- * Conversion Utilities
+ , to_base16
+ , from_base16
+ , to_script
+ , from_script
+
+ -- * Script Hashes
+ , ScriptHash(..)
+ , WitnessScriptHash(..)
+ , to_scripthash
+ , to_witness_scripthash
+
+ -- for testing etc.
+ , _MAX_REDEEM_SCRIPT_SIZE
+ , _MAX_WITNESS_SCRIPT_SIZE
+ , ba_to_bs
+ , bs_to_ba
+ ) where
import qualified Crypto.Hash.RIPEMD160 as RIPEMD160
import qualified Crypto.Hash.SHA256 as SHA256
@@ -66,6 +89,9 @@ hilo b =
-- types ----------------------------------------------------------------------
+-- XX since we have to export the constructor, add checks that
+-- bytearrays are pinned as required
+
-- | A Script program, represented as a 'ByteArray'.
newtype Script = Script BA.ByteArray
deriving (Eq, Show)
diff --git a/test/Main.hs b/test/Main.hs
@@ -39,7 +39,7 @@ instance Q.Arbitrary BA.ByteArray where
instance Q.Arbitrary Script where
arbitrary = do
- l <- Q.chooseInt (0, 1024)
+ l <- Q.chooseInt (0, _MAX_REDEEM_SCRIPT_SIZE)
-- pushdata must be added with care; easy to blow up quickcheck
bs <- fmap BS.pack (Q.vectorOf l (Q.chooseEnum (100, 255)))
pure (Script (bs_to_ba bs))