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 148 forks source link

Create BitcoinCash from privatekey [bitcoincash:qr...] #57

Open Pymmdrza opened 2 years ago

Pymmdrza commented 2 years ago

How create bitcoincash address (bitcoincash:qr...) from this package ??? used this source , not worked to this type address :

from hdwallwet import HDWallet
from hdwallet.symbols import BCH as SYMBOL
hdwallet: HDWallet = HDWallet(symbol=SYMBOL)
hdwallet.from_private_key(private_key=private_key)
addr = hdwallet.p2wpkh_address()
print(addr)
# out: bc1qgrdf2l6z6u78zpdj4excxp44r4amquxlalcnpd

i need this address type : bitcoincash:q....

meherett commented 2 years ago

@Pymmdrza, Basically Bitcoin Cash has 3 different types of Pay to Public Key Hash (P2PKH) addresses. Those are: 1, CashAddr addresses for Bitcoin Cash (ie starting with q or bitcoincash:q instead of 1) 2, BitPay-style addresses for Bitcoin Cash (ie starting with C instead of 1) 3, Legacy addresses for Bitcoin Cash (ie starting with 1)

So, on the currerent version of this hdwallet package; you can only generate addresses on the second type of BitPay-style addresses for Bitcoin Cash (ie starting with C instead of 1) style. In the upcoming version I will add the rest of them.

And also call this hdwallet.p2pkh_address() instead of hdwallet.p2wpkh_address() function because p2wpkh_address() is Pay to Witness Public Key Hash address or it's SegWit address.

Thanks.