<p>Good day. You shoud have list of unspent outputs, for adding them into inputs of your tx. Also you should generate private keys and use special privKey for every input you have.</p>

<p>Try it out:</p>

<pre><code>TransactionOutPoint outPoint = new TransactionOutPoint(params, utxo.getIndex(), utxo.getHash());
byte[] privKeyBytes = HEX.decode(privKeyAsHex);
ECKey ecKey = ECKey.fromPrivate(privKeyBytes);

transaction.addSignedInput(outPoint, utxo.getScript(), ecKey, Transaction.SigHash.ALL, true);
</code></pre>

CC BY-SA 3.0
2017-11-14T16:53:54.537Z
2017-11-14T16:53:54.537Z
Timur Panzhiev
<p>Start by creating a Java project and adding the BitcoinJ library to your project's dependencies. You can download the BitcoinJ library from the official GitHub repository or use a build tool like Maven or Gradle to include it in your project</p>

CC BY-SA 4.0
2023-09-11T05:40:53.150Z
2023-09-11T05:40:53.150Z
Carlos Benini
<p>I am having problem signing the transaction using BitcoinJ library without the Wallet instance, I only have the Transaction class instance and the ECKey in order to sign the transaction.</p>

<p>Is there a way to implement it ? </p>

<transactions><raw-transaction><bitcoinj><android><java>
How to sign a transaction using BitcoinJ
Firass Obaid
# How to sign a transaction using BitcoinJ

(Asked by: username_0 on 2015-04-29)

I am having problem signing the transaction using BitcoinJ library without the Wallet instance, I only have the Transaction class instance and the ECKey in order to sign the transaction.

Is there a way to implement it ?

**Tags:** transactions, raw-transaction, bitcoinj, android, java


---

## 2 answers

### Answer by username_1 on 2017-11-14. Score: 0

Good day. You shoud have list of unspent outputs, for adding them into inputs of your tx. Also you should generate private keys and use special privKey for every input you have.

Try it out:

```
TransactionOutPoint outPoint = new TransactionOutPoint(params, utxo.getIndex(), utxo.getHash());
byte[] privKeyBytes = HEX.decode(privKeyAsHex);
ECKey ecKey = ECKey.fromPrivate(privKeyBytes);

transaction.addSignedInput(outPoint, utxo.getScript(), ecKey, Transaction.SigHash.ALL, true);

```


---

### Answer by username_2 on 2023-09-11. Score: -3

Start by creating a Java project and adding the BitcoinJ library to your project's dependencies. You can download the BitcoinJ library from the official GitHub repository or use a build tool like Maven or Gradle to include it in your project


---

