Closed taxa-chris closed 4 years ago
Hi @taxa-chris, thanks for the report. As you can see in the docstring of multihash/__init__.py
, Multihash
expects a bytes
object as a second argument, not a str
.
Actually, the call using the base64
encoding may have failed as well, it happened to work by pure chance of the Base64 call path being more permissive with accepted types…
I'm closing the issue but feel free to open another one regarding that behavior (but mind you, I don't have much time to take care of these issues anyway).
Cheers!
The var dig
is being passed into MultiHash.__init__
as the second argument, which is always a bytes object, since dig
is the output of hashlib.digest()
Anyways, I think the problem is the "ascii" argument needs to be removed, as that seems to fix the problem:
In [5]: import base58
In [6]: base58.b58encode(b'34')
Out[6]: b'4u1'
In [7]: base58.b58encode('34')
Out[7]: b'4u1'
In [8]: bytes(base58.b58encode('34'))
Out[8]: b'4u1'
In [9]: bytes(base58.b58encode('34'), 'ascii')
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-9-f5606cddfe84> in <module>
----> 1 bytes(base58.b58encode('34'), 'ascii')
TypeError: encoding without a string argument
In [10]:
Why is 'ascii' there in the first place?