oskyk / cashaddress

Python tool for convert bitcoin cash legacy addresses
MIT License
46 stars 36 forks source link

Support a different prefix #16

Open PiRK opened 3 years ago

PiRK commented 3 years ago

Hi, i work with Bitcoin ABC. We plan to keep using the CashAddr format, but obviously we will change the prefix after the recent fork.

Would you accept a pull request to support our new prefix in addition to bitcoincash:? I can do it in such a way that none of the existing API is modified, I would only add a few attributes, methods and functions.

This would avoid duplication of the whole codebase in a new fork, and allow three way conversion (legacy, bitcoincash, new prefix).

PiRK commented 3 years ago

The new prefix will be announced very soon as part of the rebranding, btw.

ghost commented 3 years ago

I imagine we would need to have some kind of API argument that would be BITCOIN_ABC=1 or BITCOIN_CASH_VERSION=(ABC|MAIN), etc?

PiRK commented 3 years ago

I was thinking of adding : ABC_MAINNET_PREFIX, ABC_TESTNET_PREFIX, Address.abc_cash_address, to_abc_cash_addr

And make Address.from_string, to_legacy_addr, to_cash_addr all support the 3 type of addresses as input (default to "bitcoincash:" if the prefix is missing).

Maybe also add an Address.from_cashaddr_arbitrary_prefix() method to support stuff like "regtest:", "simpleledger:"...

PiRK commented 3 years ago

I see that you already support importing CashAddr strings with any prefix. The only thing that is missing is a simple way to output to any other prefix. What do you think about an optional prefix argument for the Address.cash_address() method?