Bitcoin and other Cryptocurrencies Library for Python. Includes a fully functional wallet, Mnemonic key generation and management and connection with various service providers to receive and send blockchain and transaction information.
If I import anything at all from bitcoinlib, I get the following traceback.
Windows 10
bitcoinlib version 0.6.4
Python version 3.10.5
pipenv version 2020.11.15
Traceback:
---------------------------------------------------------------------------
UnicodeDecodeError Traceback (most recent call last)
project\app.py in <cell line: 3>()
1 """Run my btc stuff for me"""
2 import os
----> 3 from bitcoinlib import *
4 # from bitcoinlib.mnemonic import Mnemonic
5 from dotenv import load_dotenv
File project\.venv\lib\site-packages\bitcoinlib\__init__.py:22, in <module>
20 import bitcoinlib.encoding
21 import bitcoinlib.mnemonic
---> 22 import bitcoinlib.keys
23 import bitcoinlib.transactions
24 import bitcoinlib.wallets
File project\.venv\lib\site-packages\bitcoinlib\keys.py:26, in <module>
23 import collections
24 import json
---> 26 from bitcoinlib.networks import Network, network_by_value, wif_prefix_search
27 from bitcoinlib.config.secp256k1 import *
28 from bitcoinlib.encoding import *
File project\.venv\lib\site-packages\bitcoinlib\networks.py:58, in <module>
54 f.close()
55 return network_definitions
---> 58 NETWORK_DEFINITIONS = _read_network_definitions()
61 def _format_value(field, value):
62 if field[:6] == 'prefix':
File project\.venv\lib\site-packages\bitcoinlib\networks.py:51, in _read_network_definitions()
48 f = fn.open()
50 try:
---> 51 network_definitions = json.loads(f.read())
52 except json.decoder.JSONDecodeError as e:
53 raise NetworkError("Error reading provider definitions from %s: %s" % (fn, e))
File ~\AppData\Local\Programs\Python\Python310\lib\encodings\cp1252.py:23, in IncrementalDecoder.decode(self, input, final)
22 def decode(self, input, final=False):
---> 23 return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 11353: character maps to <undefined>
Edit: also happens when I use Wallet.create()
UnicodeDecodeError Traceback (most recent call last)
Input In [1], in <cell line: 27>()
22 missing_keys = tuple(key for (key, value) in ENVIRONMENT.items() if not value)
23 raise EnvironmentError(
24 f"Missing environment variables: {', '.join(missing_keys)}"
25 )
---> 27 w = Wallet.create(
28 ENVIRONMENT.get('WALLET_NAME'),
29 keys=ENVIRONMENT.get('WALLET_PASSPHRASE'),
30 network='testnet')
File bitcoinlib\wallets.py:1207, in Wallet.create(cls, name, keys, owner, network, account_id, purpose, scheme, sort_keys, password, witness_type, encoding, multisig, sigs_required, cosigner_id, key_path, db_uri)
1205 if not network:
1206 raise WalletError("Please specify network when using passphrase to create a key")
-> 1207 key = HDKey.from_seed(Mnemonic().to_seed(key, password), network=network)
1208 else:
1209 try:
File bitcoinlib\mnemonic.py:81, in Mnemonic.to_seed(self, words, password, validate)
63 def to_seed(self, words, password='', validate=True):
64 """
65 Use Mnemonic words and optionally a password to create a PBKDF2 seed (Password-Based Key Derivation Function 2)
66
(...)
79 :return bytes: PBKDF2 seed
80 """
---> 81 words = self.sanitize_mnemonic(words)
82 # Check if passphrase is valid
83 if validate:
File bitcoinlib\mnemonic.py:233, in Mnemonic.sanitize_mnemonic(self, words)
222 """
223 Check and convert list of words to utf-8 encoding.
224
(...)
230 :return str: Sanitized list of words
231 """
232 words = normalize_string(words)
--> 233 language = self.detect_language(words)
234 if isinstance(words, TYPE_TEXT):
235 words = words.split(' ')
File bitcoinlib\mnemonic.py:210, in Mnemonic.detect_language(words)
208 if fn.suffix == ".txt":
209 with open(os.path.join(str(BCL_INSTALL_DIR), 'wordlist', fn)) as f:
--> 210 wordlist = [w.strip() for w in f.readlines()]
211 language = fn.name.split('.')[0]
212 wlcount[language] = 0
File ~\AppData\Local\Programs\Python\Python310\lib\encodings\cp1252.py:23, in IncrementalDecoder.decode(self, input, final)
22 def decode(self, input, final=False):
---> 23 return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 22: character maps to <undefined>```
If I import anything at all from bitcoinlib, I get the following traceback.
Windows 10 bitcoinlib version 0.6.4 Python version 3.10.5 pipenv version 2020.11.15
Traceback:
Edit: also happens when I use Wallet.create()