Safe Haskell | Safe |
---|---|

Language | Haskell98 |

Numbers in Bitcoin scripts

- data Sign
- signOf :: Integer -> Sign
- toSignAbs :: Integer -> (Sign, Integer)
- fromSignAbs :: (Sign, Integer) -> Integer
- asInteger :: ByteString -> Integer
- asByteString :: Integer -> ByteString
- encodeSign :: Sign -> [Word8] -> [Word8]
- decodeSign :: [Word8] -> (Sign, [Word8])

# signs

Positive actually means non-negative here, but it looks better (and is easier to read) this way

# Bitcoin's special ByteString - Integer conversion

asInteger :: ByteString -> Integer Source #

Byte vectors are interpreted as little-endian variable-length integers with the most significant bit determining the sign of the integer. Thus 0x81 represents -1. 0x80 is another representation of zero (so called negative 0). Byte vectors are interpreted as Booleans where False is represented by any representation of zero, and True is represented by any representation of non-zero.

asByteString :: Integer -> ByteString Source #