pybitcash / bitcash

BitCash: Python Bitcoin Cash Library (fork of ofek's Bit)
https://bitcash.dev
MIT License
97 stars 39 forks source link

ValueError: "0" is an invalid base58 encoded character. on PrivKeyTestnet #113

Closed goodatdrowning closed 2 years ago

goodatdrowning commented 2 years ago

I'm just getting started using this library, and the examples work OK.

However, when I try to use my own Testnet private keys, it throws an error:

k2 = PrivateKeyTestnet('TESTNETKEYGOESHERE')

I thought it might be an invalid format of address, so I made a new address then used k.to_wif() to get the private key and tried that, and it's still throwing this error (I'll leave the key since it's just testnet haha):

raceback (most recent call last): File "bchwal.py", line 7, in k2 = PrivateKeyTestnet('qp0srrxty5840ht02avj3qsgu6hppux0dsjutfy5ud') File "/home/etali/.local/lib/python3.8/site-packages/bitcash/wallet.py", line 499, in init super().init(wif=wif, network=network) File "/home/etali/.local/lib/python3.8/site-packages/bitcash/wallet.py", line 159, in init super().init(wif=wif) File "/home/etali/.local/lib/python3.8/site-packages/bitcash/wallet.py", line 67, in init private_key_bytes, compressed, version = wif_to_bytes(wif, regtest) File "/home/etali/.local/lib/python3.8/site-packages/bitcash/format.py", line 79, in wif_to_bytes private_key = b58decode_check(wif) File "/home/etali/.local/lib/python3.8/site-packages/bitcash/base58.py", line 70, in b58decode_check decoded = b58decode(string) File "/home/etali/.local/lib/python3.8/site-packages/bitcash/base58.py", line 52, in b58decode raise ValueError( ValueError: "0" is an invalid base58 encoded character.

I assume I'm missing something obvious? Thanks

merc1er commented 2 years ago

qp0srrxty5840ht02avj3qsgu6hppux0dsjutfy5ud is not a valid private key. Looks like a public key without prefix.

merc1er commented 2 years ago

Here is a tutorial on how to use to_wif() and other basic concepts: https://read.cash/@merc1er/python-bitcoin-cash-part-2-65c70f27