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

"errno.WITNESS_UNEXPECTED" error while trying to get signatures #367

Open
yakitorifoodie opened this issue May 16, 2020 · 3 comments
Open

Comments

@yakitorifoodie
Copy link

This issue persists if a segwit or a transaction with more than one inputs were given.

Log:

vb@h2o:~# tx -s 0100000000010285325215f4daedad07839c16648ad631fc654d3c40cd287f3437c3dcde3c90340000000000ffffffff02e783a09ca7de9824151fa6699a31c6fef1fd979f68ef4f1149f5e4629e402d000000006b483045022100917eef11069fcf2be24dd55c29bb9d5e30b10eeb812be1024a5a404d80d7a51c0220293952a6d8b80c2db98e2575ddd00a591115161e33853652fde5cbc58e4488c40121023614b4175b150d36c6058bff2dcc4e26c244c848785387482d57b31ab60818cfffffffff018e5812000000000017a9143ffa057b31d280f5034b66af6ca0824b9a98aed5870247304402204748ea5502f7561eed5494b95f0545ae4b05ed40d32f5169d6385df0a1ea54e6022052fe070b165d7cde86aba2d7ca72996d10ba9d304521088b34015bcd59c8bec001210364f57caa72b31e1cbfd12f92b2b281407b4914b2e7e0b9cb7b3cd9bb9a7bbf0c0000000000 Traceback (most recent call last): File "/usr/local/bin/tx", line 11, in <module> load_entry_point('pycoin==0.0.0', 'console_scripts', 'tx')() File "/usr/local/lib/python3.6/dist-packages/pycoin-0.0.0-py3.6.egg/pycoin/cmds/tx.py", line 710, in main tx(args, parser) File "/usr/local/lib/python3.6/dist-packages/pycoin-0.0.0-py3.6.egg/pycoin/cmds/tx.py", line 686, in tx args.verbose_signature, args.disassemble, args.trace, args.pdb) File "/usr/local/lib/python3.6/dist-packages/pycoin-0.0.0-py3.6.egg/pycoin/cmds/tx.py", line 569, in print_output dump_tx(output, tx, network, verbose_signature, disassembly_level, trace, pdb) File "/usr/local/lib/python3.6/dist-packages/pycoin-0.0.0-py3.6.egg/pycoin/cmds/dump.py", line 120, in dump_tx dump_inputs(output, tx, network, verbose_signature, traceback_f, disassembly_level) File "/usr/local/lib/python3.6/dist-packages/pycoin-0.0.0-py3.6.egg/pycoin/cmds/dump.py", line 72, in dump_inputs dump_signatures(output, tx, tx_in, tx_out, idx, network, traceback_f) File "/usr/local/lib/python3.6/dist-packages/pycoin-0.0.0-py3.6.egg/pycoin/cmds/dump.py", line 88, in dump_signatures signatures = [parse_signature_blob(blob) for blob, sig_hash in network.who_signed.extract_signatures(tx, idx)] File "/usr/local/lib/python3.6/dist-packages/pycoin-0.0.0-py3.6.egg/pycoin/cmds/dump.py", line 88, in <listcomp> signatures = [parse_signature_blob(blob) for blob, sig_hash in network.who_signed.extract_signatures(tx, idx)] File "/usr/local/lib/python3.6/dist-packages/pycoin-0.0.0-py3.6.egg/pycoin/contrib/who_signed.py", line 33, in extract_signatures for puzzle_script, solution_stack, flags, sighash_f in sc.puzzle_and_solution_iterator(tx_context): File "/usr/local/lib/python3.6/dist-packages/pycoin-0.0.0-py3.6.egg/pycoin/coins/bitcoin/SolutionChecker.py", line 215, in puzzle_and_solution_iterator witness_tuple = self.witness_program_tuple(tx_context, puzzle_script, solution_stack, flags, is_p2sh) File "/usr/local/lib/python3.6/dist-packages/pycoin-0.0.0-py3.6.egg/pycoin/coins/bitcoin/SegwitChecker.py", line 144, in witness_program_tuple raise ScriptError("witness unexpected", errno.WITNESS_UNEXPECTED) pycoin.coins.SolutionChecker.ScriptError: ('witness unexpected', 39)

@richardkiss
Copy link
Owner

richardkiss commented May 17, 2020

There is definitely a bug here, but I'm not sure exactly what it is. You can work around it by adding -a, which will fetch the source transaction from block explorers (see the README for PYCOIN_BTC_PROVIDERS). Example:

% tx -a -s 0100000000010285325215f4daedad07839c16648ad631fc654d3c40cd287f3437c3dcde3c90340000000000ffffffff02e783a09ca7de9824151fa6699a31c6fef1fd979f68ef4f1149f5e4629e402d000000006b483045022100917eef11069fcf2be24dd55c29bb9d5e30b10eeb812be1024a5a404d80d7a51c0220293952a6d8b80c2db98e2575ddd00a591115161e33853652fde5cbc58e4488c40121023614b4175b150d36c6058bff2dcc4e26c244c848785387482d57b31ab60818cfffffffff018e5812000000000017a9143ffa057b31d280f5034b66af6ca0824b9a98aed5870247304402204748ea5502f7561eed5494b95f0545ae4b05ed40d32f5169d6385df0a1ea54e6022052fe070b165d7cde86aba2d7ca72996d10ba9d304521088b34015bcd59c8bec001210364f57caa72b31e1cbfd12f92b2b281407b4914b2e7e0b9cb7b3cd9bb9a7bbf0c0000000000
warning: transaction fees recommendations casually calculated and estimates may be incorrect
warning: transaction fee lower than (casually calculated) expected value of 0.10000 mBTC, transaction might not propogate
Version:  1  tx hash 05f5f11bda9fbef31a6be64a50e5f27f31dcd132c524f3bbc95121d61c763ea6  341 bytes
      segwit tx hash d5a8a5556071abcc149afa1a1038d09f6c44aecbc4741bfa77edaa087a71dda7
TxIn count: 2; TxOut count: 1
Lock time: 0 (valid anytime)
Inputs:
   0: bc1qsezkmvg63r8w9s6c3mmr9tf9cm5s4mx7tkdagt from 34903cdedcc337347f28cd403c4d65fc31d68a64169c8307adeddaf415523285:0         1.37200 mBTC  sig ok
      r: 0x4748ea5502f7561eed5494b95f0545ae4b05ed40d32f5169d6385df0a1ea54e6
      s: 0x52fe070b165d7cde86aba2d7ca72996d10ba9d304521088b34015bcd59c8bec0
      z: 0xd0dba1caf3f40d30019f358bd7a1cc0d715c7d03b2451cb44d8390d67240a668 SIGHASH_ALL
   1: 1Fmma8inqay1y7CLibp6FcBFxNnVbkLDSf from 2d409e62e4f549114fef689f97fdf1fec6319a69a61f152498dea79ca083e702:0        10.70018 mBTC  sig ok
      r: 0x917eef11069fcf2be24dd55c29bb9d5e30b10eeb812be1024a5a404d80d7a51c
      s: 0x293952a6d8b80c2db98e2575ddd00a591115161e33853652fde5cbc58e4488c4
      z: 0xd09537d881d2058def18c2ab6f291e0be27adbe1fb3c7f4f0f0aa03ec9f7307a SIGHASH_ALL
Output:
   0: 37XJ1RPN9q7T9yxbbcH5eq2c6rqLxqsHbD receives     12.02318 mBTC
Total input      12.07218 mBTC
Total output     12.02318 mBTC
Total fees        0.04900 mBTC
0100000000010285325215f4daedad07839c16648ad631fc654d3c40cd287f3437c3dcde3c90340000000000ffffffff02e783a09ca7de9824151fa6699a31c6fef1fd979f68ef4f1149f5e4629e402d000000006b483045022100917eef11069fcf2be24dd55c29bb9d5e30b10eeb812be1024a5a404d80d7a51c0220293952a6d8b80c2db98e2575ddd00a591115161e33853652fde5cbc58e4488c40121023614b4175b150d36c6058bff2dcc4e26c244c848785387482d57b31ab60818cfffffffff018e5812000000000017a9143ffa057b31d280f5034b66af6ca0824b9a98aed5870247304402204748ea5502f7561eed5494b95f0545ae4b05ed40d32f5169d6385df0a1ea54e6022052fe070b165d7cde86aba2d7ca72996d10ba9d304521088b34015bcd59c8bec001210364f57caa72b31e1cbfd12f92b2b281407b4914b2e7e0b9cb7b3cd9bb9a7bbf0c0000000000
all incoming transaction values validated

(There is a known bug affecting segwit that means the z-values above are probably incorrect.)

@yakitorifoodie
Copy link
Author

thank you very much for addressing the issue.

@richardkiss
Copy link
Owner

richardkiss commented May 18, 2020

I'm going to reopen as a reminder to improve this error case.

@richardkiss richardkiss reopened this May 18, 2020
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