chainside / btcpy

A Python3 SegWit-compliant library which provides tools to handle Bitcoin data structures in a simple fashion.
https://www.chainside.net
GNU Lesser General Public License v3.0
271 stars 74 forks source link

Addresses generation #53

Open rafaelpac opened 5 years ago

rafaelpac commented 5 years ago

Hi! I don't understand something. If I take private key 0000000000000000000000000000000000000000000000000000000000000001 private key WIF is KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn public key compressed is 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798

https://segwitaddress.org/ will give me address 3JvL6Ymt8MVWiCNHC7oWU6nLeHNJKLZGLN but BTCPY will give me 3CNHUhP3uyB9EUtRLsmvFUmvGdjGdkTxJw

https://segwitaddress.org/bech32/ will give me address bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4 but BTCPY will give me bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4 (version 0) bc1pw508d6qejxtdg4y5r3zarvary0c5xw7k8e76x7 (version 1) bc1zw508d6qejxtdg4y5r3zarvary0c5xw7k6jw83r (version 2)

Why are these differences?!?

brunoerg commented 5 years ago

@rafaelpac It's everything right! From a key you can generate MANY addresses. You are assuming it should return always the same address, but it is not true. Reuse addresses is not a good practice.

rafaelpac commented 5 years ago

Bech32 is fine, I understand it, btcpy is working as expected. But for the P2SH, it is weird. What script is btcpy using to get that different address? I am not talking about HD addresses, I mean, SH means script hash, right? What script when hashed will make it to this p2sh btcpy gives out?

ghost commented 2 years ago

how is possible generate each time new address for Bech32 can some one share code?