From 58f1ac32079b1cbe1f5621e5ef5159dd3287c321 Mon Sep 17 00:00:00 2001 From: Vivek Teega Date: Sat, 9 Jul 2022 11:37:20 +0530 Subject: [PATCH 1/7] Converting from SegWit address to Legacy address --- pybtc/functions/address.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pybtc/functions/address.py b/pybtc/functions/address.py index fb489ff..126f2c1 100644 --- a/pybtc/functions/address.py +++ b/pybtc/functions/address.py @@ -14,7 +14,7 @@ from pybtc.functions.encode import (encode_base58, base32charset_upcase) -def hash_to_address(address_hash, testnet=False, script_hash=False, witness_version=0): +def hash_to_address(address_hash, testnet=False, script_hash=False, witness_version=None): """ Get address from public key/script hash. In case PUBKEY, P2PKH, P2PKH public key/script hash is SHA256+RIPEMD160, P2WSH script hash is SHA256. @@ -70,7 +70,7 @@ def hash_to_address(address_hash, testnet=False, script_hash=False, witness_vers return "%s1%s" % (hrp, rebase_5_to_32(address_hash + checksum).decode()) -def public_key_to_address(pubkey, testnet=False, p2sh_p2wpkh=False, witness_version=0): +def public_key_to_address(pubkey, testnet=False, p2sh_p2wpkh=False, witness_version=None): """ Get address from public key/script hash. In case PUBKEY, P2PKH, P2PKH public key/script hash is SHA256+RIPEMD160, P2WSH script hash is SHA256. From abbd422fa4a662de21e41993f2375676c0f58b67 Mon Sep 17 00:00:00 2001 From: Vivek Teega Date: Sat, 9 Jul 2022 12:26:12 +0530 Subject: [PATCH 2/7] Update Readme --- README.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/README.md b/README.md index 94742d6..48ee8ad 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,46 @@ To install pybtc, simply use pip Documentation is available at https://pybtc.readthedocs.io +#### Message signing and verification + +Every message sent to the Blockchain is in hash format, and not in plain string. So we convert the message we are signing into a SHA256 hash before. + +``` +>>> import pybtc + +# ADDRESS GENERATION +>>> a = pybtc.Address() +>>> a = pybtc.Address(address_type="P2PKH") +>>> a.address +'FTP7LL7QjhgKfqYX1pis18bCqEpZaGSRzZ' +>>> a.private_key.wif +'R8Gw2Mr3n2fY1ydB2X5gEehxHkdhboeUD6yw4wRtVKHaqAd9gdkK' +>>> a.private_key.hex +'16b6aca5ff6a3bf3a1332dd4edf87880b2883cb4fe16effd073e2e866aa141aa' +>>> a.public_key.hex +'033c30b269e2d5df229f3f0ce294b19c4f0a3a8d12280415ce41e7bd3784a619c4' + +# CONVERT MESSAGE INTO SHA-256 HASH +>>> pybtc.sha256(b'vivek'.hex()) +b'\xa3\xdas\x97e\x01\x81,\xd7\xb8!\xa2\x0b\xfb\t\xaf\nj\x89\x1eA\x9c\xdf\xb7a\xfb\x19\xa9,\x91BB' +>>> pybtc.sha256(b'vivek'.hex()).hex() +'a3da73976501812cd7b821a20bfb09af0a6a891e419cdfb761fb19a92c914242' +>>> msg = b'vivek'.hex() +>>> msg_hash_hex = sha256(msg).hex() +>>> msg_hash_bytes = sha256(msg) +>>> msg +'766976656b' +>>> msg_hash_hex +'a3da73976501812cd7b821a20bfb09af0a6a891e419cdfb761fb19a92c914242' +>>> msg_hash_bytes +b'\xa3\xdas\x97e\x01\x81,\xd7\xb8!\xa2\x0b\xfb\t\xaf\nj\x89\x1eA\x9c\xdf\xb7a\xfb\x19\xa9,\x91BB' + +# SIGN AND VERIFY THE MESSAGE +>>> sig_msg_hex = pybtc.sign_message(msg_hash_hex, a.private_key.wif) +>>> pybtc.verify_signature(sig_msg_hex, a.public_key.hex, msg_hash_hex) +True +``` + ### How to Contribute From bb8bc82823f7465063e50e8b70f0343af7f42f90 Mon Sep 17 00:00:00 2001 From: tripathyr Date: Sat, 9 Jul 2022 12:30:31 +0530 Subject: [PATCH 3/7] Update README.md --- README.md | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 48ee8ad..1b65f07 100644 --- a/README.md +++ b/README.md @@ -16,11 +16,11 @@ Current version is 2.0 ### Installation -To install pybtc, simply use pip +To install pyflo, simply use pip - $ git clone https://github.com/bitaps-com/pybtc - $ cd pybtc - $ python3 setup.py install + $ git clone https://github.com/ranchimall/pyflo + $ cd pyflo + $ sudo python3 setup.py install ### Dependencies @@ -40,7 +40,6 @@ Every message sent to the Blockchain is in hash format, and not in plain string. >>> import pybtc # ADDRESS GENERATION ->>> a = pybtc.Address() >>> a = pybtc.Address(address_type="P2PKH") >>> a.address 'FTP7LL7QjhgKfqYX1pis18bCqEpZaGSRzZ' @@ -73,17 +72,4 @@ True ``` -### How to Contribute - -In order to make a clone of the GitHub repo: open the link and press the “Fork” button on the upper-right menu of the web page. - -Workflow is pretty straightforward: - -1. Clone the GitHub -2. Make a change -3. Make sure all tests passed -4. Add a record into file into change.log. -5. Commit changes to own pybtc clone -6. Make pull request from github page for your clone against master branch - From 9f0cf4425fcfb0e3d330f00080c81d992f4f7dc9 Mon Sep 17 00:00:00 2001 From: tripathyr Date: Sat, 9 Jul 2022 12:30:57 +0530 Subject: [PATCH 4/7] Update README.md --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 1b65f07..7c49a6e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,4 @@ - - -## Python bitcoin library +## Python bitcoin library modified for FLO Current version is 2.0 From 8938aef84f4eb88bdb9e918b4ae54fc3621ce118 Mon Sep 17 00:00:00 2001 From: tripathyr Date: Sat, 9 Jul 2022 12:31:17 +0530 Subject: [PATCH 5/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7c49a6e..389f28b 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Current version is 2.0 ### Installation -To install pyflo, simply use pip +To install pyflo, $ git clone https://github.com/ranchimall/pyflo $ cd pyflo From 1ef2b2b161b4db1c8245eff267964870eec07894 Mon Sep 17 00:00:00 2001 From: tripathyr Date: Sat, 9 Jul 2022 12:31:39 +0530 Subject: [PATCH 6/7] Update README.md --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index 389f28b..4df352f 100644 --- a/README.md +++ b/README.md @@ -26,10 +26,6 @@ To install pyflo, * secp256k1 -### Documentation - -Documentation is available at https://pybtc.readthedocs.io - #### Message signing and verification Every message sent to the Blockchain is in hash format, and not in plain string. So we convert the message we are signing into a SHA256 hash before. From 7df603d88d76957671b82fba06edbbac9edc4eb9 Mon Sep 17 00:00:00 2001 From: tripathyr Date: Sat, 9 Jul 2022 12:31:58 +0530 Subject: [PATCH 7/7] Update README.md --- README.md | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/README.md b/README.md index 4df352f..e297a6f 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,5 @@ ## Python bitcoin library modified for FLO -Current version is 2.0 - - -### Feature Support - -* Basic functions -* Supports addresses types PUBKEY, P2PKH, P2SH, P2SH-PWPKH, P2WPKH, P2WSH. -* Supports BIP32(Hierarchical Deterministic Wallets), BIP39(Mnemonic code generation) -* Supports BIP141(Segregated Witness) -* Transaction constructor - ### Installation