Bitcoin Forum
December 14, 2024, 12:01:27 AM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: whats happening in wallet.dat  (Read 2304 times)
donking (OP)
Jr. Member
*
Offline Offline

Activity: 38
Merit: 2



View Profile
March 30, 2013, 12:19:16 AM
Merited by ABCbits (2)
 #1

I am just wondering what is happening in the wallet.dat file in the standard bitcoin client.

Can anybody explain the high level functionality in a way a layman can understand?

First I thought the file was just a list of private keys. But it does not seem to be the case.

I see in the log:
Flushed wallet.dat 408ms
AddToWallet xxxxxxxx  new

Why does it need to write anything to the file when
it is starting up (rescanning). I thought it was only needed to write to wallet.dat when generating a new address.



Don.
deepceleron
Legendary
*
Offline Offline

Activity: 1512
Merit: 1036



View Profile WWW
March 30, 2013, 07:47:24 AM
Merited by ABCbits (9)
 #2

The Bitcoin-qt/bitcoind wallet.dat file is a BerkeleyDB database. It contains several different data stores. Here's a dump of a new wallet (with just two reserve addresses for future use)


Code:
{
    "acc": "",
    "bestblock": "000000000000036011761a18097da44837e45d2997473cdbb5073900e7e6e7ac",
    "defaultkey": "1ynUnWB9JJ9nDzS8sWDA2Dm3oDuMW2zHp",
    "keys": [
        {
            "addr": "1H5YWGN4wxSMQVkxeNvt7143Tb2sx5btcF",
            "hexsec": "5f73b6e3433d3dcc0ff581a972e675c6b90b2400a5172fe2e41d38b7cdb741a0",
            "reserve": 1,
            "sec": "5JYKmuHP165m8aRbkuQbtotV4rzfbNTSSVmoNqjBqPJgkvzaSxd"
        },
        {
            "addr": "18pXbTAXH8yQ3G7YJtebgDjcMBP6ecmuJK",
            "hexsec": "df8b1541844beace15abc9c60dac6ecbb55e2119e7f134abe4e5d2da862d0fa0",
            "reserve": 1,
            "sec": "5KWjhFuqmtn5YGvErQ9prWcjCKGixZXeskQtR8WTnyTkAS8LdjM"
        },
        {
            "addr": "1ynUnWB9JJ9nDzS8sWDA2Dm3oDuMW2zHp",
            "hexsec": "f60a32974e7dc594ec5fa68b8e240e379e1cb2e3df251ddc57d85c4489f846a0",
            "label": "",
            "sec": "5KgeLcBKufAUium7DGtbbe1mXYFQsvXE2GAuweRjQ7QMwxhqxiU"
        }
    ],
    "minversion": "unsupported",
    "names": {
        "1ynUnWB9JJ9nDzS8sWDA2Dm3oDuMW2zHp": ""
    },
    "orderposnext": "unsupported",
    "pool": [
        {
            "addr": "18pXbTAXH8yQ3G7YJtebgDjcMBP6ecmuJK",
            "n": 2,
            "nTime": 1364628317
        },
        {
            "addr": "1H5YWGN4wxSMQVkxeNvt7143Tb2sx5btcF",
            "n": 3,
            "nTime": 1364628317
        }
    ],
    "settings": {
        "addrIncoming": "0.0.0.0:0"
    },
    "tx": [],
    "version": 80000
}

An analysis of some of the things in the wallet - we see that every time a new block is received, data is written to the wallet:


   "acc": "",
Assign account name to address - rarely used
 
   "bestblock": "000000000000036011761a18097da44837e45d2997473cdbb5073900e7e6e7ac",
The last block hash seen on the network, so wallet knows where to start scanning for new payments

   "defaultkey": "1ynUnWB9JJ9nDzS8sWDA2Dm3oDuMW2zHp",
The key that is offered as "your receiving address" (used to automatically change in Bitcoin < 0.4)

   "keys": [ ...
The store of public/private keys. "reserve": 1 means the address is a reserve key

   "minversion": "unsupported",
Option if future wallets are backwards-incompatible

   "names": { ...
Labels applied to addresses/address book

   "orderposnext": "unsupported",
Database position counter

   "pool": [ ...
List of reserve pool addresses in order they should be used

   "settings": {
Most user settings have been moved to the registry on Windows.
 
   "tx": [], ...
A list of all transactions sent and received/seen on the network relating to wallet addresses

   "version": 80000
Bitcoin version that created wallet/current version (if upgraded by software)


Also from http://bitcoin.stackexchange.com/questions/3173/what-information-does-a-wallet-contain

Quote
   name - an address book name
    tx - a transaction
    acentry - an accounting entry
    key - a pair of public and private keys
    mkey - a master key
    ckey - an encrypted key
    defaultkey - the default receiving address' key
    pool - a keypool entry
    version - the version of the software that wrote this wallet
    minversion - the earliest version of the software that can read this wallet
    cscript - a script
    bestblock - a pointer to the end of the best blockchain seen
    wkey - a private key (no longer used)
    setting - used to store user interface settings (no longer used, except to hold an invalid setting to stop pre-0.4.0 versions of the client which don't understand minversion from loading wallets that are too new for them)
jackjack
Legendary
*
Offline Offline

Activity: 1176
Merit: 1280


May Bitcoin be touched by his Noodly Appendage


View Profile
March 30, 2013, 09:58:36 AM
 #3

Yep, as the quote says there is 'mkey' that contains the info about wallet encryption: salt, number of rounds, encrypted masterkey, crypting method and a couple of more things
Never saw cscript

Own address: 19QkqAza7BHFTuoz9N8UQkryP4E9jHo4N3 - Pywallet support: 1AQDfx22pKGgXnUZFL1e4UKos3QqvRzNh5 - Bitcointalk++ script support: 1Pxeccscj1ygseTdSV1qUqQCanp2B2NMM2
Pywallet: instructions. Encrypted wallet support, export/import keys/addresses, backup wallets, export/import CSV data from/into wallet, merge wallets, delete/import addresses and transactions, recover altcoins sent to bitcoin addresses, sign/verify messages and files with Bitcoin addresses, recover deleted wallets, etc.
MikeJ_NpC
Member
**
Offline Offline

Activity: 107
Merit: 10

if you want to lie *cough*use your data; not mine.


View Profile
March 02, 2022, 04:09:39 PM
 #4

This seems to be the only thread about this issue... i have that entry.
How can i verify its transferred it .. im somewhat lost about it.. does it need to be node verified.  I assume so but its throwing a mismatch between  db47 needed and db48 what it is now.
Can someone explain this as i think mine is stuck.  - the resolution would be to obtain the db47 blockchain and let it finish i presume. There is no other way from what ive seen which is nothing.  lol kinda..

If Karma is a bitch, then god is a woman. I ask to know, not to be screwed or hear trite excuses (after the fact) which a 3rd grader could do better on. If you give your word, keep it atleast..
MikeJ_NpC
Member
**
Offline Offline

Activity: 107
Merit: 10

if you want to lie *cough*use your data; not mine.


View Profile
March 04, 2022, 10:05:35 AM
 #5

okay... so is this normal? i just did a internal wallet to wallet xfer and seems like everything went okay ...  but then when i loaded the following time i saw the accounting entry..
The key is present and all otherwise it wouldn't of approved he push...  it seems stuck to me as it has not reflected yet and i see it want 4.7db citing a mismatch on 4.8

Im out of my element on this,  how can i have it complete what is in a accepted paused state ... i dont have the slightest idea and cannot find 4.7 anywhere
so if someone knows how to resolve it please let me know.....    Here is some of the outputs censored.

data was written to the wallet.. accepted was indicated... did a subtract but then froze after that citing an mismatch or hell if i know..
Can someone help me and ill tip them ...


Move '2nd wallet' 200000000000 (other: '1st wallet, time: Wed Feb 23 18:33:10 2022, entry 2)  ☺️☺️n☺️8
Move '1st wallet' -200000000000 (other: '2ndwallet', time: Wed Feb 23 18:33:10 2022, entry 1)  ☺️☺️n☺️7

account" : "1st intenral wallet",
"category" : "move",
"time" : 1645669990,
"amount" : -2000.00000000,
"otheraccount" : "2nd internal wallet",
"comment" : ""
},
{
"account" : "2nd internal wallet",
"category" : "move",
"time" : 1645669990,
"amount" : 2000.00000,
"otheraccount" : "1st internal wallett",
"comment" : ""
}




NotifyAddressBookChanged 2nd internal wallett isMine=0 status=0
Flushing wallet.dat
Flushed wallet.dat 76ms
AddToWallet 8645b5eb1f  
NotifyTransactionChanged 8645b5eb1f8fda4c803d463ea4657a90b549b03d3274dd24e86dd459d91efe73 status=1
received block 0000000000000d33038f
SetBestChain: new best=0000000000000d33038f  height=155626  work=178118820252315657527  date=12/01/11 23:26:19
ProcessBlock: ACCEPTED
received block 0000000000000e14c5da
updateWallet 8645b5eb1f8fda4c803d463ea4657a90b549b03d3274dd24e86dd459d91efe73 1
   inWallet=1 inModel=1 Index=3-4 showTransaction=1 derivedStatus=1




Then i pulled it again and saw this


"acentry": [
        "1st internal wallet",
        -200000000000,
        "2nd internal wallet",
        "Wed Feb 23 18:33:10 2022",
        1,
        "\u0000\u0001\u0001n\u00017"
    ],
    "bestblock": "00000000000000480ad86800491315535a4a71bbe51b5d595b7e7e1cd6851987",




Did i do something wrong? ..



The Bitcoin-qt/bitcoind wallet.dat file is a BerkeleyDB database. It contains several different data stores. Here's a dump of a new wallet (with just two reserve addresses for future use)


Code:
{
    "acc": "",
    "bestblock": "000000000000036011761a18097da44837e45d2997473cdbb5073900e7e6e7ac",
    "defaultkey": "1ynUnWB9JJ9nDzS8sWDA2Dm3oDuMW2zHp",
    "keys": [
        {
            "addr": "1H5YWGN4wxSMQVkxeNvt7143Tb2sx5btcF",
            "hexsec": "5f73b6e3433d3dcc0ff581a972e675c6b90b2400a5172fe2e41d38b7cdb741a0",
            "reserve": 1,
            "sec": "5JYKmuHP165m8aRbkuQbtotV4rzfbNTSSVmoNqjBqPJgkvzaSxd"
        },
        {
            "addr": "18pXbTAXH8yQ3G7YJtebgDjcMBP6ecmuJK",
            "hexsec": "df8b1541844beace15abc9c60dac6ecbb55e2119e7f134abe4e5d2da862d0fa0",
            "reserve": 1,
            "sec": "5KWjhFuqmtn5YGvErQ9prWcjCKGixZXeskQtR8WTnyTkAS8LdjM"
        },
        {
            "addr": "1ynUnWB9JJ9nDzS8sWDA2Dm3oDuMW2zHp",
            "hexsec": "f60a32974e7dc594ec5fa68b8e240e379e1cb2e3df251ddc57d85c4489f846a0",
            "label": "",
            "sec": "5KgeLcBKufAUium7DGtbbe1mXYFQsvXE2GAuweRjQ7QMwxhqxiU"
        }
    ],
    "minversion": "unsupported",
    "names": {
        "1ynUnWB9JJ9nDzS8sWDA2Dm3oDuMW2zHp": ""
    },
    "orderposnext": "unsupported",
    "pool": [
        {
            "addr": "18pXbTAXH8yQ3G7YJtebgDjcMBP6ecmuJK",
            "n": 2,
            "nTime": 1364628317
        },
        {
            "addr": "1H5YWGN4wxSMQVkxeNvt7143Tb2sx5btcF",
            "n": 3,
            "nTime": 1364628317
        }
    ],
    "settings": {
        "addrIncoming": "0.0.0.0:0"
    },
    "tx": [],
    "version": 80000
}

An analysis of some of the things in the wallet - we see that every time a new block is received, data is written to the wallet:


   "acc": "",
Assign account name to address - rarely used
 
   "bestblock": "000000000000036011761a18097da44837e45d2997473cdbb5073900e7e6e7ac",
The last block hash seen on the network, so wallet knows where to start scanning for new payments

   "defaultkey": "1ynUnWB9JJ9nDzS8sWDA2Dm3oDuMW2zHp",
The key that is offered as "your receiving address" (used to automatically change in Bitcoin < 0.4)

   "keys": [ ...
The store of public/private keys. "reserve": 1 means the address is a reserve key

   "minversion": "unsupported",
Option if future wallets are backwards-incompatible

   "names": { ...
Labels applied to addresses/address book

   "orderposnext": "unsupported",
Database position counter

   "pool": [ ...
List of reserve pool addresses in order they should be used

   "settings": {
Most user settings have been moved to the registry on Windows.
 
   "tx": [], ...
A list of all transactions sent and received/seen on the network relating to wallet addresses

   "version": 80000
Bitcoin version that created wallet/current version (if upgraded by software)


Also from http://bitcoin.stackexchange.com/questions/3173/what-information-does-a-wallet-contain

Quote
   name - an address book name
    tx - a transaction
    acentry - an accounting entry
    key - a pair of public and private keys
    mkey - a master key
    ckey - an encrypted key
    defaultkey - the default receiving address' key
    pool - a keypool entry
    version - the version of the software that wrote this wallet
    minversion - the earliest version of the software that can read this wallet
    cscript - a script
    bestblock - a pointer to the end of the best blockchain seen
    wkey - a private key (no longer used)
    setting - used to store user interface settings (no longer used, except to hold an invalid setting to stop pre-0.4.0 versions of the client which don't understand minversion from loading wallets that are too new for them)


If Karma is a bitch, then god is a woman. I ask to know, not to be screwed or hear trite excuses (after the fact) which a 3rd grader could do better on. If you give your word, keep it atleast..
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!