<blockquote>
  <p>What is the weight unit cost of an input?</p>
</blockquote>

<p>2 things affect the weight of a tx, the total number of bytes , and the total bytes minus witness data.</p>

<p><code>Transaction Weight = Base transaction size * 3 + Total transaction size</code>, where</p>

<p><strong>Base transaction size</strong> is the size of the transaction serialised with the witness data stripped.</p>

<p><strong>Total transaction size</strong> is the transaction size in bytes serialized as described in <a href="https://github.com/bitcoin/bips/blob/master/bip-0144.mediawiki" rel="nofollow noreferrer">BIP144</a>, including base data and witness data.</p>

<p>See <a href="https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki" rel="nofollow noreferrer">BIP141</a></p>

<blockquote>
  <p>Can you batch/aggregate the inputs or is it linearly growth when you
  add more inputs to a tx?</p>
</blockquote>

<p>You can't batch inputs, but you can combine them and send them back to yourself first in a larger amount, but that requires an additional transaction. Probably the best you can do now is to use a segwit address to receive funds so when you go to spend the inputs, the witness data lowers the weight of each input.</p>

CC BY-SA 4.0
2018-09-27T14:13:03.153Z
And to address OP's specific question, yes, this means that transaction size grows linearly with the number of inputs.
Nate Eldredge
CC BY-SA 4.0
2018-09-27T19:23:35.357Z
Thank you for the answer, I am however still wondering how heavy an input is?
Bertram Lund
CC BY-SA 4.0
2018-09-27T19:37:00.163Z
It depends on the scriptSig, see https://bitcoin.stackexchange.com/questions/68811/what-is-the-absolute-smallest-size-of-the-data-bytes-that-a-blockchain-transac and https://en.bitcoin.it/wiki/Transaction#General_format_.28inside_a_block.29_of_each_input_of_a_transaction_-_Txin
JBaczuk
CC BY-SA 4.0
2018-09-27T13:20:28.700Z
2018-09-27T13:20:28.700Z
JBaczuk
<p>The weight of a single input in a transaction always uses:</p>

<ul>
<li><code>32</code> bytes to reference the outpoint id (hash)</li>
<li><code>4</code> bytes to reference the outpoint index</li>
</ul>

<p>Then, if the outpoint is a non-segwit p2pkh output the scriptSig uses:</p>

<ul>
<li><code>1</code> byte to denote the scriptSig size</li>
<li><code>1</code> byte to denote the signature size</li>
<li><code>71</code> bytes (on average) for the signature</li>
<li><code>1</code> byte to denote the public key size</li>
<li><code>33</code> bytes for the public key</li>
</ul>

<p>In total this makes <code>143</code> bytes (on average) to reference a non-segwit p2pkh output with your spending transaction.</p>

<p>For segwit p2sh nested p2pkh outputs, the scriptSig uses instead:</p>

<ul>
<li><code>1</code> byte to denote the scriptSig size</li>
<li><code>1</code> byte to denote the witness version (0x00)</li>
<li><code>1</code> byte to denote the public key hash size</li>
<li><code>20</code> bytes for the public key hash</li>
</ul>

<p>Further, the witnessScript will use the same amount of bytes as the scriptSig for spending non-witness p2pkh outpoints. However, the witnessScript only counts with a quarter to the total weight.</p>

<p>Therefore a segwit p2sh nested input has a weight contribution of <code>59</code> bytes + (<code>107</code>)/4 bytes = <code>86</code> bytes on average.</p>

CC BY-SA 4.0
2018-11-23T22:43:54.537Z
2018-11-23T22:43:54.537Z
Bjarne Magnussen
<p>What is the weight unit cost of an input? And can you batch/aggregate the inputs or is it linearly growth when you add more inputs to a tx?</p>

<transaction-input>
How many weight units does an input use?
Bertram Lund
# How many weight units does an input use?

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

What is the weight unit cost of an input? And can you batch/aggregate the inputs or is it linearly growth when you add more inputs to a tx?

**Tags:** transaction-input


---

## 2 answers

### Answer by username_1 on 2018-09-27. Score: 1

> What is the weight unit cost of an input?

2 things affect the weight of a tx, the total number of bytes , and the total bytes minus witness data.

`Transaction Weight = Base transaction size * 3 + Total transaction size`, where

**Base transaction size** is the size of the transaction serialised with the witness data stripped.

**Total transaction size** is the transaction size in bytes serialized as described in [BIP144](https://github.com/bitcoin/bips/blob/master/bip-0144.mediawiki), including base data and witness data.

See [BIP141](https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki)

> Can you batch/aggregate the inputs or is it linearly growth when you
> add more inputs to a tx?

You can't batch inputs, but you can combine them and send them back to yourself first in a larger amount, but that requires an additional transaction. Probably the best you can do now is to use a segwit address to receive funds so when you go to spend the inputs, the witness data lowers the weight of each input.

> **Comments:**
> **username_2**: And to address OP's specific question, yes, this means that transaction size grows linearly with the number of inputs.  
> **username_0**: Thank you for the answer, I am however still wondering how heavy an input is?  
> **username_1**: It depends on the scriptSig, see https://bitcoin.stackexchange.com/questions/68811/what-is-the-absolute-smallest-size-of-the-data-bytes-that-a-blockchain-transac and https://en.bitcoin.it/wiki/Transaction#General_format_.28inside_a_block.29_of_each_input_of_a_transaction_-_Txin  

---

### Answer by username_3 on 2018-11-23. Score: 1

The weight of a single input in a transaction always uses:

* `32` bytes to reference the outpoint id (hash)
* `4` bytes to reference the outpoint index

Then, if the outpoint is a non-segwit p2pkh output the scriptSig uses:

* `1` byte to denote the scriptSig size
* `1` byte to denote the signature size
* `71` bytes (on average) for the signature
* `1` byte to denote the public key size
* `33` bytes for the public key

In total this makes `143` bytes (on average) to reference a non-segwit p2pkh output with your spending transaction.

For segwit p2sh nested p2pkh outputs, the scriptSig uses instead:

* `1` byte to denote the scriptSig size
* `1` byte to denote the witness version (0x00)
* `1` byte to denote the public key hash size
* `20` bytes for the public key hash

Further, the witnessScript will use the same amount of bytes as the scriptSig for spending non-witness p2pkh outpoints. However, the witnessScript only counts with a quarter to the total weight.

Therefore a segwit p2sh nested input has a weight contribution of `59` bytes + (`107`)/4 bytes = `86` bytes on average.


---

