1200wd / bitcoinlib

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.
http://bitcoinlib.readthedocs.io/
GNU General Public License v3.0
596 stars 199 forks source link

bitcoinlib.scripts.ScriptError: Expected a sequence of 69 bytes, got 70 #400

Closed heyanlong closed 3 months ago

heyanlong commented 3 months ago
block_conn.getblock(135106)
Traceback (most recent call last):
  File "/home/ec2-user/.virtualenvs/web3-btc/lib/python3.9/site-packages/bitcoinlib/scripts.py", line 345, in parse_bytesio
    sig = Signature.parse_bytes(data)
  File "/home/ec2-user/.virtualenvs/web3-btc/lib/python3.9/site-packages/bitcoinlib/keys.py", line 2003, in parse_bytes
    signature = convert_der_sig(signature[:-1], as_hex=False)
  File "/home/ec2-user/.virtualenvs/web3-btc/lib/python3.9/site-packages/bitcoinlib/encoding.py", line 457, in convert_der_sig
    r, s = DEREncoder.decode_signature(bytes(signature))
  File "/home/ec2-user/.virtualenvs/web3-btc/lib64/python3.9/site-packages/fastecdsa/encoding/der.py", line 65, in decode_signature
    raise InvalidDerSignature("Expected a sequence of {} bytes, got {}".format(
fastecdsa.encoding.der.InvalidDerSignature: Expected a sequence of 69 bytes, got 70
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/ec2-user/.virtualenvs/web3-btc/lib/python3.9/site-packages/bitcoinlib/scripts.py", line 351, in parse_bytesio
    raise ScriptError(str(e))
bitcoinlib.scripts.ScriptError: Expected a sequence of 69 bytes, got 70
python-BaseException
mccwdev commented 3 months ago

This code works for me:

srv = Service()
b = srv.getblock(135106)
print(b)

You could also try to add the strict=False option:

srv = Service(strict=False)
b = srv.getblock(135106)
print(b)
heyanlong commented 3 months ago

So, what is Service?

mccwdev commented 3 months ago

Sorry, I forgot the include

from bitcoinlib.services.services import Service