diff --git a/trezorlib/tools.py b/trezorlib/tools.py index e63f20960..83be8d880 100644 --- a/trezorlib/tools.py +++ b/trezorlib/tools.py @@ -107,6 +107,10 @@ def b58decode(v, length=None): if isinstance(v, bytes): v = v.decode() + for c in v: + if c not in __b58chars: + raise ValueError("invalid Base58 string") + long_value = 0 for (i, c) in enumerate(v[::-1]): long_value += __b58chars.find(c) * (__b58base ** i)