Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Commit

Permalink
Update: documentation typo errors
Browse files Browse the repository at this point in the history
  • Loading branch information
meherett committed Oct 14, 2023
1 parent 2f53c3e commit feb511f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 22 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
[![Documentation Status](https://readthedocs.org/projects/bip38/badge/?version=master)](https://bip38.readthedocs.io)
[![PyPI License](https://img.shields.io/pypi/l/bip38?color=black)](https://pypi.org/project/bip38)
[![PyPI Python Version](https://img.shields.io/pypi/pyversions/bip38.svg)](https://pypi.org/project/bip38)

[comment]: <> ([![Coverage Status]&#40;https://coveralls.io/repos/github/meherett/python-bip38/badge.svg?branch=master&#41;]&#40;https://coveralls.io/github/meherett/python-bip38&#41;)
[![Coverage Status](https://coveralls.io/repos/github/meherett/python-bip38/badge.svg?branch=master)](https://coveralls.io/github/meherett/python-bip38)

Python library for implementation of Bitcoin Improvement Proposal - 0038 / BIP38 protocol. It supports both [No EC-multiply](https://github.com/bitcoin/bips/blob/master/bip-0038.mediawiki#encryption-when-ec-multiply-flag-is-not-used) and [EC-multiply](https://github.com/bitcoin/bips/blob/master/bip-0038.mediawiki#encryption-when-ec-multiply-mode-is-used) modes.

Expand Down
34 changes: 19 additions & 15 deletions bip38/bip38.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,14 +285,14 @@ def encode_wif(private_key: Union[str, bytes]) -> Tuple[str, str]:

def private_key_to_wif(private_key: Union[str, bytes], wif_type: Literal["wif", "wif-compressed"] = "wif-compressed") -> str:
"""
Private key to Wallet Important Fromat (WFI) converter
Private key to Wallet Important Format (WIF) converter
:param private_key: Private key
:type private_key: Union[str, bytes]
:param wif_type: Wallet Important Fromat (WFI) type, default to ``wif-compressed``
:param wif_type: Wallet Important Format (WIF) type, default to ``wif-compressed``
:type wif_type: Literal["wif", "wif-compressed"]
:returns: str -- Wallet Important Fromat
:returns: str -- Wallet Important Format
>>> from bip38 import private_key_to_wif
>>> private_key_to_wif(private_key="cbf4b9f70470856bb4f40f80b87edb90865997ffee6df315ab166d713af433a5")
Expand Down Expand Up @@ -339,9 +339,9 @@ def decode_wif(wif: str) -> Tuple[bytes, Literal["wif", "wif-compressed"], bytes

def wif_to_private_key(wif: str) -> str:
"""
Wallet Important Fromat (WFI) to Private key converter
Wallet Important Format (WIF) to Private key converter
:param wif: Wallet Important Fromat
:param wif: Wallet Important Format
:type wif: str
:returns: str -- Private key
Expand All @@ -358,12 +358,12 @@ def wif_to_private_key(wif: str) -> str:

def get_wif_type(wif: str) -> Literal["wif", "wif-compressed"]:
"""
Get Wallet Important Fromat (WFI) type
Get Wallet Important Format (WIF) type
:param wif: Wallet Important Fromat
:param wif: Wallet Important Format
:type wif: str
:returns: Literal["wif", "wif-compressed"] -- WFI type
:returns: Literal["wif", "wif-compressed"] -- WIF type
>>> from bip38 import get_wif_type
>>> get_wif_type(wif="L44B5gGEpqEDRS9vVPz7QT35jcBG2r3CZwSwQ4fCewXAhAhqGVpP")
Expand All @@ -377,12 +377,12 @@ def get_wif_type(wif: str) -> Literal["wif", "wif-compressed"]:

def get_wif_checksum(wif: str) -> str:
"""
Get Wallet Important Fromat (WFI) checksum
Get Wallet Important Format (WIF) checksum
:param wif: Wallet Important Fromat
:param wif: Wallet Important Format
:type wif: str
:returns: str -- WFI checksum
:returns: str -- WIF checksum
>>> from bip38 import get_wif_checksum
>>> get_wif_checksum(wif="L44B5gGEpqEDRS9vVPz7QT35jcBG2r3CZwSwQ4fCewXAhAhqGVpP")
Expand All @@ -406,10 +406,14 @@ def public_key_to_addresses(public_key: Union[str, bytes], network: Literal["mai
:returns: str -- Address
>>> from bip38 import public_key_to_addresses
>>> public_key_to_addresses(public_key="02d2ce831dd06e5c1f5b1121ef34c2af4bcb01b126e309234adbc3561b60c9360e")
>>> public_key_to_addresses(public_key="02d2ce831dd06e5c1f5b1121ef34c2af4bcb01b126e309234adbc3561b60c9360e", network="mainnet")
'164MQi977u9GUteHr4EPH27VkkdxmfCvGW'
>>> public_key_to_addresses(public_key="04d2ce831dd06e5c1f5b1121ef34c2af4bcb01b126e309234adbc3561b60c9360ea7f23327b49ba7f10d17fad15f068b8807dbbc9e4ace5d4a0b40264eefaf31a4")
>>> public_key_to_addresses(public_key="04d2ce831dd06e5c1f5b1121ef34c2af4bcb01b126e309234adbc3561b60c9360ea7f23327b49ba7f10d17fad15f068b8807dbbc9e4ace5d4a0b40264eefaf31a4", network="mainnet")
'1Jq6MksXQVWzrznvZzxkV6oY57oWXD9TXB'
>>> public_key_to_addresses(public_key="02d2ce831dd06e5c1f5b1121ef34c2af4bcb01b126e309234adbc3561b60c9360e", network="testnet")
'mkaJhmE5vvaXG17uZdCm6wKpckEfnG4yt9'
>>> public_key_to_addresses(public_key="04d2ce831dd06e5c1f5b1121ef34c2af4bcb01b126e309234adbc3561b60c9360ea7f23327b49ba7f10d17fad15f068b8807dbbc9e4ace5d4a0b40264eefaf31a4", network="testnet")
'myM3eoxWDWxFe7GYHZw8K21rw7QDNZeDYM'
"""

if network not in ["mainnet", "testnet"]:
Expand Down Expand Up @@ -652,7 +656,7 @@ def confirm_code(
:type confirmation_code: str
:param network: Network type
:type network: Literal["mainnet", "testnet"], default to ``mainnet``
:param detail: To show in deatil, default to ``False``
:param detail: To show in detail, default to ``False``
:type detail: bool
:returns: Union[str, dict] -- Confirmation of address info's
Expand Down Expand Up @@ -751,7 +755,7 @@ def bip38_decrypt(
:type passphrase: str
:param network: Network type
:type network: Literal["mainnet", "testnet"], default to ``mainnet``
:param detail: To show in deatil, default to ``False``
:param detail: To show in detail, default to ``False``
:type detail: bool
:returns: Union[str, dict] -- WIF or All private Key info's
Expand Down
14 changes: 9 additions & 5 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ _______________
PRIVATE_KEY: str = "cbf4b9f70470856bb4f40f80b87edb90865997ffee6df315ab166d713af433a5"
# Passphrase / password
PASSPHRASE: str = "meherett" # u"\u03D2\u0301\u0000\U00010400\U0001F4A9"
# Network type
NETWORK: Literal["mainnet", "testnet"] = "mainnet"
# To show detail
DETAIL: bool = True
# Wallet important format's
Expand All @@ -83,12 +85,12 @@ _______________
print("WIF:", WIF)

encrypted_wif: str = bip38_encrypt(
wif=WIF, passphrase=PASSPHRASE
wif=WIF, passphrase=PASSPHRASE, network=NETWORK
)
print("BIP38 Encrypted WIF:", encrypted_wif)

print("BIP38 Decrypted:", json.dumps(bip38_decrypt(
encrypted_wif=encrypted_wif, passphrase=PASSPHRASE, detail=DETAIL
encrypted_wif=encrypted_wif, passphrase=PASSPHRASE, network=NETWORK, detail=DETAIL
), indent=4))

print("-" * 125)
Expand Down Expand Up @@ -152,6 +154,8 @@ EC multiply:

# Passphrase / password
PASSPHRASE: str = "meherett" # u"\u03D2\u0301\u0000\U00010400\U0001F4A9"
# Network type
NETWORK: Literal["mainnet", "testnet"] = "mainnet"
# To show detail
DETAIL: bool = True
# List of samples with owner salt, seed, public key type, lot, and sequence
Expand Down Expand Up @@ -182,16 +186,16 @@ EC multiply:
print("Intermediate Passphrase:", intermediate_passphrase)

encrypted_wif: dict = create_new_encrypted_wif(
intermediate_passphrase=intermediate_passphrase, public_key_type=SAMPLE["public_key_type"], seed=SAMPLE["seed"]
intermediate_passphrase=intermediate_passphrase, public_key_type=SAMPLE["public_key_type"], seed=SAMPLE["seed"], network=NETWORK
)
print("Encrypted WIF:", json.dumps(encrypted_wif, indent=4))

print("Confirm Code:", json.dumps(confirm_code(
passphrase=PASSPHRASE, confirmation_code=encrypted_wif["confirmation_code"], detail=DETAIL
passphrase=PASSPHRASE, confirmation_code=encrypted_wif["confirmation_code"], network=NETWORK, detail=DETAIL
), indent=4))

print("BIP38 Decrypted:", json.dumps(bip38_decrypt(
encrypted_wif=encrypted_wif["encrypted_wif"], passphrase=PASSPHRASE, detail=DETAIL
encrypted_wif=encrypted_wif["encrypted_wif"], passphrase=PASSPHRASE, network=NETWORK, detail=DETAIL
), indent=4))

print("-" * 125)
Expand Down

0 comments on commit feb511f

Please sign in to comment.