1
0

paymentrequest: be explicit about only allowing "addresses"

This commit is contained in:
SomberNight
2018-11-14 16:04:43 +01:00
parent a266de6735
commit e059867314
3 changed files with 16 additions and 11 deletions

View File

@@ -444,8 +444,7 @@ def assert_str(*args):
assert isinstance(x, str)
def to_string(x, enc):
def to_string(x, enc) -> str:
if isinstance(x, (bytes, bytearray)):
return x.decode(enc)
if isinstance(x, str):
@@ -453,7 +452,8 @@ def to_string(x, enc):
else:
raise TypeError("Not a string or bytes like object")
def to_bytes(something, encoding='utf8'):
def to_bytes(something, encoding='utf8') -> bytes:
"""
cast string to bytes() like object, but for python2 support it's bytearray copy
"""
@@ -471,16 +471,13 @@ bfh = bytes.fromhex
hfu = binascii.hexlify
def bh2u(x):
def bh2u(x: bytes) -> str:
"""
str with hex representation of a bytes-like object
>>> x = bytes((1, 2, 10))
>>> bh2u(x)
'01020A'
:param x: bytes
:rtype: str
"""
return hfu(x).decode('ascii')