Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: initial_value must be unicode or None, not str #91

Closed
Goro2030 opened this issue Sep 24, 2019 · 2 comments
Closed

TypeError: initial_value must be unicode or None, not str #91

Goro2030 opened this issue Sep 24, 2019 · 2 comments

Comments

@Goro2030
Copy link

When running a very basic test, like this:

from bitcoinlib.services.services import *
from bitcoinlib.services.bitcoind import *
from pprint import pprint


from bitcoinlib.services.bitcoind import BitcoindClient
bdc = BitcoindClient.from_config('/home/user00/.bitcoin/bitcoin.conf')

# Check bitcoind connection
pprint(bdc.proxy.getnetworkinfo())

# Get latest block
latest_block_hash = bdc.proxy.getbestblockhash()
print("Getting latest block with hash %s" % latest_block_hash)
latest_block = bdc.proxy.getblock(latest_block_hash)
transactions = latest_block['tx']
print("Found %d transactions" % len(transactions))

I get the error:

python blockchain_parse.py
Traceback (most recent call last):
  File "blockchain_parse.py", line 7, in <module>
    bdc = BitcoindClient.from_config('/home/chile00/.bitcoin/bitcoin.conf')
  File "/home/chile00/.local/lib/python2.7/site-packages/bitcoinlib/services/bitcoind.py", line 92, in from_config
    config.read_string(config_string)
  File "/usr/lib/python2.7/dist-packages/backports/configparser/__init__.py", line 722, in read_string
    sfile = io.StringIO(string)
TypeError: initial_value must be unicode or None, not str

Python is 3.7 . Running on Ubuntu kernel version 4.18.0.25

@mccwdev
Copy link
Member

mccwdev commented Sep 27, 2019

The configparser module is complaining about the encoding of the configfile which should be unicode apparently. So maybe you can try to convert the format of the config file.

You can also avoid this issue by adding the connection setting to the .bitcoinlib/config/providers.json config file:
"bitcoind.testnet": { "provider": "bitcoind", "network": "testnet", "client_class": "BitcoindClient", "url": "http://user:password@server_url:18332", "api_key": "", "priority": 11, "denominator": 100000000 }

See https://bitcoinlib.readthedocs.io/en/latest/_static/manuals.setup-bitcoind-connection.html

@Goro2030
Copy link
Author

Goro2030 commented Sep 27, 2019 via email

@Goro2030 Goro2030 closed this as completed Oct 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants