Bitcoin Forum
November 17, 2024, 12:02:21 AM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Bitcoin Core wallet.dat specification  (Read 273 times)
pbies (OP)
Full Member
***
Offline Offline

Activity: 297
Merit: 133



View Profile
April 17, 2022, 03:46:19 PM
Merited by Welsh (1), ABCbits (1)
 #1

Has anybody .NET/C# classes structure of Bitcoin Core wallet.dat that he could share?

BTC: bc1qmrexlspd24kevspp42uvjg7sjwm8xcf9w86h5k
ABCbits
Legendary
*
Offline Offline

Activity: 3066
Merit: 8090


Crypto Swap Exchange


View Profile
April 18, 2022, 10:33:44 AM
Merited by Welsh (3), NeuroticFish (2), pooya87 (2), BlackHatCoiner (1)
 #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.

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
pbies (OP)
Full Member
***
Offline Offline

Activity: 297
Merit: 133



View Profile
April 18, 2022, 03:41:46 PM
 #3


Thank you!

That's a very good program.

I can extend it to my needs.

BTC: bc1qmrexlspd24kevspp42uvjg7sjwm8xcf9w86h5k
pbies (OP)
Full Member
***
Offline Offline

Activity: 297
Merit: 133



View Profile
April 18, 2022, 06: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#.

BTC: bc1qmrexlspd24kevspp42uvjg7sjwm8xcf9w86h5k
pbies (OP)
Full Member
***
Offline Offline

Activity: 297
Merit: 133



View Profile
April 20, 2022, 06: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?

BTC: bc1qmrexlspd24kevspp42uvjg7sjwm8xcf9w86h5k
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3542
Merit: 6886


Just writing some code


View Profile WWW
April 20, 2022, 11:35:10 PM
Merited by Welsh (4), ABCbits (2), nc50lc (2), n0nce (1)
 #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".

pbies (OP)
Full Member
***
Offline Offline

Activity: 297
Merit: 133



View Profile
April 21, 2022, 06:30:01 PM
Last edit: April 21, 2022, 06:41:04 PM by pbies
 #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?

BTC: bc1qmrexlspd24kevspp42uvjg7sjwm8xcf9w86h5k
pbies (OP)
Full Member
***
Offline Offline

Activity: 297
Merit: 133



View Profile
April 23, 2022, 07: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...

BTC: bc1qmrexlspd24kevspp42uvjg7sjwm8xcf9w86h5k
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!