python-hdwallet icon indicating copy to clipboard operation
python-hdwallet copied to clipboard

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

Open Pymmdrza opened this issue 2 years ago • 1 comments

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....

Pymmdrza avatar Jun 01 '22 11:06 Pymmdrza

@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.

meherett avatar Jun 03 '22 07:06 meherett