<p>CCoins is an internal data structure, used to represented entries in the UTXO set while cached in memory (see CCoinsViewCache).</p>

<p>It is separate from CTransaction for efficiency and utility reasons. It lacks a vector for the output, saving space. It also has a much more efficient serialized form, allowing a more compact database on disk. Furthermore it has convenience methods that we wouldn't want in a base data type that's used everywhere. As CCoins is only used inside the consensus validation logic, it can be more specific.</p>

CC BY-SA 3.0
2016-02-02T11:26:36.940Z
2016-02-02T11:26:36.940Z
Pieter Wuille
<p>As per my understanding <code>CTransactions</code> represents the atomic unit in Bitcoin. It has the inputs <code>CTxIn</code> and outputs <code>CTxOut</code>. </p>

<p>Can any expert give the intuition of why we need <code>CCoins</code> in source code ? Why should we have a separate pruned class just for storing outputs ?  </p>

<transactions><bitcoin-core-development><utxo>
Why do we need CCoins in addition to CTransactions?
Prem Anand
# Why do we need CCoins in addition to CTransactions?

(Asked by: username_0 on 2016-02-02)

As per my understanding `CTransactions` represents the atomic unit in Bitcoin. It has the inputs `CTxIn` and outputs `CTxOut`.

Can any expert give the intuition of why we need `CCoins` in source code ? Why should we have a separate pruned class just for storing outputs ?

**Tags:** transactions, bitcoin-core-development, utxo


---

## 1 answers

### Answer by username_1 on 2016-02-02. Score: 5 | Accepted answer

CCoins is an internal data structure, used to represented entries in the UTXO set while cached in memory (see CCoinsViewCache).

It is separate from CTransaction for efficiency and utility reasons. It lacks a vector for the output, saving space. It also has a much more efficient serialized form, allowing a more compact database on disk. Furthermore it has convenience methods that we wouldn't want in a base data type that's used everywhere. As CCoins is only used inside the consensus validation logic, it can be more specific.


---

