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

Error in parsing one specific transaction only (edge case?) #338

Closed
pputnik opened this issue Oct 22, 2023 · 1 comment
Closed

Error in parsing one specific transaction only (edge case?) #338

pputnik opened this issue Oct 22, 2023 · 1 comment

Comments

@pputnik
Copy link

pputnik commented Oct 22, 2023

Hello,
I'm using Service.gettransaction(txid) to get a lot of transactions and found one which the library fails to process properly.

Way to test:

from bitcoinlib.services.services import *

srv = Service(network='bitcoin')
txid = "a618dc10b8a1f9d9a1469b3bb84fc17da86df2d51c27e2aa16fa130953840735"
print(srv.gettransaction(txid))   # <=== here returns False

I've traced the flow to /bitcoinlib/scripts.py:

class Script(object):
    def parse_bytesio(...):
         (...)
                if data_type == 'signature':
                    try:
                        sig = Signature.parse_bytes(data)
                        signatures.append(sig)
                        hash_type = sig.hash_type
                        blueprint.append('signature')
                    except Exception as e:
                       # ====== > Here `e` is "Expected a sequence of 69 bytes, got 70"
                        (...)

As far as I see here this transaction looks quite valid.
Could you help, please?

Python 3.11.4
bitcoinlib 0.6.12

@mccwdev
Copy link
Member

mccwdev commented Oct 23, 2023

This transaction contains a non-standard signature, which Bitcoinlib cannot parse. The signature contains an extra byte and is considered invalid with current standards. See https://github.com/bitcoin/bips/blob/master/bip-0066.mediawiki

You can use the strict=False setting to avoid raising errors and continue parsing the rest of the transaction.

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