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

serialization issue #174

Open
vpereira opened this issue Apr 8, 2021 · 1 comment
Open

serialization issue #174

vpereira opened this issue Apr 8, 2021 · 1 comment

Comments

@vpereira
Copy link

vpereira commented Apr 8, 2021

from bitcoinlib.services.services import Service
srv = Service()
b = srv.getblock(300953)
print(b.serialize())

gives me the following error:

vpereira@foo:/mnt/c/Users/vpere/codes/bitcoin> python3 1.py
Traceback (most recent call last):
  File "1.py", line 19, in <module>
    print(b.serialize())
  File "/usr/lib/python3.6/site-packages/bitcoinlib/blocks.py", line 298, in serialize
    raise ValueError("Block contains incorrect number of transactions, can not serialize")
ValueError: Block contains incorrect number of transactions, can not serialize
@mccwdev
Copy link
Member

mccwdev commented Jun 14, 2021

Yes, that's not the behavior you would expect. For efficiency reasons the getblock method by default only parses the first 10 transactions. So transactions are missing and the block cannot be serialized.

I'm not sure what your goal is, but you can also retrieve the serialized block with the getrawblock method. Or you could add a limit parameter to the getblock method and set it to 9999 for instance.

But I think this needs improvement and the getblock method should store the rawblock as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants