meherett / python-hdwallet

Python-based library for the implementation of a hierarchical deterministic wallet generator for more than 140+ multiple cryptocurrencies.
https://hdwallet.readthedocs.io
MIT License
443 stars 147 forks source link

P2PKH address for the uncompressed public key #58

Open meir555 opened 2 years ago

meir555 commented 2 years ago

Code:

from hdwallet import HDWallet
from hdwallet.symbols import BTC as SYMBOL
hdwallet: HDWallet = HDWallet(symbol=SYMBOL)
PRIVATE_KEY: str = hashlib.sha256(b"asdasd").hexdigest()
hdwallet.from_private_key(PRIVATE_KEY)
print("Uncompressed:", hdwallet.uncompressed())
print("P2PKH Address:", hdwallet.p2pkh_address())

Result:

Uncompressed: fb2b1bf2bcb92b11db6caee48f4a0656dddb0104abc8583a67be81581868ae31551a7aeb83a4004d4b169d4d8020f0b1fd4ae977e4bd9da0d9f3414a0c0353c5
P2PKH Address: 1AQYRDSw3eUo3LuWbdENKdLudxJ2ENuUwN

Problems:

  1. Shouldn't you add 04 to the beginning of the uncompressed key?
  2. The address P2PKH Address: 1AQYRDSw3eUo3LuWbdENKdLudxJ2ENuUwN is the address of the compressed public key, can you add the P2PKH Address for the uncompressed public key? For the example above, from my calculation the P2PKH address for the uncompressed public key is 1Mw7FXN7D7du9umtbkhov2ftELKQw1wFor
meherett commented 2 years ago

Duplicated https://github.com/meherett/python-hdwallet/issues/50