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

CC BY-SA 4.0
2018-11-02T15:13:09.073Z
2018-11-02T15:13:09.073Z
Gigi
<p>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. </p>

<p>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_in<a href="https://bitcoin.stackexchange.com/questions/41209/how-to-sign-a-transaction-with-multiple-inputs">1</a> the pubkey script. And so on... I try to display it this way:</p>

<pre><code>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]
</code></pre>

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

<p>I have seen similiar info <a href="https://bitcoin.stackexchange.com/questions/41209/how-to-sign-a-transaction-with-multiple-inputs">here</a> and <a href="https://bitcoin.stackexchange.com/questions/35877/multisig-vs-multi-input-transaction-signing">here</a>.</p>

CC BY-SA 4.0
2018-07-27T15:20:28.647Z
2018-07-27T15:20:28.647Z
pebwindkraft
<p>I can not decode transaction in Bitcoin-QT.</p>

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

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

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

<p>I upload signed and unsigned transactions on pastebin.</p>

<p>Unsigned transaction: <a href="https://pastebin.com/XfE73U57" rel="nofollow noreferrer">https://pastebin.com/XfE73U57</a></p>

<p>Decoded unsigned transaction: <a href="https://pastebin.com/RH2tNrNn" rel="nofollow noreferrer">https://pastebin.com/RH2tNrNn</a></p>

<p>Signed transaction: <a href="https://pastebin.com/K15c29tK" rel="nofollow noreferrer">https://pastebin.com/K15c29tK</a></p>

<p>Decoded signed transaction: <a href="https://pastebin.com/Mfs0bXgR" rel="nofollow noreferrer">https://pastebin.com/Mfs0bXgR</a></p>

<p>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.</p>

CC BY-SA 4.0
2018-07-22T08:46:07.617Z
when looking at https://www.blockchain.com/btc/tx/c806c9ae2ac9c71fad307c9fedeca2133edb195cae9e924424885f57a63ba9a9?show_adv=true, I can see that the transaction's input spent the funds already to other addresses. What do you get with listunspent?
pebwindkraft
CC BY-SA 4.0
2018-07-22T10:52:10.617Z
pebwindkraft, I little bit confused about what are you asking for, because the 5 outputs of this transaction are "unspent"
chupacabra
CC BY-SA 4.0
2018-07-22T17:46:08.207Z
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
CC BY-SA 4.0
2018-07-23T11:37:51.803Z
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
CC BY-SA 4.0
2018-08-14T17:38:52.160Z
@chupacabra something happened? similar error
Alex Muravyov
<transactions><raw-transaction>
Can not decode transaction. Script was manually verified successfull
chupacabra
# Can not decode transaction. Script was manually verified successfull

(Asked by: username_0 on 2018-07-22)

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.

**Tags:** transactions, raw-transaction

> **Comments:**
> **username_1**: when looking at https://www.blockchain.com/btc/tx/c806c9ae2ac9c71fad307c9fedeca2133edb195cae9e924424885f57a63ba9a9?show_adv=true, I can see that the transaction's input spent the funds already to other addresses. What do you get with listunspent?  
> **username_0**: username_1, I little bit confused about what are you asking for, because the 5 outputs of this transaction are "unspent"  
> **username_1**: 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.  
> **username_0**: 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.  
> **username_2**: @username_0 something happened? similar error  

---

## 2 answers

### Answer by username_3 on 2018-11-02. Score: 1

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


---

### Answer by username_1 on 2018-07-27. Score: 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.


---

