candidateblock_bitcoin_library.base58 module
Base58 encoding.
Base58 and Base58Check encoding and decodings that are compatible with the bitcoin network.
- class candidateblock_bitcoin_library.base58.Base58
Bases:
object- classmethod check_decode(b58: str = '') tuple
_summary_
- Parameters:
b58 (str) – Base58Check encoded string
- Raises:
ValueError – Checksum not valid
- Returns:
A tuple containing, respectively, a bytes (address prefix) and a bytes (payload) and a bytes (checksum)
- classmethod check_encode(payload: bytes = b'') str
Encode a hex string using Base58Check
Base58Check 1. Takes input bytes payload 2. Computes the double-SHA256 checksum (4-Byte) and appends to end 3. Base58 encodes result
- Parameters:
payload (bytes) – value in bytes
- Returns:
Base58Check encoded paload & (4-Byte) checksum
- Return type:
str
- classmethod decode(b58: str = '') bytes
Decode the Base58 encoded string
Check base58 string is valid, remove padding. A ValueError is raised if base58 has invalid chars Decode Base58 into bytes, even char pad with ‘0’ and with any leading ‘00’
- Parameters:
b58 (str) – Base58 encoded string
- Raises:
ValueError – Input string can not be empty
ValueError – string argument should contain only Base58 characters
- Returns:
value in bytes
- Return type:
bytes
- classmethod encode(input: bytes = b'') str
Encode bytes into a string using Base58
Take the input bytes and convert to Base58 using the Bitcoin alphabet, including leading 0x00’s coverted to ‘1’s
- Parameters:
input (bytes) – value in bytes
- Returns:
Base58 encoded
- Return type:
str