Skip to content

Commit

Permalink
python3 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
oskyk committed Jan 17, 2018
1 parent 1a5d561 commit af06957
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
dist
dist
testing.py
1 change: 1 addition & 0 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pass
18 changes: 11 additions & 7 deletions cashaddress/convert.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from cashaddress.crypto import *
from base58 import b58decode_check, b58encode_check
import sys


class InvalidAddress(Exception):
Expand Down Expand Up @@ -43,9 +44,14 @@ def cash_address(self):

@staticmethod
def code_list_to_string(code_list):
output = ''
for code in code_list:
output += chr(code)
if sys.version_info > (3, 0):
output = bytes()
for code in code_list:
output += bytes([code])
else:
output = ''
for code in code_list:
output += chr(code)
return output

@staticmethod
Expand All @@ -57,8 +63,6 @@ def _address_type(address_type, version):

@staticmethod
def from_string(address_string):
if not isinstance(address_string, str):
raise InvalidAddress('Expected string as input')
if ':' not in address_string:
return Address._legacy_string(address_string)
else:
Expand All @@ -72,8 +76,8 @@ def _legacy_string(address_string):
raise InvalidAddress('Could not decode legacy address')
version = Address._address_type('legacy', decoded[0])[0]
payload = list()
for letter in str(decoded[1:]):
payload.append(ord(letter))
for letter in decoded[1:]:
payload.append(letter)
return Address(version, payload)

@staticmethod
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
from setuptools import find_packages

setup(name='cashaddress',
version='1.0.0',
version='1.0.1',
packages=find_packages(),
install_requires=['base58==0.2.5'],
description='Python tool for converty bitcoin cash legacy addresses',
author='Oskar Hladky',
author_email='[email protected]',
url='https://github.com/oskyk/cashaddress',
download_url='https://github.com/oskyk/cashaddress/archive/1.0.0.tar.gz',
python_requires='>=2.7,<3',
download_url='https://github.com/oskyk/cashaddress/archive/1.0.1.tar.gz',
python_requires='>=2.7',
keywords=['bitcoincash', 'bch', 'address', 'cashaddress', 'legacy', 'convert']
)

0 comments on commit af06957

Please sign in to comment.