Wallet Import Format¶
- bip38.wif.encode_wif(private_key: str | bytes, wif_prefix: int = 128) Tuple[str, str]¶
Encode a private key to Wallet Import Format (WIF).
- Parameters:
private_key (Union[str, bytes]) – The private key to encode, as a 32-byte string or bytes.
wif_prefix (int) – The prefix to use for the WIF format (default is Bitcoin mainnet prefix).
- Returns:
A tuple containing the WIF and WIF-compressed formats.
- Return type:
Tuple[str, str]
- bip38.wif.decode_wif(wif: str, wif_prefix: int = 128) Tuple[bytes, str, bytes]¶
Decode a Wallet Import Format (WIF) string to a private key.
- Parameters:
wif (str) – The WIF string to decode.
wif_prefix (int) – The prefix to use for the WIF format (default is Bitcoin mainnet prefix).
- Returns:
A tuple containing the private key, the WIF type (‘wif’ or ‘wif-compressed’), and the checksum.
- Return type:
Tuple[bytes, str, bytes]
- bip38.wif.private_key_to_wif(private_key: str | bytes, wif_type: str = 'wif-compressed', cryptocurrency: ~typing.Type[~bip38.cryptocurrencies.ICryptocurrency] = <class 'bip38.cryptocurrencies.Bitcoin'>, network: str = 'mainnet') str¶
Convert a private key to Wallet Import Format (WIF).
- Parameters:
private_key (Union[str, bytes]) – The private key to convert, as a 32-byte string or bytes.
wif_type (str) – The WIF type, either ‘wif’ or ‘wif-compressed’ (default is ‘wif-compressed’).
cryptocurrency (Type[ICryptocurrency]) – The cryptocurrency class (default is Bitcoin).
network (str) – The network type (default is ‘mainnet’).
- Returns:
The private key in WIF format.
- Return type:
str
- bip38.wif.wif_to_private_key(wif: str, cryptocurrency: ~typing.Type[~bip38.cryptocurrencies.ICryptocurrency] = <class 'bip38.cryptocurrencies.Bitcoin'>, network: str = 'mainnet') str¶
Convert a Wallet Import Format (WIF) string to a private key.
- Parameters:
wif (str) – The WIF string to decode.
cryptocurrency (Type[ICryptocurrency]) – The cryptocurrency class (default is Bitcoin).
network (str) – The network type (default is ‘mainnet’).
- Returns:
The private key as a string.
- Return type:
str
- bip38.wif.get_wif_type(wif: str, cryptocurrency: ~typing.Type[~bip38.cryptocurrencies.ICryptocurrency] = <class 'bip38.cryptocurrencies.Bitcoin'>, network: str = 'mainnet') str¶
Get the type of Wallet Import Format (WIF) string (‘wif’ or ‘wif-compressed’).
- Parameters:
wif (str) – The WIF string to inspect.
cryptocurrency (Type[ICryptocurrency]) – The cryptocurrency class (default is Bitcoin).
network (str) – The network type (default is ‘mainnet’).
- Returns:
The WIF type (‘wif’ or ‘wif-compressed’).
- Return type:
str
- bip38.wif.get_wif_checksum(wif: str, cryptocurrency: ~typing.Type[~bip38.cryptocurrencies.ICryptocurrency] = <class 'bip38.cryptocurrencies.Bitcoin'>, network: str = 'mainnet') str¶
Get the checksum of a Wallet Import Format (WIF) string.
- Parameters:
wif (str) – The WIF string to inspect.
cryptocurrency (Type[ICryptocurrency]) – The cryptocurrency class (default is Bitcoin).
network (str) – The network type (default is ‘mainnet’).
- Returns:
The checksum as a string.
- Return type:
str