<p>I learned that the blocks and transactions are stored locally in .bitcoin/blocks/index and .bitcoin/chainstate databases, respectively. 
I want to make a direct query to those databases to measure the response time. 
However, I found it hard to understand the format and the best way to access to the data. 
I am using Plyvel, but I couldn't formulate the exact query, for example to search for a particular transaction identified by its hash value, or searching for the all transactions made by a particular sender identified by the hash of its public address. </p>

<p>Any help, please.</p>

CC BY-SA 3.0
2017-05-16T09:15:58.857Z
This may help you https://bitcoin.stackexchange.com/a/52167/30668
sr_gi
CC BY-SA 3.0
2017-05-16T10:10:24.740Z
I already see it, but how the transaction id is transformed from 246c5a81b6ad0dfc0dbc0b2ff5bde65ee1913f75a47d409b8ff8074a27ec1000    to c0010ec274a07f88f9b407da4753f91e15ee6bdf52f0bbc0dfc0dadb6815a6c24 ??
Noureddine
CC BY-SA 3.0
2017-05-16T10:17:53.287Z
You should change the endianness. While txids are displayed in blockexplorers as big endian values, they are stored in the LevelDB in their little endian representation.
sr_gi
CC BY-SA 3.0
2017-05-16T10:33:35.883Z
Ah ok, I see.  Then I have to convert txid from big to little endian before making the query. May be this can help in the conversion: http://stackoverflow.com/questions/13155570/reorder-byte-order-in-hex-string-python
Noureddine
CC BY-SA 3.0
2017-05-16T10:34:20.803Z
What about the sender address, how I can search for transaction by sender address?
Noureddine
CC BY-SA 3.0
2017-05-16T10:44:20.770Z
To my knowledge, You can't, at least by querying the LevelDB. The purpose of the UTXO set stored in the DB is identify which transactions are unspent in order to make it easier to validate a transaction that  tries to redeem one. If you want to know the addresses (or more generally the scripts) involved in each UTXO you will need to parse the information obtained when querying the DB by the txids.
sr_gi
CC BY-SA 3.0
2017-05-16T10:48:33.423Z
Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/58830/discussion-between-sr-gi-and-noureddine).
sr_gi
<transactions><bitcoind><utxo><address-reuse>
How to directly query leveldb database to get get a record by transaction hash or by sender's address?
Noureddine
# How to directly query leveldb database to get get a record by transaction hash or by sender's address?

(Asked by: username_0 on 2017-05-16)

I learned that the blocks and transactions are stored locally in .bitcoin/blocks/index and .bitcoin/chainstate databases, respectively.
I want to make a direct query to those databases to measure the response time.
However, I found it hard to understand the format and the best way to access to the data.
I am using Plyvel, but I couldn't formulate the exact query, for example to search for a particular transaction identified by its hash value, or searching for the all transactions made by a particular sender identified by the hash of its public address.

Any help, please.

**Tags:** transactions, bitcoind, utxo, address-reuse

> **Comments:**
> **username_1**: This may help you https://bitcoin.stackexchange.com/a/52167/30668  
> **username_0**: I already see it, but how the transaction id is transformed from 246c5a81b6ad0dfc0dbc0b2ff5bde65ee1913f75a47d409b8ff8074a27ec1000    to c0010ec274a07f88f9b407da4753f91e15ee6bdf52f0bbc0dfc0dadb6815a6c24 ??  
> **username_1**: You should change the endianness. While txids are displayed in blockexplorers as big endian values, they are stored in the LevelDB in their little endian representation.  
> **username_0**: Ah ok, I see.  Then I have to convert txid from big to little endian before making the query. May be this can help in the conversion: http://stackoverflow.com/questions/13155570/reorder-byte-order-in-hex-string-python  
> **username_0**: What about the sender address, how I can search for transaction by sender address?  
> **username_1**: To my knowledge, You can't, at least by querying the LevelDB. The purpose of the UTXO set stored in the DB is identify which transactions are unspent in order to make it easier to validate a transaction that  tries to redeem one. If you want to know the addresses (or more generally the scripts) involved in each UTXO you will need to parse the information obtained when querying the DB by the txids.  
> **username_1**: Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/58830/discussion-between-username_1-and-username_0).  

---

## 0 answers

