Author

Topic: What data LevelDB stores? (Read 157 times)

jr. member
Activity: 33
Merit: 22
April 09, 2023, 03:11:16 PM
#8
Can one explain please what does "'C'+ 32-byte transaction hash + output index length + output index" mean? In this answer https://bitcoin.stackexchange.com/questions/28168/what-are-the-keys-used-in-the-blockchain-leveldb-ie-what-are-the-keyvalue-pair/29418#29418
Firstly i decided, that hex C is stored in DB, but then I saw in there other letters, like T, or R, which are not hex numbers. So does that mean, that it's real letters, which are decoded in bytes via utf-8 for example?
And also it's not clear what output index length means. It means that if real vout index is 16 for example, then in bytes it's compared to '10' which has length of 2, and this output index length == '2' in bytes? And for vout 4096 for example hex representation is '1000', which has length of 4 bytes.
If so, then it's a bit strange. Is there any limit for the number of vouts per transaction, or I can send coins for a million users for example?
legendary
Activity: 2870
Merit: 7490
Crypto Swap Exchange
February 10, 2023, 06:15:50 AM
#7
What do these letters at the beginning mean? 'c' + smth it means that a key consists of the letter c at the begging + smth?

Correct. But if you decide to read LevelDB file directly, take note Bitcoin Core has obfuscation key[1] to prevent data corruption due to false positive from Anti virus[2].

[1] https://bitcoin.stackexchange.com/a/52167
[2] https://github.com/bitcoin/bitcoin/issues/6613
jr. member
Activity: 33
Merit: 22
February 09, 2023, 03:09:11 PM
#6


What do these letters at the beginning mean? 'c' + smth it means that a key consists of the letter c at the begging + smth?
legendary
Activity: 2870
Merit: 7490
Crypto Swap Exchange
February 09, 2023, 07:32:39 AM
#5
The set of unconfirmed transactions, the best known block header, and various metadata required to validate transactions and blocks are just a few examples of the additional data that LevelDB can hold in addition to the UTXO data regarding the health of the Bitcoin network.

Bitcoin Core documentation doesn't mention mempool (on memory or dump file "mempool.dat") use LevelDB though[1].

But what kind of data about UTXO is stored in there? I've heard that it's like txid -> data about all UTXOs, but what kind of data? Saw that there are some bits that indicates if a vout is spent or not. And when all bits show that all vouts are spent, this pair txid -> vouts will be deleted

See https://bitcoin.stackexchange.com/a/29418.

[1] https://github.com/bitcoin/bitcoin/blob/v24.0.1/doc/files.md
jr. member
Activity: 33
Merit: 22
February 09, 2023, 06:21:00 AM
#4
But what kind of data about UTXO is stored in there? I've heard that it's like txid -> data about all UTXOs, but what kind of data? Saw that there are some bits that indicates if a vout is spent or not. And when all bits show that all vouts are spent, this pair txid -> vouts will be deleted
newbie
Activity: 1078
Merit: 0
February 09, 2023, 03:30:30 AM
#3
Some Bitcoin network implementations use LevelDB, a key-value store, to keep track of the outputs of unspent transactions (UTXOs). In LevelDB, the key-value pairs stand in for the UTXOs and the related data required to verify transactions and build new blocks.

The hash of the transaction that created the UTXO and the index of the output in that transaction are combined to create each key in the LevelDB database, which represents a UTXO. Each key's value consists of a binary representation of the output's script and its associated Bitcoin balance.



The set of unconfirmed transactions, the best known block header, and various metadata required to validate transactions and blocks are just a few examples of the additional data that LevelDB can hold in addition to the UTXO data regarding the health of the Bitcoin network.

It's crucial to note that since there is no set format for this data, the precise fields and structure of the data saved in LevelDB may differ between different Bitcoin protocol implementations.
staff
Activity: 3458
Merit: 6793
Just writing some code
February 08, 2023, 11:04:03 PM
#2
It's a key-value store of outpoint to transaction output. Outpoints consist of the txid and output index, and transaction output is the amount in satoshis and the output script. These are the pieces from previous transactions that's needed to verify a transaction.
jr. member
Activity: 33
Merit: 22
February 08, 2023, 07:19:19 PM
#1
I know that LevelDB stores information about current UTXO in the whole network. But what data exactly in this database, that allows nodes create transactions? For example in a block the fields are: previous hash, timestamp, merkle root, nonce, difficulty and etc. But what are the fields in LevelDB?
Jump to: