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

Error parsing bitcoin testnet transaction #365

Closed bit0t closed 7 months ago

bit0t commented 8 months ago

the library (v. 0.6.12) throws the following error while parsing the following raw transaction:

Traceback (most recent call last): File "XXXX", line 577, in _fetch_tx_coro parsed_resp = Transaction.parse_hex(resp, network=self.network, strict=False) File "/venv/lib/python3.10/site-packages/bitcoinlib/transactions.py", line 1545, in parse_hex return cls.parse_bytesio(BytesIO(bytes.fromhex(rawtx)), strict, network) File "/venv/lib/python3.10/site-packages/bitcoinlib/transactions.py", line 1501, in parse_bytesio if script.script_types[0][:13] == 'p2sh_multisig' or script.script_types[0] =='signature_multisig': IndexError: list index out of range

Transaction:

https://mempool.space/testnet/tx/b7f6c5c3c4261d319d6161f88fff7c247b89d44395e6ee5c79cc091557cd49c2

mccwdev commented 7 months ago

The last input of the transaction contains an witness script with an incorrect size. However this shouldn't lead to errors when using strict=False. Fixed in commit https://github.com/1200wd/bitcoinlib/commit/1454d578765bfa684491a7d90b42448706c29895