<p>A purely local database is generally used. The specifics are implementation dependent. It is for a software developer to choose. It may be sensible to use a popular DBMS for efficiency reasons but any system of storage and retrieval is sufficient.</p>
<p>The primary source of data used in validation is the replicated journal of all Bitcoin transactions since its beginning. This transaction journal is called the &quot;blockchain&quot;. Every full-node (e.g. wallets like Bitcoin core) maintains its own copy of this transaction journal.</p>
<p>Spendable amounts of Bitcoin are kept track of in the form of unspent transaction outputs (UTXOs). Each transaction consumes one or more UTXOs as inputs and creates new UTXOs as outputs (including amounts of <a href="https://bitcoin.stackexchange.com/q/736/13866">change</a> being returned to the spender). Nodes generally maintain a list of the current set of UTXOs.</p>
<p>Coinbase transactions create new amounts for the block reward without consuming UTXOs. These amounts are constrained by the halving rules for block reward amounts. These rules are built into the software. Coinbase transactions also collect the transaction fees which are the difference between sum of inputs and sum of outputs for ordinary transactions in the block. So those amounts also don't need to be tracked back to specific UTXOs because the ordinary transactions will have already been validated against the UTXO set.</p>

CC BY-SA 4.0
2022-03-25T15:11:06.460Z
2022-03-25T15:45:47.037Z
2022-03-25T15:45:47.037Z
RedGrittyBrick
<p>In order to be able to tell whether an unconfirmed transaction is eligible for block inclusion, a node checks that the UTXO spent in the transaction's inputs are available for spending and that the transaction is well-formed according to the protocol rules. To that end, the node must enforce all protocol rules, be caught up to the chain tip, and know the complete UTXO set.</p>
<p>Coinbase transactions have slightly different rules in that they don't have inputs but their outputs are constrained by the block subsidy schedule and the transaction fees of the remaining transactions in their corresponding block. To assess the validity of coinbase transactions, the node must have checked all transactions in the block, tallied the transaction fees, and then verify the amounts in the coinbase and (for segwit blocks) the presence of the correct witness commitment in an OP_RETURN output. Since transactions do not explicitly state the input amounts or the transaction fees, the UTXO values must be known beforehand to calculate the transaction fees. The blockchain therefore has to be processed in full and in order.</p>

CC BY-SA 4.0
2022-03-27T12:35:26.090Z
2022-03-27T12:41:20.767Z
2022-03-27T12:41:20.767Z
Murch
<p>When you check a transaction before adding it to a block what data source is used as a source to make sure all the coinbase transactions are valid.</p>

<transaction-verification><coinbase-transaction><utxo-set>
What databases is used to see if a transaction is valid?
PurpleMoneys89
# What databases is used to see if a transaction is valid?

(Asked by: username_0 on 2022-03-25)

When you check a transaction before adding it to a block what data source is used as a source to make sure all the coinbase transactions are valid.

**Tags:** transaction-verification, coinbase-transaction, utxo-set


---

## 2 answers

### Answer by username_1 on 2022-03-25. Score: 1 | Accepted answer

A purely local database is generally used. The specifics are implementation dependent. It is for a software developer to choose. It may be sensible to use a popular DBMS for efficiency reasons but any system of storage and retrieval is sufficient.

The primary source of data used in validation is the replicated journal of all Bitcoin transactions since its beginning. This transaction journal is called the "blockchain". Every full-node (e.g. wallets like Bitcoin core) maintains its own copy of this transaction journal.

Spendable amounts of Bitcoin are kept track of in the form of unspent transaction outputs (UTXOs). Each transaction consumes one or more UTXOs as inputs and creates new UTXOs as outputs (including amounts of [change](https://bitcoin.stackexchange.com/q/736/13866) being returned to the spender). Nodes generally maintain a list of the current set of UTXOs.

Coinbase transactions create new amounts for the block reward without consuming UTXOs. These amounts are constrained by the halving rules for block reward amounts. These rules are built into the software. Coinbase transactions also collect the transaction fees which are the difference between sum of inputs and sum of outputs for ordinary transactions in the block. So those amounts also don't need to be tracked back to specific UTXOs because the ordinary transactions will have already been validated against the UTXO set.


---

### Answer by username_2 on 2022-03-27. Score: 0

In order to be able to tell whether an unconfirmed transaction is eligible for block inclusion, a node checks that the UTXO spent in the transaction's inputs are available for spending and that the transaction is well-formed according to the protocol rules. To that end, the node must enforce all protocol rules, be caught up to the chain tip, and know the complete UTXO set.

Coinbase transactions have slightly different rules in that they don't have inputs but their outputs are constrained by the block subsidy schedule and the transaction fees of the remaining transactions in their corresponding block. To assess the validity of coinbase transactions, the node must have checked all transactions in the block, tallied the transaction fees, and then verify the amounts in the coinbase and (for segwit blocks) the presence of the correct witness commitment in an OP\_RETURN output. Since transactions do not explicitly state the input amounts or the transaction fees, the UTXO values must be known beforehand to calculate the transaction fees. The blockchain therefore has to be processed in full and in order.


---

