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

Parsed transaction don't have all the data #281

Open
ravi-ojha opened this issue Dec 22, 2022 · 4 comments
Open

Parsed transaction don't have all the data #281

ravi-ojha opened this issue Dec 22, 2022 · 4 comments

Comments

@ravi-ojha
Copy link

ravi-ojha commented Dec 22, 2022

Example snippet:

from bitcoinlib.services.services import Service

txid = 'cc3afefe30dda8c31cbd39ad19efbdb14a28ac048d28fcf1cfc37c4bc424150b'
s = Service(providers=['bitcoind'], strict=True)

t = s.gettransaction(txid)

It logs the error Malformed script, not enough data found but returns the Transaction object.

This Transaction object has some empty params.

For eg: Notice that the address field is empty in the inputs

{'coinbase': False,
 'inputs': [<Input(prev_txid='b7243353f67cb799db171f21d1e8af045b5ec60babeab22a8bdc3c6813de8946', output_n=0, address='', index_n=0, type='sig_pubkey')>],
 'outputs': [<Output(value=2337, address=bc1qemqrchhnc336m70zm4ryn8jdcrmz596j0msagk5c7tt93wejwvvsz0gja0, type=p2wpkh)>],
 'version': b'\x00\x00\x00\x02',
 'version_int': 2,
 'locktime': 0,
 'network': <Network: bitcoin>,
 'flag': b'\x01',
 'fee': 163,
 'fee_per_kb': 1455,
 'size': 163,
 'vsize': 112,
 'txid': 'cc3afefe30dda8c31cbd39ad19efbdb14a28ac048d28fcf1cfc37c4bc424150b',
 'txhash': '',
 'date': datetime.datetime(2022, 12, 20, 13, 40, 1),
 'confirmations': 2,
 'block_height': 768220,
 'block_hash': '000000000000000000057c5fbaf55b31ed6e3f3c39a00b68e25a1dc9ce77af4a',
 'input_total': 2500,
 'output_total': 2337,
 'rawtx': b'\x02\x00\x00\x00\x00\x01\x01F\x89\xde\x13h<\xdc\x8b*\xb2\xea\xab\x0b\xc6^[\x04\xaf\xe8\xd1!\x1f\x17\xdb\x99\xb7|\xf6S3$\xb7\x00\x00\x00\x00\x00\xff\xff\xff\xff\x01!\t\x00\x00\x00\x00\x00\x00"\x00 \xce\xc0<^\xf3\xc4c\xad\xf9\xe2\xddFI\x9eM\xc0\xf6*\x17R~\xe1\xd4Z\x98\xf2\xd6X\xbb2s\x19\x01A\x11e\x0e\x81\xca\xbd\xbf\xac{g\xc5\xf0[c\xadBt\xdc\xcb\xe0\x9d\xec)\xe9\x989g"\x1c\x0b~+\x1eh\xcb\x101\xba$\x85\xd6\xed\x03\xda\xfa\xd3\x16\x03\xf5\xa5\xd0\xb8[\x19\xb9\xc2\x8f\xc4\xd0_\xfe\x00I9\x01\x00\x00\x00\x00',
 'status': 'confirmed',
 'verified': True,
 'witness_type': 'segwit',
 'change': 0}

I tried leaving a comment on my previously closed issue, but no response, so posting as a new issue. Also, noticed the same behavior on blocksmurfer, so I assume this is known?

@ravi-ojha
Copy link
Author

I understand the library tries to get addresses from witness data, and it's certainly possible for it to fail in some cases. As mentioned here.

For those stumbling upon this in future, as that stackexchange answer suggests, it's not recommended to do this. A better (more reliable) way to get addresses of the inputs being spent is to make another RPC call of txid in vin and get the outputs of that result. A similar approach is taken by the mempool.space team.

@mccwdev
Copy link
Member

mccwdev commented Dec 24, 2022

Good point, I will take a look into it.

@marghidanu
Copy link

I've also bumped into this issue while bulk-exporting the blocks into another format.

@mrx23dot
Copy link

mrx23dot commented Jun 2, 2023

I get the same error, even with .parse(t, strict=False)
"WARNING:bitcoinlib.scripts:Malformed script, not enough data found"
from

msg = "Malformed script, not enough data found"

only after it runs for ~24hrs on all incoming transactions!
Then it gives me this warning for every 2nd-3rd transaction, but still returns the parsed object!
restart my script and works again. Tried on 2 PCs, same thing.
Seems like memory/heap issue in the lib.

If this is intended then why does the warning go away after restarting the app?
I cannot trust the objects returned when this warning pops up from nowhere.

bitcoinlib==0.6.10
Python 3.9.2
debian

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

4 participants