<blockquote>
  <p>So are bitcoins, or the smallest allowable bitcoin fractions,
  distinctly labeled entities?</p>
</blockquote>

<p>No, but almost. Bitcoins are literally just a value which is assigned to a script (see <strong>Scripts</strong> below). There are many consensus rules that determine whether that value is valid bitcoin. The most important of which is that <strong>It must be from a valid unspent transaction output.</strong> This is labeled, by a <code>txid</code> and <code>vout</code> index.</p>

<p>Bitcoin uses a TXO (Transaction Ouput) model instead of a account model. This means, a transaction always has at least one input and one output (but can have multiple).</p>

<p><strong>Example Transaction:</strong></p>

<pre><code>txid: f5d8ee39a430901c91a5917b9f2dc19d6d1a0e9cea205b009ca73dd04470b9a6

Inputs             vin    Outputs                   vout
1 BTC to Address 1 0   -&gt; 0.999 Address 2           0
                       -&gt; 0.0009 Address 1 (Change) 1
</code></pre>

<p><strong>Note</strong>: The leftover <code>0.0001 btc</code> can be claimed by the miner as a tx fee.</p>

<p>Let's say that vin 0 references a txid and vout which has already been referenced in a previous transaction. If that is the case, then that txo has been spent (the entire blockchain is checked for unspent outputs), and that transaction would be considered a <strong><em>double spend</em></strong>, and rejected by the Bitcoin network.</p>

<h2>Scripts</h2>

<p>An amount of bitcoin is locked by a specific <a href="https://en.bitcoin.it/wiki/Script" rel="nofollow noreferrer">script</a>. The script can represent a public key (P2PKH - Pay to Public Key Hash) or <a href="https://en.bitcoin.it/wiki/Transaction#Pay-to-Script-Hash" rel="nofollow noreferrer">multiple</a> (multisig P2SH - Pay to Script Hash), for example. But, the spender has to be able to satisfy the script in order to spend the bitcoin. Usually the script requires signing the transaction with a private key.</p>

CC BY-SA 4.0
2018-08-30T15:34:07.127Z
2018-08-30T15:34:07.127Z
JBaczuk
<p>Bitcoins are labeled by the Unspent Outputs ("UTXO"). When a transaction pays to an address, the bitcoins are kept in a container named UTXO. (In other words, addresses don't keep bitcoins, unspent outputs do.) To make a transaction from that address, the transaction must reference the UTXO:</p>

<ul>
<li>Transaction id of the transaction who created it.</li>
<li>Which output of the transaction it is. ("vout")</li>
</ul>

<p>When someone spends it (and gets one confirmation), the database removes that UTXO. If you try to respend it, it won't find that UTXO, thus an error will be thrown.</p>

<p>Different UTXO are used for different payments, unless the UTXO is large enough.</p>

CC BY-SA 4.0
2018-08-30T15:32:14.843Z
2018-08-30T15:32:14.843Z
MCCCS
<blockquote>
  <p><strong>So are bitcoins, or the smallest allowable bitcoin fractions, distinctly labeled entities?</strong></p>
</blockquote>

<p>They are unspent amounts (outputs of prior transactions) associated with addresses. Unspent transaction outputs are abbreviated UTXO.</p>

<p>Bitcoins or fractions (millibits, Satoshis etc) don't exist as <em><a href="https://www.sqa.org.uk/e-learning/MDBS01CD/page_06.htm" rel="noreferrer">entities</a></em> in computers running Bitcoin software. The computers just keep track of the movement of amounts, they keep track of UTXOs, transactions, addresses and so on. Those are the identified entities.</p>

<blockquote>
  <p><strong>what would double spending actually look like in the bitcoin system?</strong></p>
</blockquote>

<p>Two transactions with the same input UTXOs.</p>

<p>The first one to be mined and "confirmed" will be valid, the second one will be regarded as invalid. There can be a period in which the outcome is uncertain until a consensus emerges.</p>

<p>See also <a href="https://en.bitcoin.it/wiki/Replace_by_fee" rel="noreferrer">Replace By Fee (RBF)</a></p>

CC BY-SA 4.0
2018-09-03T03:06:03.723Z
So, does the amount in a single transaction (with one UTXO) have to all be spent at once? Suppose I received 1 BTC in one transaction (with 1 UTXO), and then I create two transactions, each referencing the same UTXO and each paying 0.5 BTC to different users. Have I double-spent?
WillG
CC BY-SA 4.0
2018-09-03T07:32:08.637Z
@willg that is not a double-spend. You could do it as a single transaction or as two with the second using change returned from the first. The change UTXO is new.
RedGrittyBrick
CC BY-SA 4.0
2018-08-30T15:28:15.437Z
2018-08-30T16:37:03.990Z
2018-08-30T16:37:03.990Z
RedGrittyBrick
<p>Many sources describe the double spending problem by saying something like "people cannot be able to spend the same bitcoin twice." <a href="https://coinsutra.com/bitcoin-double-spending/" rel="nofollow noreferrer">[1]</a><a href="https://en.wikipedia.org/wiki/Double-spending" rel="nofollow noreferrer">[2]</a><a href="https://www.bitcoin.com/info/what-is-bitcoin-double-spending" rel="nofollow noreferrer">[3]</a> So are bitcoins, or the smallest allowable bitcoin fractions, distinctly labeled entities? My understanding was that they are not, and that the blockchain only records information on the <em>amount</em> of bitcoins each user has. </p>

<p>Also, if I am correct, what would double spending actually look like in the bitcoin system? If I send a transaction to one miner saying "I pay user X 1 bitcoin" and another transaction to a different miner saying "I pay user Y 1 bitcoin", then it seems like I haven't double-spent, but rather just paid two bitcoins in total, one to each user. Right?</p>

<doublespend>
Are bitcoins (or fractions of bitcoins) labeled with IDs?
WillG
# Are bitcoins (or fractions of bitcoins) labeled with IDs?

(Asked by: username_0 on 2018-08-30)

Many sources describe the double spending problem by saying something like "people cannot be able to spend the same bitcoin twice." [[1]](https://coinsutra.com/bitcoin-double-spending/)[[2]](https://en.wikipedia.org/wiki/Double-spending)[[3]](https://www.bitcoin.com/info/what-is-bitcoin-double-spending) So are bitcoins, or the smallest allowable bitcoin fractions, distinctly labeled entities? My understanding was that they are not, and that the blockchain only records information on the *amount* of bitcoins each user has.

Also, if I am correct, what would double spending actually look like in the bitcoin system? If I send a transaction to one miner saying "I pay user X 1 bitcoin" and another transaction to a different miner saying "I pay user Y 1 bitcoin", then it seems like I haven't double-spent, but rather just paid two bitcoins in total, one to each user. Right?

**Tags:** doublespend


---

## 3 answers

### Answer by username_3 on 2018-08-30. Score: 7 | Accepted answer

> **So are bitcoins, or the smallest allowable bitcoin fractions, distinctly labeled entities?**

They are unspent amounts (outputs of prior transactions) associated with addresses. Unspent transaction outputs are abbreviated UTXO.

Bitcoins or fractions (millibits, Satoshis etc) don't exist as *[entities](https://www.sqa.org.uk/e-learning/MDBS01CD/page_06.htm)* in computers running Bitcoin software. The computers just keep track of the movement of amounts, they keep track of UTXOs, transactions, addresses and so on. Those are the identified entities.

> **what would double spending actually look like in the bitcoin system?**

Two transactions with the same input UTXOs.

The first one to be mined and "confirmed" will be valid, the second one will be regarded as invalid. There can be a period in which the outcome is uncertain until a consensus emerges.

See also [Replace By Fee (RBF)](https://en.bitcoin.it/wiki/Replace_by_fee)

> **Comments:**
> **username_0**: So, does the amount in a single transaction (with one UTXO) have to all be spent at once? Suppose I received 1 BTC in one transaction (with 1 UTXO), and then I create two transactions, each referencing the same UTXO and each paying 0.5 BTC to different users. Have I double-spent?  
> **username_3**: @username_0 that is not a double-spend. You could do it as a single transaction or as two with the second using change returned from the first. The change UTXO is new.  

---

### Answer by username_1 on 2018-08-30. Score: 4

> So are bitcoins, or the smallest allowable bitcoin fractions,
> distinctly labeled entities?

No, but almost. Bitcoins are literally just a value which is assigned to a script (see **Scripts** below). There are many consensus rules that determine whether that value is valid bitcoin. The most important of which is that **It must be from a valid unspent transaction output.** This is labeled, by a `txid` and `vout` index.

Bitcoin uses a TXO (Transaction Ouput) model instead of a account model. This means, a transaction always has at least one input and one output (but can have multiple).

**Example Transaction:**

```
txid: f5d8ee39a430901c91a5917b9f2dc19d6d1a0e9cea205b009ca73dd04470b9a6

Inputs             vin    Outputs                   vout
1 BTC to Address 1 0   -> 0.999 Address 2           0
                       -> 0.0009 Address 1 (Change) 1

```

**Note**: The leftover `0.0001 btc` can be claimed by the miner as a tx fee.

Let's say that vin 0 references a txid and vout which has already been referenced in a previous transaction. If that is the case, then that txo has been spent (the entire blockchain is checked for unspent outputs), and that transaction would be considered a ***double spend***, and rejected by the Bitcoin network.

## Scripts

An amount of bitcoin is locked by a specific [script](https://en.bitcoin.it/wiki/Script). The script can represent a public key (P2PKH - Pay to Public Key Hash) or [multiple](https://en.bitcoin.it/wiki/Transaction#Pay-to-Script-Hash) (multisig P2SH - Pay to Script Hash), for example. But, the spender has to be able to satisfy the script in order to spend the bitcoin. Usually the script requires signing the transaction with a private key.


---

### Answer by username_2 on 2018-08-30. Score: 3

Bitcoins are labeled by the Unspent Outputs ("UTXO"). When a transaction pays to an address, the bitcoins are kept in a container named UTXO. (In other words, addresses don't keep bitcoins, unspent outputs do.) To make a transaction from that address, the transaction must reference the UTXO:

* Transaction id of the transaction who created it.
* Which output of the transaction it is. ("vout")

When someone spends it (and gets one confirmation), the database removes that UTXO. If you try to respend it, it won't find that UTXO, thus an error will be thrown.

Different UTXO are used for different payments, unless the UTXO is large enough.


---

