<p>The problem was that I tried to sign inputs and add outputs and other info into transaction.
The last result hexRawTx :</p>

<blockquote>
  <p>01000000019843f83b2c42de1585cdc3b689a10a2960d016d5887f1ecd50bc8e040bbe94cc000000006b483045022100f9559234c189df36b99ffea94ecec650c1a483cdc02a976759d4bd7347a82ca9022009278f760db1dabf666ea0fcab55b8a1c6f20b27f8b442738b1d51165d91fd3e8121027e912293da7fecdffe57a49a726649d547a6b0fb2a5420047515d6373d251296ffffffff02102700000000000017a914e211863c0e582b5df44f6e1aa0eef0eb9ddcc9078760590100000000001976a914ad7252447111e2300c77aa406339b4e38d08cf4988ac00000000</p>
</blockquote>

<p>Detect this tx, the fee is always zero, and input without address(<a href="https://live.blockcypher.com/btc/decodetx/" rel="nofollow noreferrer">https://live.blockcypher.com/btc/decodetx/</a>)</p>

<pre><code> transaction.addOutput(coin , Address.fromBase58(MainNetParams.get(),toAddress));
transaction.addOutput(coinInput,Address.fromBase58(MainNetParams.get(),fromAddress));
for(int k=0;k&lt;unSpentNum;k++){
TransactionInput transactionInput=new TransactionInput(MainNetParams.get(), 
         transaction,newBigInteger(unSpent.get(k).getScript(),16).toByteArray(),
                   new TransactionOutPoint(MainNetParams.get(), 0, Sha256Hash.wrap(unSpent.get(k).getTx_hash())));
           transaction.addInput(transactionInput);

}
String hexRawTx = SignTool.verifyAndSignTransaction(transaction, 0, ecKey, null, false,MainNetParams.get());
</code></pre>

<p>(unSpentNum) get from <a href="https://blockchain.info/unspent?active=3D2oetdNuZUqQHPJmcMDDHYoqkyNVsFk9r" rel="nofollow noreferrer">https://blockchain.info/unspent?active=3D2oetdNuZUqQHPJmcMDDHYoqkyNVsFk9r</a></p>

CC BY-SA 4.0
2018-09-21T12:05:49.023Z
Which output are you trying to spend? I can't find txid `cc94be0b048ebc50cd1e7f88d516d060290aa189b6c3cd8515de422c3bf84398` on a block explorer
Mike D
CC BY-SA 4.0
2018-09-25T02:19:04.093Z
Thank you for your help，I am spending the second here. fromAddress:1Gp6rNgRjUVFuoC6dZvvpUaCidfzJEVbAW ,  toAddress: 3NJMdWarysk9woSUkzAV18AapbxsA4qd7p ,   Does the problem occur in the  transaction.addInput() ？
blueberry082
CC BY-SA 4.0
2018-09-25T02:48:04.243Z
https://blockchain.info/unspent?active=1Gp6rNgRjUVFuoC6dZvvpUaCidfzJEVbAW
blueberry082
CC BY-SA 4.0
2018-09-25T07:15:52.910Z
The problem has been solved, the parameter problem
blueberry082
<transactions>
Can't sign a transaction correctly
blueberry082
# Can't sign a transaction correctly

(Asked by: username_0 on 2018-09-21)

The problem was that I tried to sign inputs and add outputs and other info into transaction.
The last result hexRawTx :

01000000019843f83b2c42de1585cdc3b689a10a2960d016d5887f1ecd50bc8e040bbe94cc000000006b483045022100f9559234c189df36b99ffea94ecec650c1a483cdc02a976759d4bd7347a82ca9022009278f760db1dabf666ea0fcab55b8a1c6f20b27f8b442738b1d51165d91fd3e8121027e912293da7fecdffe57a49a726649d547a6b0fb2a5420047515d6373d251296ffffffff02102700000000000017a914e211863c0e582b5df44f6e1aa0eef0eb9ddcc9078760590100000000001976a914ad7252447111e2300c77aa406339b4e38d08cf4988ac00000000

Detect this tx, the fee is always zero, and input without address(https://live.blockcypher.com/btc/decodetx/)
 transaction.addOutput(coin , Address.fromBase58(MainNetParams.get(),toAddress));
transaction.addOutput(coinInput,Address.fromBase58(MainNetParams.get(),fromAddress));
for(int k=0;k
(unSpentNum) get from https://blockchain.info/unspent?active=3D2oetdNuZUqQHPJmcMDDHYoqkyNVsFk9r

**Tags:** transactions

> **Comments:**
> **username_1**: Which output are you trying to spend? I can't find txid `cc94be0b048ebc50cd1e7f88d516d060290aa189b6c3cd8515de422c3bf84398` on a block explorer  
> **username_0**: Thank you for your help，I am spending the second here. fromAddress:1Gp6rNgRjUVFuoC6dZvvpUaCidfzJEVbAW ,  toAddress: 3NJMdWarysk9woSUkzAV18AapbxsA4qd7p ,   Does the problem occur in the  transaction.addInput() ？  
> **username_0**: https://blockchain.info/unspent?active=1Gp6rNgRjUVFuoC6dZvvpUaCidfzJEVbAW  
> **username_0**: The problem has been solved, the parameter problem  

---

## 0 answers

