script

A Script library.
git clone git://git.ppad.tech/script.git
Log | Files | Refs | LICENSE

commit c21f3525360110f5e96c50f5f95f35e55763c989
parent 7d58a8cbf0855a58c556ad1580ac5c027e05791a
Author: Jared Tobin <jared@jtobin.io>
Date:   Mon,  6 Jan 2025 19:57:01 -0330

lib: write word16s

Diffstat:
Mlib/Bitcoin/Prim/Script.hs | 7++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/Bitcoin/Prim/Script.hs b/lib/Bitcoin/Prim/Script.hs @@ -28,7 +28,6 @@ _MAX_REDEEM_SCRIPT_SIZE = 520 _MAX_WITNESS_SCRIPT_SIZE :: Int _MAX_WITNESS_SCRIPT_SIZE = 10_000 --- realization for small builders toStrict :: BSB.Builder -> BS.ByteString toStrict = BS.toStrict . BSB.toLazyByteString {-# INLINE toStrict #-} @@ -78,8 +77,10 @@ to_base16 (Script bs) = toStrict (go 0) where | j == l = mempty | otherwise = let b = PB.indexByteArray bs j :: Word8 - (hi, lo) = hilo b - in BSB.word8 (fi hi) <> BSB.word8 (fi lo) <> go (succ j) + (fi -> hi, fi -> lo) = hilo b + w16 = hi `B.shiftL` 8 + .|. lo + in BSB.word16BE w16 <> go (succ j) -- adapted from emilypi's 'base16' package from_base16 :: BS.ByteString -> Maybe Script