Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [leveldb]

LevelDB is an embedded key-value storage developed by Google that is used in Bitcoin Core for block index storage and quick access to the UTXO set (unspent transaction outputs).

Filter by
Sorted by
Tagged with
0 votes
0 answers
17 views

How to decode bitcoin node's chainstate data stored in LevelDB?

I am trying to decode the data available in the chainstate. After doing some research, I see that Google's LevelDB is mentioned (like in this post). However, I am still not sure how to effectively and ...
ram's user avatar
  • 1
1 vote
1 answer
48 views

I can't parse the UTXO from the chainstate

I have a problem with reading tx out from the Bitcoin Core LevelDB chainstate storage. I know that the structure of the current version of the chainstate is key => value where the key is a prefix (...
Novak's user avatar
  • 41
2 votes
1 answer
50 views

Transaction incorrect when reading a block from `blk*.dat` files

The problem occurs with block 1,669,774 on testnet (https://blockstream.info/testnet/block/0000000010001cebd3e4f2fe5f2e2cbbe35ba6457554d9e0e6eb100b6f91eaee). To obtain a block I retrieve the file and ...
Ouziel Slama's user avatar
4 votes
1 answer
74 views

Does Bitcoin Core write blockchain and chainstate data atomically?

In particular, when a new block arrives: Is the block written to disk in an atomic fashion, so a new block either exists, or it doesn't? (reader can never see a partially written state) Are the ...
user49396's user avatar
  • 245
2 votes
1 answer
104 views

When does chainstate get updated?

What i'm trying to do now is reading LevelDB at chainstate folder to save all utxos at my own DB, and keep tracking the changes of utxos by looking at chainstate folder frequently. However, what i ...
Jin's user avatar
  • 61
2 votes
1 answer
94 views

LevelDB error after power outage

After a power outage, starting bitcoind I recieved this errors (circled in the image). Reading online some users suggest to do a reindex and i did it but after 11 hours my node isn't reindex yet... ...
Niko's user avatar
  • 23
2 votes
1 answer
321 views

Number of transactions per blk.dat files

I am working on a parser for the blk.dat files being returned by the Bitcoin Core node. It seems to slow down considerably after a point and I am pretty sure it's because the number of transactions is ...
Rohan Maheshwari's user avatar
0 votes
1 answer
76 views

Regarding the chainstate level db (UXTO)

Already found many useful information regarding the chainstats db. such as: What are the keys used in the blockchain levelDB (ie what are the key:value pairs)? But what is the meanning of the last ...
Carpemer's user avatar
  • 301
0 votes
1 answer
55 views

Getting wrong version number of block from block index of Bitcoin Core

I am reading block index using plyvel python package. Following is the location of block indexes: export BLOCK_INDEX_DB=$BITCOIN_HOME/blocks/index Following is the method to decode b128 varint: def ...
Vizeet Srivastava's user avatar
0 votes
1 answer
141 views

Are the block headers kept in memory?

Bitcoin Core keeps block data as files in the file system and blocks indexes in a LevelDB database to make the search process of transactions and blocks faster. But Bitcoin Core also stores block ...
MHT's user avatar
  • 13
1 vote
0 answers
90 views

Cannot unserialize chainstate transaction outputs after de-obfuscation

I was able to read chainstate database. Getting the key and de-obfuscating to get a valid last block. However, when it comes to transactions that follow after that, I cannot de-serialize them no ...
Anonymous's user avatar
  • 111
0 votes
1 answer
221 views

Bitcoin - Level DB - Block Index - Parsing value for block hash

I am trying to read the value against block hash in level DB of Bitcoin node database - Block/index. For Genesis block, I get 88 bytes which I want to parse. I tried to follow instructions in https://...
Ankit's user avatar
  • 29
0 votes
1 answer
210 views

Bitcoin - Read transaction details from LevelDB

I am new to LevelDB and the way BTC keeps everything in the database. I went through article How does Bitcoin read from/write to LevelDB but was not able to get to the first step - Transaction ...
Ankit's user avatar
  • 29
1 vote
0 answers
49 views

What is the relationship between LevelDB's cache (default 8MB) and Bitcoin's UTXO cache?

Please correct me if I am wrong. Bitcoin uses levelDB to store UTXO set. LevelDB has a default 8MB block cache, and the Bitcoin also has a dbcache(default 450MB). What is the relationship between the ...
GoneV's user avatar
  • 185
6 votes
1 answer
390 views

When the UTXO in the cache is full, what strategy is used to replace one UTXO with another in the cache?

The UTXO set is stored on the disk, but some UTXOs are also stored in the cache. When validating a transaction, you need to query the UTXO pointed to by the input of the transaction. First, you go to ...
GoneV's user avatar
  • 185
0 votes
1 answer
114 views

How does bitcoin find the block locator hashes in the leveldb database?

I am trying to understand how bitcoin core builds the list of block locator hashes needed for sendheaders and getheaders messages. I have looked on the wiki and I have seen that after the 10 most ...
giacomocaironi's user avatar
3 votes
1 answer
918 views

What is in the Bitcoin Core LevelDB dbcache? Is it full records or metadata?

What is in the Bitcoin Core LevelDB dbcache? Is it full records or metadata? This question was asked on IRC by Anonymous.
Michael Folkson's user avatar
0 votes
0 answers
2k views

Error opening block database Full node

For some reason my node shutdown and now I get when restart it Error opening block database here my bitcoin.conf txindex=1 reindex=1 reindex-chainstate=1 # Accept command line and JSON-RPC ...
monkeyUser's user avatar
1 vote
0 answers
246 views

What can cause the chainstate database to become corrupted?

I have written a tool that accesses the chainstate LevelDB database to get a list of UTXOs. https://github.com/in3rsha/bitcoin-utxo-dump/blob/master/utxodump.go The tool would originally corrupt the ...
inersha's user avatar
  • 3,145
1 vote
0 answers
126 views

why is bitcoind daemon occasionally stuck at `Opening LevelDB in .../.bitcoin/chainstate`despite clean shutdown

My bitcoind daemon sometimes takes an hour to go past Opening LevelDB in .../.bitcoin/chainstate After googling a bit, i thought it was simply an unclean daemon stop causing a leveldb corruption. But ...
stephane's user avatar
2 votes
1 answer
155 views

How Does Bitcoin Core Client Keep Track of Longest Chain/Strongest PoW Chains?

Bitcoin Core stores blocks in files in local disk. And it uses LevelDb to form an index on top of block storage to make it faster to retrieve a block (basically a simple key-value pair db). See this ...
user3299116's user avatar
2 votes
1 answer
4k views

Bitcoind Node crashes after using -dbcache option

I've been trying to speed up my node sync by increasing the dbcache. However my node tends to crash overnight. My system is running ubuntu 18.04, 4GM of ram bitcoin core v0.18. I've tried bitcoind -...
nakamoto_connection's user avatar
0 votes
1 answer
27 views

CDiskBlockIndex: NFile and NDataPos not defined

This is the source code snippet that is used for the serialization of block indexes (found in leveldb). Block 478573 index is (as of my node's leveldb) ...
Kevin P's user avatar
  • 69
0 votes
2 answers
441 views

How to get the block hash in the chainstate leveldb?

From this link What are the keys used in the blockchain levelDB (ie what are the key:value pairs)?, to get the block hash I use the obfuscation key and xor it with the result I get from the db. So I ...
guest1234312's user avatar
1 vote
1 answer
993 views

How exactly do I decode the block file info in leveldb?

Base on the links https://github.com/bitcoin/bitcoin/blob/fcbc8bfa6d10cac4f16699d6e6e68fb6eb98acd0/src/main.h#L392 and What are the keys used in the blockchain levelDB (ie what are the key:value ...
guest1234312's user avatar
2 votes
1 answer
361 views

How to parse values in block index leveldb?

So I'm trying to read the block files with Python. From this link, What are the keys used in the blockchain levelDB (ie what are the key:value pairs)?, it tells you how to access the files with ...
guest1234312's user avatar
4 votes
1 answer
327 views

Does the chainstate leveldb only contain "addresses" for P2PKH and P2SH?

I'm writing a small script that will dump the utxo database to a text file. As far as I'm aware, these are the most common script patterns indicated by the type field inside each value: e.g. value: ...
inersha's user avatar
  • 3,145
0 votes
1 answer
212 views

How does Bitcoin use its communication protocol and its database model?

In terms of Bitcoin's communication protocol, how does Bitcoin allow nodes to communicate between each other? Is Bitcoin's communication protocol the same as IPFS(InterPlanetary File System) and if ...
Iulian's user avatar
  • 135
1 vote
2 answers
626 views

Python - Querying bitcoin's block header using leveldb

I am facing a stupid problem. I am trying to read bitcoin/blocks/index leveldb using plyvel. I've set up a regtest and i know there is a block with the hash : ...
Elerir's user avatar
  • 11
2 votes
1 answer
670 views

EXCEPTION: 15dbwrapper_error

I'm running Bitcoind 0.17 on a raspberry Pi 3. Everything ran smoothly until I did something wrong (I guess) but can't figure out what happened. Now I got this error. Has someone experience with this ...
Jeans5's user avatar
  • 41
1 vote
1 answer
140 views

why is bitcoin leveldb separated in so many small pieces?

Currently I could see 1418 ldb files on my box, from 210040.ldb to 215423.ldb (some missing). Why are they separated in this way? I want to read the leveldb using golang, but I don't know which one ...
lzl124631x's user avatar
0 votes
1 answer
154 views

How can I get the key of blockindex

According to this post: What are the keys used in the blockchain levelDB (ie what are the key:value pairs)? One type of the keys in leveldb of bitcoin is formed in the following way 'b' + 32-byte ...
lzl124631x's user avatar
0 votes
0 answers
339 views

Get value from leveldb bitcoin using node.js?

I request information about the block 100001 using leveldb and node js. Below is my code example. var level = require('level'); var db = level('E:/download/blockchain/block'); var str = '...
Дима Марков's user avatar
3 votes
2 answers
419 views

Why was Bitcoin Core in need of a fork of LevelDB?

Why did Bitcoin Core fork LevelDB? What special needs does Bitcoin Core have, which require a specialized version of LevelDB?
MCCCS's user avatar
  • 10.2k
2 votes
1 answer
430 views

Why is wallet.dat BerkeleyDB instead of LevelDB?

Why wasn't wallet.dat migrated to LevelDB? Is it because BerkeleyDB is better at [something] Backwards compatibility
MCCCS's user avatar
  • 10.2k
2 votes
1 answer
470 views

bitcoin chainstate database parsing in python giving wrong value

I am trying to decode chainstate db for a specific out index for a transaction in python just for learning. Transaction ID: 4d4a4c6ca4f3c91e69563199943336d3279fad71c9e8d9c1708ef9dc6ac16000 out index = ...
Vizeet Srivastava's user avatar
1 vote
2 answers
299 views

Very hard to sync Core Client from scratch

Recently I started running a Core 15.1 node with the blockchain on an external hard drive, and found it very hard to fully sync the blockchain. The problem I keep running into is that (in about 90% of ...
2J87qy5arXEXVhc9hfT2's user avatar
0 votes
1 answer
110 views

Trojans detected in ldb bitcoin database?

I started regular scan and clamscan found lots of trojans in bitcon.lfb blocks. What is it? A mistake? sudo clamscan --infected --recursive --exclude-dir="^/sys" / /root/.bitcoin/data/blocks/index/...
Denis Matafonov's user avatar
0 votes
1 answer
827 views

Bitcoin blockchain in mongodb

How bad would it be to use MongoDB as a Bitcoin database instead of LevelDB? I know that LevelDB is faster but I've also read that MongoDB is better for doing queries. It seems cleaner to store the ...
Vladislav Zhdanov's user avatar
5 votes
3 answers
1k views

Format of a block key's contents in bitcoind's LevelDB?

I am trying to use bitcoind's LevelDB block index files (that are stored in blocks/index) to find the file (e.g. blk00029.dat) and byte position of specfic blocks. Thanks to questions What is the ...
Arjen's user avatar
  • 153
2 votes
0 answers
545 views

How to delete last n blocks / roll back to specific block number in Bitcoin Core? (Like `monero-blockchain-import --pop-blocks n`)

I have Bitcoin Core's bitcoind running and synced in a VM. Now I want to clone the VM and run one of the various hard forks (such as Bitcoin Cash) in the clone. The plan is to roll back my copy of the ...
Jay Dow's user avatar
  • 21
0 votes
2 answers
455 views

How does bitcoind store blocks?

I want to parse blockchain manually and extract the UTXO set (for various reasons). Is there any way to understand how the blocks are stored without going through the C++ code? Some specs will be ...
Jus12's user avatar
  • 1,365
1 vote
2 answers
283 views

Non-obfuscated chainstate data

I'm wondering if there is a flag that allows running bitcoind without using an obfuscation key for the chainstate. I haven't been able to find it.
sr_gi's user avatar
  • 3,220
2 votes
1 answer
286 views

Chainstate Bitcoin Core 0.15

Recently updated my LevelDB parser to work with the new LevelDB 0.15 internal structure. However, I'm wondering about two small changes I found: The prefix for transactions was changed from b'c' to b'...
sr_gi's user avatar
  • 3,220
-2 votes
1 answer
641 views

how to build altcoin in mingw?

OS : Windows 10 Installed Dependencies: -qt4.8.6 gcc 6.3.0 boost 1_55_0 berkeleyDB 4.8.30NC openssl 1.0.2l I tried compiling with the following commands: qmake "USE_UPNP=1" coin-pt.pro mingw32-...
southouse's user avatar
2 votes
1 answer
337 views

What will happen when the blockchain size will reach 1 Tb? Or 10 Tb?

My question is more about bitcoin client (bitcoind). Will it still be working fine or maybe something will go wrong? I mean, maybe LevelDB can't handle this amount of data correctly?
Sergey Potekhin's user avatar
2 votes
1 answer
240 views

Bcoin - Database backend not found

/root/BCoin/node_modules/bcoin/lib/db/backends.js:16 throw new Error('Database backend "' + name + '" not found.'); ^ Error: Database backend "leveldown" not found. at Object.get (/root/...
Thann's user avatar
  • 70
2 votes
1 answer
206 views

Resyncing bcoin brings up database version error

I was resyncing my bcoin node and got the following error: Error: Warning: Your database does not match the current database version. This is likely because the database layout or serialization ...
Bucko's user avatar
  • 183
4 votes
1 answer
2k views

In which order does the leveldb iterator iterate over utxos?

I would like to know in which order the leveldb iterator iterates over the chainstate entries. I aim to serialize the chainstate and have to make sure that every node can calculate exactly the same ...
user avatar
3 votes
1 answer
2k views

Chainstate LevelDB corruption after reading from the database

I've been working with the LevelDB for a few weeks, coding some tools to access the database and parse the data to be human readable. However, every single time I read from the chainstate the data ...
sr_gi's user avatar
  • 3,220