stacks-network / pybitcoin

A Bitcoin python library for private + public keys, addresses, transactions, & RPC
MIT License
277 stars 117 forks source link

TypeError: Can't convert 'bytes' object to str implicitly #9

Closed ianthius closed 10 years ago

ianthius commented 10 years ago

I installed this on in the latest python for windows. I installed the coinkit and characters modules. I then attempted to utilize the simple walkthroughs in the readme and they throw an error on almost every method. Here is an example of the type of errors I am getting:

>>> from coinkit import NamecoinKeypair
>>> keypair = NamecoinKeypair()
>>> keypair.private_key()
b'0f1a40850d0e53164314111b24161d2dc4a90d843fcaa85944af54d64162b2ca'
>>> keypair.publickey()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'NamecoinKeypair' object has no attribute 'publickey'
>>> keypair.public_key()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\yousir\Desktop\coinkit-master\coinkit\keypair.py", line 102, in
 public_key
    return binascii.hexlify(self._bin_public_key())
  File "C:\Users\yousir\Desktop\coinkit-master\coinkit\keypair.py", line 82, in
_bin_public_key
    return '\x04' + self._ecdsa_public_key.to_string()
TypeError: Can't convert 'bytes' object to str implicitly
shea256 commented 10 years ago

Hm, strange.

It's working fine for me but I'm using python 2.7.

The error is in the to_string() method of the ECDSA public key.

We're using this ECDSA library: https://github.com/warner/python-ecdsa and it's possible that the library has an incompatibility with python 3.

ianthius commented 10 years ago

Okay, I will downgrade and try it. So far I have been unable to import the namecoin into my client. The key I get when I sha256 the passphrase and convert to base58check does not contain any namecoin. I'll see if your coinkit has some difference than gives me the correct private key to access my /u username.

shea256 commented 10 years ago

What's your OneName username? I can check the address you should be getting.

ianthius commented 10 years ago

"treebat" is the username i am attempting to edit / transfer

Shouldn't the namecoin private key just be the bitcoin private key? I successfully got the bitcoin public / private keypair from the brainwallet you gave me. I than ran importprivkey with the private key. Is that what i should be doing?

I successfully used coinkit (with Python 2.7) to do the address calculations and got the same thing as my other method. So I'm not sure why I am not getting anything in namecoin client.

Public address I am getting is N1JwpfN5GgNGAL9oUCvETL6gvstwgMftBH

ianthius commented 10 years ago

Okay, I finally found this issues (sorry I didn't realize it was already posted).

https://github.com/onenameio/onename/issues/1

It appears you guys may be holding on to the usernames ATM at a different address. If that is the case just let me know. I'll post in other issue report and we can move the conversation over there.

Thanks!

muneeb-ali commented 10 years ago

@ianthius I responded to you in the other thread https://github.com/onenameio/onename/issues/1 and I can confirm that "N1JwpfN5GgNGAL9oUCvETL6gvstwgMftBH" is the address that own your username now.