Skip to content

Conversation

@PiRK
Copy link

@PiRK PiRK commented Dec 21, 2020

This PR adds an prefix argument to the Address.cash_address method.
If not specified, it defaults to the current prefix if the object was
instantiated from string via a CashAddr, or to the "bitcoincash:" prefix if
it was instantiated from string with a legacy address.

Test plan:
python3 -m tests.test

This is a simple solution to #16

This commit adds an `prefix` argument to the `Address.cash_address` method.
If not specified, it defaults to the current prefix if the object was
instantiated  from string via a CashAddr, or to the "bitcoincash:" prefix if
it was instantiated from string with a legacy address.

Test plan:

python3 -m tests.test
@PiRK
Copy link
Author

PiRK commented Dec 21, 2020

It also provides a solution for issue #13:

>>> from cashaddress.convert import Address
>>> regtest_cashaddr = Address.from_string(
...     "bitcoincash:qr4pqy6q4cy2d50zpaek57nnrja7289fkskz6jm7yf"
...     ).cash_address(prefix='regtest')
>>> print(regtest_cashaddr)
regtest:qr4pqy6q4cy2d50zpaek57nnrja7289fksjm6es9se
>>> 

@coveralls
Copy link

coveralls commented Dec 21, 2020

Pull Request Test Coverage Report for Build 22

  • 13 of 13 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.7%) to 93.81%

Totals Coverage Status
Change from base Build 14: 0.7%
Covered Lines: 197
Relevant Lines: 210

💛 - Coveralls

@PiRK
Copy link
Author

PiRK commented Dec 21, 2020

I need to sort out the issue with case.

If the users specifies an uppercase prefix, the output should be entirely
uppercase. Mixed-case prefixes are invalid.

Note that the case is not recorded in the instance, when creating an Address
from string. If the prefix is not explicitely specified and uppercase, the
output from `Address.cash_address()` will always be lowercase.

Test plan:
python3 -m tests.test
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

Successfully merging this pull request may close these issues.

2 participants