<blockquote>
  <p>It looks to me like each input to a bitcoin transaction has an index that specifies only one output from the input its spending.</p>
</blockquote>

<p>That is correct.</p>

<blockquote>
  <p>Is there a way to specify more than one output index, or do you have to create a second input line that contains the same input ID with a different index?</p>
</blockquote>

<p>You have to add an extra input, which repeats the txid.</p>

<blockquote>
  <p>It seems like that second way is wasteful of blockchain space - I would have thought there would be a way to simply specify multiple indexes.</p>
</blockquote>

<p>It is wasteful, but only slightly. In your hypothetical system, you still need a signature/scriptSig/witness for each of the coins being spent (unless you also want to incentivize key reuse), which are generally larger than a repetition of a txid.</p>

<blockquote>
  <p>Is there a way to do that?</p>
</blockquote>

<p>No.</p>

CC BY-SA 3.0
2018-04-17T22:54:41.827Z
2018-04-17T22:54:41.827Z
Pieter Wuille
<blockquote>
  <p>Can you specify more than one output index in a transaction's input?</p>
</blockquote>

<p>yes. Transactions consists of structures, including a list of inputs (V_IN) and a list of outputs (V_OUT). 
You can have several V_INs, and several V_OUTs. A similar question <a href="https://bitcoin.stackexchange.com/questions/74003/multiple-input-and-output-addresses-in-bitcoin-transactions/74012#74012">is here</a>. </p>

<blockquote>
  <p>Is there a way to specify more than one output, or do you have to
  create a second input line that contains the same input ID with a
  different index?</p>
</blockquote>

<p>Not sure what is meant by lines... In a tx the data is structured, and an  output is defined by the list of outputs (V_OUT, <a href="https://en.bitcoin.it/wiki/Transaction" rel="nofollow noreferrer">link to the wiki</a>). It is possible to create a transaction with one input, and have many outputs. One can create these transactions manually, or also use the bitcoin core client, with the API call "createrawtransaction". The parameters are: [{"txid":txid,"vout":n},...] {address:amount,...} - one can provide several addresses with the amounts. 
For example faucets sending mini amounts of BTC assemble such transactions, to save on the fees. And so one transaction may have a single input, and 100s of outputs. </p>

<p>=== <strong>update 18 April 2018</strong>, based on comments below ===</p>

<p>I think I see what is meant. Assuming, a given tx has two outputs, with 4 values of 0.25 BTC. All shall be spent in a single transaction, with a single tx_in structure, along this idea:</p>

<pre><code>...
  tx_in[0] OutPoint hash   (previous tx hash)
   tx_in[0] OutPoint_index[0] (previous tx' outpoint index --&gt; 0.25 BTC)
   tx_in[0] OutPoint_index[1] 
   tx_in[0] OutPoint_index[2] 
   tx_in[0] OutPoint_index[3] 
  tx_in[0] Script Length   (length for the following signature script)
  tx_in[0] Script Sig      (the signature script)
  tx_in[0] Sequence        (usually set to FFFFFFFF)
...
</code></pre>

<p>This would make the transaction short, and reduce amount of space used in the blockchain and redu
ce fees. As Pieter replied already, it is not possible. The current definition of the transaction structure does not allow for such a variation. <a href="https://bitcoin.org/en/developer-reference#raw-transaction-format" rel="nofollow noreferrer">The specification</a> defines a single Outpoint Index per tx_in. So to use several outputs from a previous tx, one would have to create equivalent amount of tx_in structures, each referencing a single Output Index (and tx hash, and adding script length, sigcscript and sequence).</p>

CC BY-SA 3.0
2018-04-17T22:46:32.733Z
What I meant is: is there a way to specify two output indexes for a given output? I know you can add multiple outputs, but lets say you want to use all the ouputs from a given transaction. Could you, in that case, say something to the effect of "use output index 1, 2, 3, 4, and 5 from transaction X" or do you have to say "use output index 1 from transaction X, and use output index 2 from transaction X, ..." etc?
B T
CC BY-SA 3.0
2018-04-17T22:47:36.410Z
I believe OP is asking about a way to spend multiple outputs *from the same txid* in a way that is more efficient than creating an extra input and repeating the txid.
Pieter Wuille
CC BY-SA 3.0
2018-04-16T10:30:12.317Z
2018-04-18T07:07:44.267Z
2018-04-18T07:07:44.267Z
pebwindkraft
<p>It <a href="https://en.bitcoin.it/wiki/Transaction#general_format_.28inside_a_block.29_of_each_input_of_a_transaction_-_Txin" rel="nofollow noreferrer">looks to me</a> like each input to a bitcoin transaction has an index that specifies only one output from the input its spending. Is there a way to specify more than one output index, or do you have to create a second input line that contains the same input ID with a different index? It seems like that second way is wasteful of blockchain space - I would have thought there would be a way to simply specify multiple indexes. Is there a way to do that? </p>

<transaction-input>
Can you specify more than one output index in a transaction's input?
B T
# Can you specify more than one output index in a transaction's input?

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

It [looks to me](https://en.bitcoin.it/wiki/Transaction#general_format_.28inside_a_block.29_of_each_input_of_a_transaction_-_Txin) like each input to a bitcoin transaction has an index that specifies only one output from the input its spending. Is there a way to specify more than one output index, or do you have to create a second input line that contains the same input ID with a different index? It seems like that second way is wasteful of blockchain space - I would have thought there would be a way to simply specify multiple indexes. Is there a way to do that?

**Tags:** transaction-input


---

## 2 answers

### Answer by username_1 on 2018-04-17. Score: 2 | Accepted answer

> It looks to me like each input to a bitcoin transaction has an index that specifies only one output from the input its spending.

That is correct.

> Is there a way to specify more than one output index, or do you have to create a second input line that contains the same input ID with a different index?

You have to add an extra input, which repeats the txid.

> It seems like that second way is wasteful of blockchain space - I would have thought there would be a way to simply specify multiple indexes.

It is wasteful, but only slightly. In your hypothetical system, you still need a signature/scriptSig/witness for each of the coins being spent (unless you also want to incentivize key reuse), which are generally larger than a repetition of a txid.

> Is there a way to do that?

No.


---

### Answer by username_2 on 2018-04-16. Score: 0

> Can you specify more than one output index in a transaction's input?

yes. Transactions consists of structures, including a list of inputs (V\_IN) and a list of outputs (V\_OUT).
You can have several V\_INs, and several V\_OUTs. A similar question [is here](https://bitcoin.stackexchange.com/questions/74003/multiple-input-and-output-addresses-in-bitcoin-transactions/74012#74012).

> Is there a way to specify more than one output, or do you have to
> create a second input line that contains the same input ID with a
> different index?

Not sure what is meant by lines... In a tx the data is structured, and an output is defined by the list of outputs (V\_OUT, [link to the wiki](https://en.bitcoin.it/wiki/Transaction)). It is possible to create a transaction with one input, and have many outputs. One can create these transactions manually, or also use the bitcoin core client, with the API call "createrawtransaction". The parameters are: [{"txid":txid,"vout":n},...] {address:amount,...} - one can provide several addresses with the amounts.
For example faucets sending mini amounts of BTC assemble such transactions, to save on the fees. And so one transaction may have a single input, and 100s of outputs.

=== **update 18 April 2018**, based on comments below ===

I think I see what is meant. Assuming, a given tx has two outputs, with 4 values of 0.25 BTC. All shall be spent in a single transaction, with a single tx\_in structure, along this idea:

```
...
  tx_in[0] OutPoint hash   (previous tx hash)
   tx_in[0] OutPoint_index[0] (previous tx' outpoint index --> 0.25 BTC)
   tx_in[0] OutPoint_index[1] 
   tx_in[0] OutPoint_index[2] 
   tx_in[0] OutPoint_index[3] 
  tx_in[0] Script Length   (length for the following signature script)
  tx_in[0] Script Sig      (the signature script)
  tx_in[0] Sequence        (usually set to FFFFFFFF)
...

```

This would make the transaction short, and reduce amount of space used in the blockchain and redu
ce fees. As username_1 replied already, it is not possible. The current definition of the transaction structure does not allow for such a variation. [The specification](https://bitcoin.org/en/developer-reference#raw-transaction-format) defines a single Outpoint Index per tx\_in. So to use several outputs from a previous tx, one would have to create equivalent amount of tx\_in structures, each referencing a single Output Index (and tx hash, and adding script length, sigcscript and sequence).

> **Comments:**
> **username_0**: What I meant is: is there a way to specify two output indexes for a given output? I know you can add multiple outputs, but lets say you want to use all the ouputs from a given transaction. Could you, in that case, say something to the effect of "use output index 1, 2, 3, 4, and 5 from transaction X" or do you have to say "use output index 1 from transaction X, and use output index 2 from transaction X, ..." etc?  
> **username_1**: I believe OP is asking about a way to spend multiple outputs *from the same txid* in a way that is more efficient than creating an extra input and repeating the txid.  

---

