From 2f53c3eaba96742413c7aa38b91de41f0ff381a3 Mon Sep 17 00:00:00 2001 From: meherett Date: Sat, 14 Oct 2023 06:49:23 +0300 Subject: [PATCH] Update: README.md doc example --- README.md | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 55962bc..f5668e5 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,8 @@ [![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) -[![Coverage Status](https://coveralls.io/repos/github/meherett/python-bip38/badge.svg?branch=master)](https://coveralls.io/github/meherett/python-bip38) + +[comment]: <> ([![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. @@ -39,7 +40,9 @@ pip install git+git://github.com/meherett/python-bip38.git from bip38 import ( private_key_to_wif, bip38_encrypt, bip38_decrypt ) -from typing import List +from typing import ( + List, Literal +) import json @@ -47,6 +50,8 @@ import json 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 @@ -60,12 +65,12 @@ for WIF in WIFs: 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) @@ -114,13 +119,17 @@ BIP38 Decrypted: { from bip38 import ( intermediate_code, create_new_encrypted_wif, confirm_code, bip38_decrypt ) -from typing import List +from typing import ( + List, Literal +) import json import os # 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 @@ -151,16 +160,16 @@ for SAMPLE in SAMPLES: 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)