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.

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?
– pebwindkraftJul 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"
– chupacabraJul 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.
– pebwindkraftJul 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.
– chupacabraJul 23 '18 at 11:37

2 Answers
2

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: