<p>After searching about this, i found out that each full node maintains a database with the set of unspent transaction outputs (UTXOs) in the memory. So When a new transaction is added, its UTXOs get updated accordingly <a href="https://bitcoin.stackexchange.com/a/50071/96613">(source)</a>. Also, a full node keeps track of all transactions that ever happened <a href="https://en.bitcoin.it/wiki/Full_node" rel="nofollow noreferrer">(source)</a> and offer this:</p>
<blockquote>
<p>Filtering transactions and blocks on behalf of lightweight nodes so that lightweight nodes do not need to download every transaction ever made on the network in order to find their own transactions.</p>
<p>Serving historical full blocks to nodes that have been offline for a while.</p>
<p>Transmitting new transactions from users to miners.</p>
<p>Broadcasting new blocks from miners to other nodes.</p>
</blockquote>
<p>The RPC used for this call <a href="http://chainquery.com/bitcoin-api/getrawtransaction" rel="nofollow noreferrer">getrawtransaction</a> that takes as an argument a TxID which is hashing twice the <a href="https://learnmeabitcoin.com/glossary/transaction-data" rel="nofollow noreferrer">transaction data</a> and gives you back the transaction you are searching for.</p>

CC BY-SA 4.0
2019-07-02T20:55:25.240Z
"NOTE: By default this function only works for mempool transactions. If the -txindex option is enabled, it also works for blockchain transactions."
JBaczuk
CC BY-SA 4.0
2019-07-02T18:09:19.710Z
2019-07-02T18:09:19.710Z
2020-06-16T11:10:03.350Z
rachid chami
<p>I wanna understand how can a user find a certain transaction he created on the blockchain without him knowing on which block it belongs ? does he have to go over all the blocks using bloom filters to find his transaction ? narrow the search to an interval of timestamps ? there must be a special mechanism ...</p>

<p>I searched on google but all i found were websites to find them for u, i want to understand the actual mechanism used in the bitcoin protocol?</p>

<p>Block Explorers seems to be storing those transactions in special databases and they use their own approach to find transactions ... My question is about how full nodes find those transactions ? do they go over the whole chain trying to find them ?</p>

CC BY-SA 4.0
2019-07-01T17:41:12.847Z
Are you asking about how to search for a transaction using Bitcoin Core? There is an RPC for that, assuming you enabled indexing. Or are you asking how Bitcoin Core does it? Bitcoin and Ethereum will be different, but you can visit ethereum.stackexchange.com
JBaczuk
CC BY-SA 4.0
2019-07-01T19:16:43.367Z
About how Bitcoin core does it
rachid chami
CC BY-SA 4.0
2019-07-01T19:43:24.370Z
Bitcoin Core does not do this. It has a database of unspent outputs, and adds/removes outputs from that database. It (generally) does not have an index into the blockchain, or even the entire blockchain at all available.
Pieter Wuille
CC BY-SA 4.0
2019-07-01T20:18:36.500Z
Then my question is, how websites like block explorer works.
rachid chami
CC BY-SA 4.0
2019-07-01T20:27:45.870Z
Seems like it was covered in here https://bitcoin.stackexchange.com/questions/58844/how-block-explorer-technology-works  but without great details or how exactly it works, just the general idea behind. But apparently, there isnt any native mechanism to the protocol that lets u search in blocks, u just need to go over all the blocks and search for transactions (in Eth, using bloom filters to know if a certain transaction belongs) in a way or another.
rachid chami
CC BY-SA 4.0
2019-07-02T07:38:33.307Z
@rachidchami Bitcoin Core is a full node and hence maintains the entire database of the blockchain. If you are using a lightweight nodes that use SPV, those use bloom filters to query full nodes for transaction. These lightweight clients are then sent the merkle path by the full nodes that shows that the transaction is in the blockchain
Ugam Kamat
CC BY-SA 4.0
2019-07-02T15:47:46.510Z
@UgamKamat. How does the full nodes find such transactions ? do they go over the whole chain ?
rachid chami
CC BY-SA 4.0
2019-07-02T16:26:48.133Z
@rachidchami The answer to your question is too broad for it to be posted as a comment. Here is an answer link: https://bitcoin.stackexchange.com/questions/81188/spv-clients-querying-the-full-node.
Ugam Kamat
CC BY-SA 4.0
2019-07-02T16:37:18.760Z
@UgamKamat thank you so much for your help.
rachid chami
<transactions><bitcoin-core><blockchain>
Finding a transaction in the blockchain
rachid chami
# Finding a transaction in the blockchain

(Asked by: username_0 on 2019-07-01)

I wanna understand how can a user find a certain transaction he created on the blockchain without him knowing on which block it belongs ? does he have to go over all the blocks using bloom filters to find his transaction ? narrow the search to an interval of timestamps ? there must be a special mechanism ...

I searched on google but all i found were websites to find them for u, i want to understand the actual mechanism used in the bitcoin protocol?

Block Explorers seems to be storing those transactions in special databases and they use their own approach to find transactions ... My question is about how full nodes find those transactions ? do they go over the whole chain trying to find them ?

**Tags:** transactions, bitcoin-core, blockchain

> **Comments:**
> **username_1**: Are you asking about how to search for a transaction using Bitcoin Core? There is an RPC for that, assuming you enabled indexing. Or are you asking how Bitcoin Core does it? Bitcoin and Ethereum will be different, but you can visit ethereum.stackexchange.com  
> **username_0**: About how Bitcoin core does it  
> **username_2**: Bitcoin Core does not do this. It has a database of unspent outputs, and adds/removes outputs from that database. It (generally) does not have an index into the blockchain, or even the entire blockchain at all available.  
> **username_0**: Then my question is, how websites like block explorer works.  
> **username_0**: Seems like it was covered in here https://bitcoin.stackexchange.com/questions/58844/how-block-explorer-technology-works  but without great details or how exactly it works, just the general idea behind. But apparently, there isnt any native mechanism to the protocol that lets u search in blocks, u just need to go over all the blocks and search for transactions (in Eth, using bloom filters to know if a certain transaction belongs) in a way or another.  
> **username_3**: @username_0 Bitcoin Core is a full node and hence maintains the entire database of the blockchain. If you are using a lightweight nodes that use SPV, those use bloom filters to query full nodes for transaction. These lightweight clients are then sent the merkle path by the full nodes that shows that the transaction is in the blockchain  
> **username_0**: @username_3. How does the full nodes find such transactions ? do they go over the whole chain ?  
> **username_3**: @username_0 The answer to your question is too broad for it to be posted as a comment. Here is an answer link: https://bitcoin.stackexchange.com/questions/81188/spv-clients-querying-the-full-node.  
> **username_0**: @username_3 thank you so much for your help.  

---

## 1 answers

### Answer by username_0 on 2019-07-02. Score: 2 | Accepted answer

After searching about this, i found out that each full node maintains a database with the set of unspent transaction outputs (UTXOs) in the memory. So When a new transaction is added, its UTXOs get updated accordingly [(source)](https://bitcoin.stackexchange.com/a/50071/96613). Also, a full node keeps track of all transactions that ever happened [(source)](https://en.bitcoin.it/wiki/Full_node) and offer this:

> Filtering transactions and blocks on behalf of lightweight nodes so that lightweight nodes do not need to download every transaction ever made on the network in order to find their own transactions.
>
> Serving historical full blocks to nodes that have been offline for a while.
>
> Transmitting new transactions from users to miners.
>
> Broadcasting new blocks from miners to other nodes.

The RPC used for this call [getrawtransaction](http://chainquery.com/bitcoin-api/getrawtransaction) that takes as an argument a TxID which is hashing twice the [transaction data](https://learnmeabitcoin.com/glossary/transaction-data) and gives you back the transaction you are searching for.

> **Comments:**
> **username_1**: "NOTE: By default this function only works for mempool transactions. If the -txindex option is enabled, it also works for blockchain transactions."  

---

