<blockquote>
  <p>Do i need to sign each input in a raw transaction?</p>
</blockquote>

<p>Technically, yes. But software like Bitcoin Core Client signs all inputs where the private keys are known. And of course, leave unsigned/untouched all other inputs.</p>

CC BY-SA 3.0
2017-12-01T11:40:13.923Z
2017-12-01T11:40:13.923Z
amaclin
<p>You can just use</p>

<pre><code>bitcoin-cli signrawtransaction RAW_TX
</code></pre>

<p>if the private keys of all inputs of that transaction are in your Bitcoin Core (or bitcoind).</p>

CC BY-SA 3.0
2018-01-04T22:56:16.293Z
And what if the keys are not imported (but known anyway)? How should it be added as a argument? a list with each key, all in the same order as the outputs ?
Alex
CC BY-SA 3.0
2018-01-05T04:20:07.557Z
@FeedTheWeb Do this for each key: importprivkey PRIVKEY "" false Don't forget to type false, and.the order doesn't matter. If this doesn't work, do a rescan after adding each key (but probably it won't be needed.) If you have lots of keys, I may write you a little piece of code that reads the PrivKeys from a file and imports them.
MCCCS
CC BY-SA 3.0
2018-01-05T11:40:15.237Z
And if I don't want to import/rescan (because it takes forever), the syntax should be `bitcoin-cli signrawtransaction RAW_TX [] ["PRIVKEY1", "PRIVKEY2"]` , right?
Alex
CC BY-SA 3.0
2018-01-05T12:35:24.983Z
@FeedTheWeb No, `importprivkey PRIVKEY "" false` won't rescan, because the last argument is `rescan?`, `false`. And you're right, you don't need to importprivkey, your command is correct.
MCCCS
CC BY-SA 3.0
2017-12-01T11:40:31.503Z
2017-12-01T11:40:31.503Z
MCCCS
<p>I've been reading up about raw transactions on <a href="https://bitcoin.org/en/developer-examples#simple-raw-transaction" rel="nofollow noreferrer">bitcoin.org</a> and there are two examples <a href="https://bitcoin.org/en/developer-examples#simple-raw-transaction" rel="nofollow noreferrer">Simple</a> and <a href="https://bitcoin.org/en/developer-examples#complex-raw-transaction" rel="nofollow noreferrer">Complex</a>.</p>

<p>What I can't tell from the information provided is if it necessary to sign each of the inputs separately, or whether you can just sign the entire tx with one.</p>

<p>So two examples:</p>

<ol>
<li>Input 1 came from address A and input 2 came from address A.</li>
<li>Input 1 came from address B and input 2 came from address C.</li>
</ol>

<p>For example 1, my assumption is that I could just use</p>

<pre><code>bitcoin-cli signrawtransaction RAW_TX
</code></pre>

<p>but for example 2 I would have to use</p>

<pre><code> bitcoin-cli signrawtransaction RAW_TX [] ["ADDR_B_PRIVATE_KEY"]
 bitcoin-cli signrawtransaction PARTLY_SIGNED_RAW_TX [] ["$ADDR_B_PRIVATE_KEY"]
</code></pre>

CC BY-SA 3.0
2017-12-01T15:09:11.930Z
next to the answers below, this is at the tx level itself, if not using a wallet: https://bitcoin.stackexchange.com/questions/41209/how-to-sign-a-transaction-with-multiple-inputs?rq=1
pebwindkraft
<transaction-input><signrawtransaction>
Do i need to sign each input in a raw transaction?
Ne0
# Do i need to sign each input in a raw transaction?

(Asked by: username_0 on 2017-12-01)

I've been reading up about raw transactions on bitcoin.org and there are two examples Simple and Complex.
What I can't tell from the information provided is if it necessary to sign each of the inputs separately, or whether you can just sign the entire tx with one.
So two examples:

Input 1 came from address A and input 2 came from address A.
Input 1 came from address B and input 2 came from address C.

For example 1, my assumption is that I could just use
bitcoin-cli signrawtransaction RAW_TX

but for example 2 I would have to use
 bitcoin-cli signrawtransaction RAW_TX [] ["ADDR_B_PRIVATE_KEY"]
 bitcoin-cli signrawtransaction PARTLY_SIGNED_RAW_TX [] ["$ADDR_B_PRIVATE_KEY"]

**Tags:** transaction-input, signrawtransaction

> **Comments:**
> **username_1**: next to the answers below, this is at the tx level itself, if not using a wallet: https://bitcoin.stackexchange.com/questions/41209/how-to-sign-a-transaction-with-multiple-inputs?rq=1  

---

## 2 answers

### Answer by username_2 on 2017-12-01. Score: 2

> Do i need to sign each input in a raw transaction?

Technically, yes. But software like Bitcoin Core Client signs all inputs where the private keys are known. And of course, leave unsigned/untouched all other inputs.


---

### Answer by username_3 on 2017-12-01. Score: 1

You can just use
bitcoin-cli signrawtransaction RAW_TX

if the private keys of all inputs of that transaction are in your Bitcoin Core (or bitcoind).

> **Comments:**
> **username_4**: And what if the keys are not imported (but known anyway)? How should it be added as a argument? a list with each key, all in the same order as the outputs ?  
> **username_3**: @FeedTheWeb Do this for each key: importprivkey PRIVKEY "" false Don't forget to type false, and.the order doesn't matter. If this doesn't work, do a rescan after adding each key (but probably it won't be needed.) If you have lots of keys, I may write you a little piece of code that reads the PrivKeys from a file and imports them.  
> **username_4**: And if I don't want to import/rescan (because it takes forever), the syntax should be `bitcoin-cli signrawtransaction RAW_TX [] ["PRIVKEY1", "PRIVKEY2"]` , right?  
> **username_3**: @FeedTheWeb No, `importprivkey PRIVKEY "" false` won't rescan, because the last argument is `rescan?`, `false`. And you're right, you don't need to importprivkey, your command is correct.  

---

