bitcoinlib
bitcoinlib copied to clipboard
Deserialize raw transaction failed
I have deserialzed many raw BTC transactions and run into problems with two of them: rawTx= '01000000016aed58012684f7b55a3d05d276e81608132c97797fe85d500d8f897eec65b0c93f0000005f3c303902153b78ce563f89a0ed9414f5aa28ad0d96d6795f9c630220092a6a9748305458ef2818e9630bc6f78ed501857f207e75b433d0c8d403363f0321023a14330de73064ed3f3099bf88f4fd0436bcd188bdb1299efad737f10234f559ffffffff0100000000000000000000000000' together with deserializedTXs = transaction_deserialize(rawTx , network='bitcoin',check_size = False) gives me " File "/usr/local/lib/python3.6/dist-packages/bitcoinlib/transactions.py", line 111, in transaction_deserialize outputs.append(Output(value=value, lock_script=lock_script, network=network, output_n=n)) File "/usr/local/lib/python3.6/dist-packages/bitcoinlib/transactions.py", line 1057, in init raise TransactionError("Please specify address, lock_script, public key or public key hash when " bitcoinlib.transactions.TransactionError: Please specify address, lock_script, public key or public key hash when creating output"
Another issue was with rawTx = '0100000002af164805ec4f752ec28e75fba4ac36ca3219dd1cb34ab57fdbc3f0f4a1ff9492000000006c473044022033d41eaa7ae75f73c2bd008d395159c55e5708bd74b48cd56c350ffabe26486402206c897f93c71807e5421c6a8e6bcea7646da3688422387f3056aec83448012f30012321020de48afd32e682f3bcf42b4c3eb9120a4af34d8a4d5ec19bc8fc241b8fd40263acfdffffffd801bfbe0d7105970dde0a137a2c3d79f13e45880020cea5d3ad8712f7c143f1080000008b48304502210096717bd9a5bf6c4e9bfe833647abb73338d21e81a92ed3ef7dbaa413368e35c0022071011b5e1158d3581517e9eb0c5daaee8d1541ee6e3ca7c202191feb0b803d2f014104cf9c4b56815183cb9d609400bdbee42995270c884f9dea5ce55b90713a1499dceb4d9eba5241545efc416c1d35ee3dd6c2e009430dce19951b7c626f8640a67cfdffffff01c02709000000000017a914c5a1dbed707d2a5648f51440596226967ae27445874ce10900' raising the errors File "/usr/local/lib/python3.6/dist-packages/bitcoinlib/transactions.py", line 96, in transaction_deserialize witness_type=inp_type, sequence=sequence_number, index_n=n, network=network)) File "/usr/local/lib/python3.6/dist-packages/bitcoinlib/transactions.py", line 815, in init kobj = Key(key, network=network) File "/usr/local/lib/python3.6/dist-packages/bitcoinlib/keys.py", line 721, in init kf = get_key_format(import_key) File "/usr/local/lib/python3.6/dist-packages/bitcoinlib/keys.py", line 220, in get_key_format raise BKeyError("Unrecognised key format") bitcoinlib.keys.BKeyError: Unrecognised key format
When importing a raw transaction bitcoinlib parses all scripts and keys. Which may cause an error when a non-standard script is encountered. The first transaction has an output with an empty script and the second transaction seems to have a non-standard input.
It would be handy if bitcoinlib had an option to disable parsing all scripts when importing transactions and it should handle non-standard scripts better. So I add the enhancement tag and hope to address this in the next release.
Thank you, mccwdev!
I would like to tell you that the bitcoinlib is great. For python, it is really the best around.
Thank you!
Doing some statistical analysis on blocks, I found exactly the same issue: a few of them fail to parse their transactions and raise bitcoinlib.keys.BKeyError: Unrecognised key format.
Nevertheless bitcoinlib is turning out really useful, I do not know how could I have managed this task without it. Thank you!!
Use the strict=False option to parse transactions with unsupported scripts