Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BTC Address : [Segwit ] Wrong #11

Closed
Noname400 opened this issue Jan 11, 2022 · 5 comments
Closed

BTC Address : [Segwit ] Wrong #11

Noname400 opened this issue Jan 11, 2022 · 5 comments

Comments

@Noname400
Copy link

import secp256k1_lib
bip44_h160_c = secp256k1_lib.privatekey_to_h160(0, True, 0xe0353e2293a63769802b1e3d0d9affdedfda4d4486ed300428eadac4620427bf)

secp256k1_lib.hash_to_address(1, False, bip44_h160_c)
'32Q5Sa9pTezVeBYBZitidknwTs1Gd9HmPJ' False
secp256k1_lib.hash_to_address(1, True, bip44_h160_c)
'32Q5Sa9pTezVeBYBZitidknwTs1Gd9HmPJ' False

PVK1 BTC Address : [Segwit ] 33eYbdrqZcxSXvPb26fj8KBqW4xxofzRpC True

@Noname400 Noname400 reopened this Jan 11, 2022
@Noname400
Copy link
Author

why does the privatekey_to_h160 function need addr_type

@Noname400
Copy link
Author

if you do so : bip44_h160_c = secp256k1_lib.privatekey_to_h160(1, True, 0xe0353e2293a63769802b1e3d0d9affdedfda4d4486ed300428eadac4620427bf)
then the address will be correct

but what does the address type have to do with hash160?

@Noname400
Copy link
Author

Thanks in advance.
Thank you so much for your work.

@iceland2k14
Copy link
Owner

Thanks @Noname400
Actually the reason to keep addr_type was just function reuse of same code.

For Legacy or bech32 address the hash160 is same so there is no difference in these 2. But for P2SH address situation is complicated as it needs double hash. (A hash160 of 0014+hash160.) That is the reason by decoding back p2sh address you can only go back 1 level up of hash160 and not the second level.

Let me think about if i can reorganise my functions any different. Currently i just kept the same so that they are equivalent with address to avoid confusion.

@Noname400
Copy link
Author

thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants