cashscript_py.helpers.data_encoding module

Utility functions for data encoding and conversions.

flatten_bin_array(array: list[bytes]) bytes[source]

Flattens an array of byte sequences into a single byte sequence.

hex_to_bin(valid_hex: str) bytes[source]

Expecting raw hex (no 0x prefix).

int_to_bytes(i: int, length: int = 1) bytes[source]

Encode an integer as little-endian bytes of fixed length.

is_hex(maybe_hex: str) bool[source]

Returns true if the given string is valid hexadecimal (even-length and only has hexadecimal characters).

var_int_bytes(i: int) bytes[source]

Encode an integer as a Bitcoin variable length integer.