<blockquote>
  <p>which private key use to Sign this transaction? </p>
</blockquote>

<p>When you have a transaction with multiple inputs, each input must be signed. The general format for a transaction is:</p>

<h2>Transaction</h2>

<p><code>{version}</code> <code>{flag (optional)}</code> <code>{input counter}</code> <code>{inputs}</code> <code>{output counter}</code> <code>{outputs}</code> <code>{witnesses (optional)}</code> <code>{lock time}</code></p>

<ul>
<li><code>version</code> (4 Bytes) - Transaction format version</li>
<li><code>flag</code> (2 Byte Array) - Optional flag, if present, must be 0001, which indicates there is witness data in this transaction</li>
<li><code>input counter</code> (Variable Length) - Number of inputs in the transaction represented by a Variable Length Integer.</li>
<li><code>inputs</code> (based on Input Counter) - List of all transaction inputs which will be spent and which reference unspent transaction outputs from previous transactions.</li>
<li><code>output counter</code> (Variable Length) - Number of outputs in the transaction represented by a Variable Length Integer.</li>
<li><code>outputs</code> (based on Output Counter) - List of all transaction outputs where the coins will be sent and which will become unspent transaction outputs to be spent in future transactions.</li>
<li><code>witnesses</code> (variable) - Optional list of all witnesses only if Flag is present, which are used in transaction validation according to specifications for <a href="https://en.bitcoin.it/wiki/Segregated_Witness" rel="nofollow noreferrer">Segregated Witness</a>.</li>
<li><code>locktime</code> (4 Bytes) - If non-zero and sequence numbers are &lt; <code>ffffffff</code>: it represents either the block height or timestamp when transaction is final.</li>
</ul>

<h2>Inputs</h2>

<p>And the general format for each input is:</p>

<p><code>{previous tx hash}</code> <code>{previous utxo index}</code> <code>{scriptSig length}</code> <code>{scriptSig}</code> <code>{sequence number}</code></p>

<ul>
<li><code>previous tx hash</code> (32 Bytes) - Hash of the previous transaction. This is used to lookup the transaction in order to validate that this input can be spent.</li>
<li><code>previous utxo index</code> (4 Bytes) - Previous Unspent Transaction Output (UTXO) index. Since transactions can have multiple outputs, in order to specify which output, you can provide a zero-based index.</li>
<li><code>scriptSig length</code> (Variable Length) - Length in bytes of the scriptSig.</li>
<li><code>scriptSig</code> (based on <code>scriptSig length</code>)- The first part of the script that is executed before the scriptPubKey from the UTXO. When they are both executed in order, the result must be true in order to be considered a valid spend.</li>
<li><code>sequence number</code> (4 Bytes) - Used as a relative lock time if transaction version is >= 2. See <a href="https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki" rel="nofollow noreferrer">BIP68</a>.</li>
</ul>

<p>You can see that each input requires a <code>scriptSig</code>, which is where the signature is (unless it is a segwit tx, then it is in the <code>witnesses</code> field in the transaction above)</p>

CC BY-SA 4.0
2019-02-13T18:32:44.940Z
2019-02-13T18:32:44.940Z
JBaczuk
<p>I want to spend 1 bitcoin, And I can reach this amount with 3 inputs.</p>

<p>for example:</p>

<p>1 input = 0.5 btc
PB mypubkey_1
PK mypkkey_1</p>

<p>2 input = 0.4 btc
PB mypubkey_2
PK mypkkey_2</p>

<p>3 input = 0.15 btc
PB mypubkey_3
PK mypkkey_3</p>

<p>which private key use to Sign this transaction? </p>

<p>I will use mypkkey_1,mypkkey_2,mypkkey_3 or parent private key or something like that?</p>

<transactions>
Create Output with a bunch of input
monkeyUser
# Create Output with a bunch of input

(Asked by: username_0 on 2019-02-13)

I want to spend 1 bitcoin, And I can reach this amount with 3 inputs.

for example:

1 input = 0.5 btc
PB mypubkey\_1
PK mypkkey\_1

2 input = 0.4 btc
PB mypubkey\_2
PK mypkkey\_2

3 input = 0.15 btc
PB mypubkey\_3
PK mypkkey\_3

which private key use to Sign this transaction?

I will use mypkkey\_1,mypkkey\_2,mypkkey\_3 or parent private key or something like that?

**Tags:** transactions


---

## 1 answers

### Answer by username_1 on 2019-02-13. Score: 1 | Accepted answer

> which private key use to Sign this transaction?

When you have a transaction with multiple inputs, each input must be signed. The general format for a transaction is:

## Transaction

`{version}` `{flag (optional)}` `{input counter}` `{inputs}` `{output counter}` `{outputs}` `{witnesses (optional)}` `{lock time}`

* `version` (4 Bytes) - Transaction format version
* `flag` (2 Byte Array) - Optional flag, if present, must be 0001, which indicates there is witness data in this transaction
* `input counter` (Variable Length) - Number of inputs in the transaction represented by a Variable Length Integer.
* `inputs` (based on Input Counter) - List of all transaction inputs which will be spent and which reference unspent transaction outputs from previous transactions.
* `output counter` (Variable Length) - Number of outputs in the transaction represented by a Variable Length Integer.
* `outputs` (based on Output Counter) - List of all transaction outputs where the coins will be sent and which will become unspent transaction outputs to be spent in future transactions.
* `witnesses` (variable) - Optional list of all witnesses only if Flag is present, which are used in transaction validation according to specifications for [Segregated Witness](https://en.bitcoin.it/wiki/Segregated_Witness).
* `locktime` (4 Bytes) - If non-zero and sequence numbers are < `ffffffff`: it represents either the block height or timestamp when transaction is final.

## Inputs

And the general format for each input is:

`{previous tx hash}` `{previous utxo index}` `{scriptSig length}` `{scriptSig}` `{sequence number}`

* `previous tx hash` (32 Bytes) - Hash of the previous transaction. This is used to lookup the transaction in order to validate that this input can be spent.
* `previous utxo index` (4 Bytes) - Previous Unspent Transaction Output (UTXO) index. Since transactions can have multiple outputs, in order to specify which output, you can provide a zero-based index.
* `scriptSig length` (Variable Length) - Length in bytes of the scriptSig.
* `scriptSig` (based on `scriptSig length`)- The first part of the script that is executed before the scriptPubKey from the UTXO. When they are both executed in order, the result must be true in order to be considered a valid spend.
* `sequence number` (4 Bytes) - Used as a relative lock time if transaction version is >= 2. See [BIP68](https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki).

You can see that each input requires a `scriptSig`, which is where the signature is (unless it is a segwit tx, then it is in the `witnesses` field in the transaction above)


---

