Author

Topic: Bitcoin Core wallet.dat specification (Read 273 times)

full member
Activity: 297
Merit: 133
April 23, 2022, 02:07:43 PM
#8
Not sure if this is what you meant, but at beginning of file mentioned by @achow101 has list of wallet keys.

https://github.com/bitcoin/bitcoin/blob/master/src/wallet/walletdb.cpp#L30-L62

Yes, that's it!

I need to connect values to identification bytes...
full member
Activity: 297
Merit: 133
April 21, 2022, 01:30:01 PM
#7
It's pretty much all in this function: https://github.com/bitcoin/bitcoin/blob/master/src/wallet/walletdb.cpp#L322

The wallet.dat is either a BerkeleyDB database, or a SQLite database, depending on whether you have decided to make a descriptor wallet (SQLite if so).

The database is used as a key-value store, where every key always begins with a length prefixed ascii string indicating the type of the record. From there, the data stored depends on the record type and is just a bunch of different objects serialized. You will have to look at each object's serialization methods to figure that out.

BerkeleyDB is a key-value database so libraries for it provide access to that directly. For SQLite, the database is a single table with two columns, the first named "key" and the second "value".

I know all that, I am asking exclusively for mentioned keys and values - what are they?
staff
Activity: 3458
Merit: 6793
Just writing some code
April 20, 2022, 06:35:10 PM
#6
It's pretty much all in this function: https://github.com/bitcoin/bitcoin/blob/master/src/wallet/walletdb.cpp#L322

The wallet.dat is either a BerkeleyDB database, or a SQLite database, depending on whether you have decided to make a descriptor wallet (SQLite if so).

The database is used as a key-value store, where every key always begins with a length prefixed ascii string indicating the type of the record. From there, the data stored depends on the record type and is just a bunch of different objects serialized. You will have to look at each object's serialization methods to figure that out.

BerkeleyDB is a key-value database so libraries for it provide access to that directly. For SQLite, the database is a single table with two columns, the first named "key" and the second "value".
full member
Activity: 297
Merit: 133
April 20, 2022, 01:07:01 PM
#5
Well, what I have done is to extract some data from wallet.dat beside headers and what I've got is:

70 bytes of key + 314 bytes of value
86 bytes of key + 16 bytes of value
148 bytes of key + 78 bytes of value

I didn't look what are these bytes (I had them only in hex format), but question is: what these bytes can be?
full member
Activity: 297
Merit: 133
April 18, 2022, 01:15:06 PM
#4
Huh

In another post I was talking about making wallet.dat program in Python,
but seems that there is much simpler way of handling wallets in C# and that link gives me much,
as I can extend this program much more and take care of BerkeleyDB in well-known for me C#.
full member
Activity: 297
Merit: 133
April 18, 2022, 10:41:46 AM
#3

Thank you!

That's a very good program.

I can extend it to my needs.
legendary
Activity: 2870
Merit: 7490
Crypto Swap Exchange
April 18, 2022, 05:33:44 AM
#2
I'm not C# programmer, but i know 2 tools/library which aimed to read/recover wallet.dat. Take note both haven't been updated in long time,
https://code.google.com/archive/p/bitcoinsharp/
https://github.com/hg5fm/WalletRecovery

Alternatively, you could use Berkeley DB reader for C# and check some known entries of wallet.dat https://bitcoin.stackexchange.com/a/3177.
full member
Activity: 297
Merit: 133
April 17, 2022, 10:46:19 AM
#1
Has anybody .NET/C# classes structure of Bitcoin Core wallet.dat that he could share?
Jump to: