1

I can not decode transaction in Bitcoin-QT.

The error is: TX decode failed (code -22). But blockexplorer site decode it.

Then I try to send transaction from blockcypher.com site, and the error is: Error validating transaction: Error running script for input 0 referencing c806c9ae2ac9c71fad307c9fedeca2133edb195cae9e924424885f57a63ba9a9 at 0: Script was NOT verified successfully..

Please help what is wrong. I check transaction structure by hand and check signatures. It's all ok.

I upload signed and unsigned transactions on pastebin.

Unsigned transaction: https://pastebin.com/XfE73U57

Decoded unsigned transaction: https://pastebin.com/RH2tNrNn

Signed transaction: https://pastebin.com/K15c29tK

Decoded signed transaction: https://pastebin.com/Mfs0bXgR

I check signatures and structure of transaction by hand, and they are all correct. Inputs are unspent. So what is the problem? Please help me.

  • when looking at blockchain.com/btc/tx/…, I can see that the transaction's input spent the funds already to other addresses. What do you get with listunspent? – pebwindkraft Jul 22 '18 at 8:46
  • pebwindkraft, I little bit confused about what are you asking for, because the 5 outputs of this transaction are "unspent" – chupacabra Jul 22 '18 at 10:52
  • I thought the error message indicates s.th. with the first transaction and it's input zero. Before going into further analysis of sig and scripts, I wanted to make sure, that this "outpoint 0" really contains funds. However, when I was looking at blockchain.info, I thought I can see, that the funds might have been sent already. So the output of "listunspent | grep -A9 -B1 $tx_id" would have helped to verify current status for the error message... If you like to, you can edit your original question and copy&paste output of the command, or use pastern again. – pebwindkraft Jul 22 '18 at 17:46
  • All inputs of my transaction are the unspend outputs from the one transaction c806c9ae2ac9c71fad307c9fedeca2133edb195cae9e924424885f57a63ba9a9. The outputs of this transaction are unspend (5 outputs). I try to edit my question so to clearify the problem that I really misunderstand. – chupacabra Jul 23 '18 at 11:37
  • @chupacabra something happened? similar error – Alex Muravyov Aug 14 '18 at 17:38
1

Your transaction has 4 extra bytes at the end. Just remove the 01000000 and it should be fine then.

0

I think the unsigned raw transaction is not setup correctly. The unsigned tx has 5 times the pubkey script in the tx_in[0-4] section. It should have only one for each signature. How I understood the system, the way to go is to set all input scripts to nothing, and run through a loop for each of the five inputs, creating 5 separate signatures.

The first loop will have the pubkey script for tx_in[0]. All others remain empty. Then you calculate a valid signature for tx_in[0]. Then in the next loop you again set all to nothing, and only for tx_in1 the pubkey script. And so on... I try to display it this way:

set all scriptSig fields to empty, and length of field to 0
Loop 1
  only tx_in[0] with pubkey script, generate sig[0]
Loop 2
  only tx_in[1] with pubkey script, generate sig[1]
Loop 3
  only tx_in[2] with pubkey script, generate sig[2]
Loop 4
  only tx_in[3] with pubkey script, generate sig[3]
Loop 5
  only tx_in[4] with pubkey script, generate sig[4]

This will give you the signatures, now you place each signature in its scriptsig field, and adopt the length fields accordingly.

I have seen similiar info here and here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.