1

These two questions (1, 2) discuss what is in wallet.dat. Andrew Chow states in 2017 (when the database was still BDB and not sqlite):

The wallet.dat file contains your private keys, public keys, scripts (which correspond to addresses), key metadata (e.g. labels), and the transactions related to your wallet. If you have an HD wallet, it also includes the HD seed and and the derivation paths for each private key.

I also found a 2011 Bitcointalk post discussing using the bitkeys format for the first time where there were 4 classes of keys:

(1) Used keys, which have unredeemed transaction outputs linked to them (and thus contain funds) (2) Used keys, which only have redeemed transaction outputs linked to them (worthless, but the addresses may be used still by others) (3) Unused keys (whose corresponding addresses may have been published) (4) Reserve keys (whose corresponding addresses have typically never been divulged, but may have been divulged at the time the export is imported again)

I am trying to inspect the contents of wallet.dat using sqlite3. I've generated a (signet) Bitcoin address and sent some (signet) Bitcoin to this address. I cd into ./bitcoin/signet/wallets/insert_wallet_name. Then I open wallet.dat with sqlite3 (I have pre-installed sqlite3).

When bitcoind (-signet) is running I get the error message that the database is locked when I try a .dump.

PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
/**** ERROR: (5) database is locked *****/
ROLLBACK; -- due to errors

I initially assumed wallet.dat would only be locked when changes were being made to it e.g. it was updating to append a new transaction that was relevant to the wallet. Why does wallet.dat need to be locked permanently if bitcoind is running?

Then I stop bitcoind (./bitcoin-cli -signet stop)

I can now do a .dump on wallet.dat

PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE main(key BLOB PRIMARY KEY NOT NULL, value BLOB NOT NULL);
INSERT INTO main VALUES(X'0776657273696f6e',X'3cf70300');
INSERT INTO main VALUES(X'0a6d696e76657273696f6e',X'ac970200');
INSERT INTO main VALUES(X'1377616c6c657464657363726970746f726b657942acd6e8276af09714363d52c0b9cc0fe11e9754a1434dc946ae5cface386a072103f41276cb64db241c0db73aa721c18c9878c5425d03f3afe608988ef96796ad16',X'd63081d3020101042074f01c223562a336a90531c0bf75d3a68c3749675fda4d5047520e31f3651038a08185308182020101302c06072a8648ce3d0101022100fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f300604010004010704210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798022100fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141020101a12403220003f41276cb64db241c0db73aa721c18c9878c5425d03f3afe608988ef96796ad165aee6f1ffa219adaa51dbd256a15208a416e511b7e3940185ab86ca3947e664f');
INSERT INTO main VALUES(X'1577616c6c657464657363726970746f72636163686542acd6e8276af09714363d52c0b9cc0fe11e9754a1434dc946ae5cface386a0700000000',X'4a04a71ffc7b0000000048855f27d0303b9d670fdcf6b8f979db9c1298a7cb869b3b587ed18a25e1ab6903eabd3dde71174e1308de895cf5e5497b0e3c96a4613544ee4d8cda58258aa1ad');
INSERT INTO main VALUES(X'1777616c6c657464657363726970746f726c68636163686542acd6e8276af09714363d52c0b9cc0fe11e9754a1434dc946ae5cface386a0700000000',X'4a03f4318f8b800000004e8fb53fef11968a0b85695857eab14f96db62f63bf847a1c4a9bdbd09e69dff02a7b1be2f7be89d1d0f31536d5d9a31254a458c1873a7ddb37927b21bd3dc7b44');
INSERT INTO main VALUES(X'1161637469766565787465726e616c73706b00',X'42acd6e8276af09714363d52c0b9cc0fe11e9754a1434dc946ae5cface386a07');
INSERT INTO main VALUES(X'1377616c6c657464657363726970746f726b6579998efcbca89c9e9a166f185fc9f0290e1c5827fba40f3955dc8f14a6dac833c32103f41276cb64db241c0db73aa721c18c9878c5425d03f3afe608988ef96796ad16',X'd63081d3020101042074f01c223562a336a90531c0bf75d3a68c3749675fda4d5047520e31f3651038a08185308182020101302c06072a8648ce3d0101022100fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f300604010004010704210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798022100fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141020101a12403220003f41276cb64db241c0db73aa721c18c9878c5425d03f3afe608988ef96796ad165aee6f1ffa219adaa51dbd256a15208a416e511b7e3940185ab86ca3947e664f');
INSERT INTO main VALUES(X'1577616c6c657464657363726970746f726361636865998efcbca89c9e9a166f185fc9f0290e1c5827fba40f3955dc8f14a6dac833c300000000',X'4a0438c061be00000000ecfbb5e86f07637492fae9c970d2a626aa30f06adbeb98c00273bc2fc7619f8902b5d54090c152e636b5d0576dbacd25bafd08e6cb7e6d5701235c451e351e619a');
INSERT INTO main VALUES(X'1777616c6c657464657363726970746f726c686361636865998efcbca89c9e9a166f185fc9f0290e1c5827fba40f3955dc8f14a6dac833c300000000',X'4a037e36c8c080000000f3c0b8f779be115a89ae76d2b2d77598978c5a2816cf3c0ef981c779741df80f034b6f4a99c316475a2e5191dc1f09cc02fe3e9e958094135ecdc167d65e77d634');
INSERT INTO main VALUES(X'1161637469766565787465726e616c73706b01',X'998efcbca89c9e9a166f185fc9f0290e1c5827fba40f3955dc8f14a6dac833c3');
INSERT INTO main VALUES(X'1377616c6c657464657363726970746f726b65792b1b9b48fd74166775b6778d559f8d54d31343e120e6188d195f5c45ea185b642103f41276cb64db241c0db73aa721c18c9878c5425d03f3afe608988ef96796ad16',X'd63081d3020101042074f01c223562a336a90531c0bf75d3a68c3749675fda4d5047520e31f3651038a08185308182020101302c06072a8648ce3d0101022100fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f300604010004010704210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798022100fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141020101a12403220003f41276cb64db241c0db73aa721c18c9878c5425d03f3afe608988ef96796ad165aee6f1ffa219adaa51dbd256a15208a416e511b7e3940185ab86ca3947e664f');
INSERT INTO main VALUES(X'1577616c6c657464657363726970746f7263616368652b1b9b48fd74166775b6778d559f8d54d31343e120e6188d195f5c45ea185b6400000000',X'4a049cb9df5a00000000b552d1c36ac23c78a730608104693b7915694e5ab03ff34f8d8d706ee73ec7e00285d14224e669b80f6f4149705f8dbc508c29c4dbed94a5ee2c96045c32f0632b');
INSERT INTO main VALUES(X'1777616c6c657464657363726970746f726c6863616368652b1b9b48fd74166775b6778d559f8d54d31343e120e6188d195f5c45ea185b6400000000',X'4a03a4c293f9800000004317022d155cbb10052ff5786e89e5c196f4a1a57bdfdef9511c5507c78764d403b71bc893e32be5177635fd964c70bab9edb84c2240228153010946553a18ad27');
INSERT INTO main VALUES(X'1161637469766565787465726e616c73706b02',X'2b1b9b48fd74166775b6778d559f8d54d31343e120e6188d195f5c45ea185b64');
INSERT INTO main VALUES(X'1377616c6c657464657363726970746f726b6579dfa720e29640a23d214c9d47582725e4e3cb71b54ae9c176e34cbd82b92ab7d32103f41276cb64db241c0db73aa721c18c9878c5425d03f3afe608988ef96796ad16',X'd63081d3020101042074f01c223562a336a90531c0bf75d3a68c3749675fda4d5047520e31f3651038a08185308182020101302c06072a8648ce3d0101022100fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f300604010004010704210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798022100fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141020101a12403220003f41276cb64db241c0db73aa721c18c9878c5425d03f3afe608988ef96796ad165aee6f1ffa219adaa51dbd256a15208a416e511b7e3940185ab86ca3947e664f');
INSERT INTO main VALUES(X'1577616c6c657464657363726970746f726361636865dfa720e29640a23d214c9d47582725e4e3cb71b54ae9c176e34cbd82b92ab7d300000000',X'4a04032caab500000000d10bc88cb19ac535d760acb590fa6ce507e30f3c08d29cac208d3a9ace855c04030c3d3220cf2e2103cb84f985c7c9b39d5eb59ec898bcc40eb0638a0345579d81');
INSERT INTO main VALUES(X'1777616c6c657464657363726970746f726c686361636865dfa720e29640a23d214c9d47582725e4e3cb71b54ae9c176e34cbd82b92ab7d300000000',X'4a03f70b175e80000000e3069525a4804e1a9d49bdac616a69b60b6be027b3f56a0ff8591687b455c530035ea0a5fa512f2eabd38a435f69a46e29bd207307700f47e97b69a8ed82066105');
INSERT INTO main VALUES(X'1161637469766565787465726e616c73706b03',X'dfa720e29640a23d214c9d47582725e4e3cb71b54ae9c176e34cbd82b92ab7d3');
INSERT INTO main VALUES(X'1377616c6c657464657363726970746f726b65793e8e6fe5fb928e0578c5287c7f5f1cedf633a6bb0bf8c24584d42b6f243bffae2103f41276cb64db241c0db73aa721c18c9878c5425d03f3afe608988ef96796ad16',X'd63081d3020101042074f01c223562a336a90531c0bf75d3a68c3749675fda4d5047520e31f3651038a08185308182020101302c06072a8648ce3d0101022100fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f300604010004010704210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798022100fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141020101a12403220003f41276cb64db241c0db73aa721c18c9878c5425d03f3afe608988ef96796ad165aee6f1ffa219adaa51dbd256a15208a416e511b7e3940185ab86ca3947e664f');
INSERT INTO main VALUES(X'1577616c6c657464657363726970746f7263616368653e8e6fe5fb928e0578c5287c7f5f1cedf633a6bb0bf8c24584d42b6f243bffae00000000',X'4a04a71ffc7b00000001fa40dc9524fd202c8c9581392d91eea09eb0b6ef79333582d78f0ba57ce1ede4036133839bc4ec08d40d7fde8eaa27dfd28b5912bd960a4a32cc1f0af758fe7d32');
INSERT INTO main VALUES(X'1777616c6c657464657363726970746f726c6863616368653e8e6fe5fb928e0578c5287c7f5f1cedf633a6bb0bf8c24584d42b6f243bffae00000000',X'4a03f4318f8b800000004e8fb53fef11968a0b85695857eab14f96db62f63bf847a1c4a9bdbd09e69dff02a7b1be2f7be89d1d0f31536d5d9a31254a458c1873a7ddb37927b21bd3dc7b44');
INSERT INTO main VALUES(X'11616374697665696e7465726e616c73706b00',X'3e8e6fe5fb928e0578c5287c7f5f1cedf633a6bb0bf8c24584d42b6f243bffae');
INSERT INTO main VALUES(X'1377616c6c657464657363726970746f726b6579d05dd81a6c47fca61e3c361c06268406b5ac627e32f9e01f7a17ecbb5ed237372103f41276cb64db241c0db73aa721c18c9878c5425d03f3afe608988ef96796ad16',X'd63081d3020101042074f01c223562a336a90531c0bf75d3a68c3749675fda4d5047520e31f3651038a08185308182020101302c06072a8648ce3d0101022100fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f300604010004010704210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798022100fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141020101a12403220003f41276cb64db241c0db73aa721c18c9878c5425d03f3afe608988ef96796ad165aee6f1ffa219adaa51dbd256a15208a416e511b7e3940185ab86ca3947e664f');
INSERT INTO main VALUES(X'1577616c6c657464657363726970746f726361636865d05dd81a6c47fca61e3c361c06268406b5ac627e32f9e01f7a17ecbb5ed2373700000000',X'4a0438c061be000000016b6acfd8ecfe4913307fc51a174be60ad505231bc8ea7a21184377e9feecba67024df1fcddacbe9a87640d9e75dcb871c4aa9891d038a9af294415d2ade6f10a67');
INSERT INTO main VALUES(X'1777616c6c657464657363726970746f726c686361636865d05dd81a6c47fca61e3c361c06268406b5ac627e32f9e01f7a17ecbb5ed2373700000000',X'4a037e36c8c080000000f3c0b8f779be115a89ae76d2b2d77598978c5a2816cf3c0ef981c779741df80f034b6f4a99c316475a2e5191dc1f09cc02fe3e9e958094135ecdc167d65e77d634');
INSERT INTO main VALUES(X'11616374697665696e7465726e616c73706b01',X'd05dd81a6c47fca61e3c361c06268406b5ac627e32f9e01f7a17ecbb5ed23737');
INSERT INTO main VALUES(X'1377616c6c657464657363726970746f726b6579c56da0ec8d553443e27cf2439fd158b8aed74e22606b55476dfc9ea4c5ea64742103f41276cb64db241c0db73aa721c18c9878c5425d03f3afe608988ef96796ad16',X'd63081d3020101042074f01c223562a336a90531c0bf75d3a68c3749675fda4d5047520e31f3651038a08185308182020101302c06072a8648ce3d0101022100fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f300604010004010704210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798022100fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141020101a12403220003f41276cb64db241c0db73aa721c18c9878c5425d03f3afe608988ef96796ad165aee6f1ffa219adaa51dbd256a15208a416e511b7e3940185ab86ca3947e664f');
INSERT INTO main VALUES(X'1577616c6c657464657363726970746f726361636865c56da0ec8d553443e27cf2439fd158b8aed74e22606b55476dfc9ea4c5ea647400000000',X'4a049cb9df5a0000000122601970b9ba136689c5f57eae67b04d5212bff3cda47da08d4e9830ae25eac1039ee257e4d1d60d2feca52ae5da6e5747d2d58297d7ce4d47501c72f1170e16b2');
INSERT INTO main VALUES(X'1777616c6c657464657363726970746f726c686361636865c56da0ec8d553443e27cf2439fd158b8aed74e22606b55476dfc9ea4c5ea647400000000',X'4a03a4c293f9800000004317022d155cbb10052ff5786e89e5c196f4a1a57bdfdef9511c5507c78764d403b71bc893e32be5177635fd964c70bab9edb84c2240228153010946553a18ad27');
INSERT INTO main VALUES(X'11616374697665696e7465726e616c73706b02',X'c56da0ec8d553443e27cf2439fd158b8aed74e22606b55476dfc9ea4c5ea6474');
INSERT INTO main VALUES(X'1377616c6c657464657363726970746f726b65792cf50eb58604c5e8fc815855e9b1c94f1ed98e0923e8479ed68d30dfcf445f392103f41276cb64db241c0db73aa721c18c9878c5425d03f3afe608988ef96796ad16',X'd63081d3020101042074f01c223562a336a90531c0bf75d3a68c3749675fda4d5047520e31f3651038a08185308182020101302c06072a8648ce3d0101022100fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f300604010004010704210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798022100fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141020101a12403220003f41276cb64db241c0db73aa721c18c9878c5425d03f3afe608988ef96796ad165aee6f1ffa219adaa51dbd256a15208a416e511b7e3940185ab86ca3947e664f');
INSERT INTO main VALUES(X'1577616c6c657464657363726970746f7263616368652cf50eb58604c5e8fc815855e9b1c94f1ed98e0923e8479ed68d30dfcf445f3900000000',X'4a04032caab500000001291c53f60dd0f14781b11b650a1a4903e93e3e357163a64620e21f946c7d26ee034250539a23c870d479ac7e51b68c25c836e1205be06230ea3ecc06f89ee4fb9a');
INSERT INTO main VALUES(X'1777616c6c657464657363726970746f726c6863616368652cf50eb58604c5e8fc815855e9b1c94f1ed98e0923e8479ed68d30dfcf445f3900000000',X'4a03f70b175e80000000e3069525a4804e1a9d49bdac616a69b60b6be027b3f56a0ff8591687b455c530035ea0a5fa512f2eabd38a435f69a46e29bd207307700f47e97b69a8ed82066105');
INSERT INTO main VALUES(X'05666c616773',X'0000000004000000');
INSERT INTO main VALUES(X'11616374697665696e7465726e616c73706b03',X'2cf50eb58604c5e8fc815855e9b1c94f1ed98e0923e8479ed68d30dfcf445f39');
INSERT INTO main VALUES(X'1077616c6c657464657363726970746f7242acd6e8276af09714363d52c0b9cc0fe11e9754a1434dc946ae5cface386a07',X'8b706b68287470756244364e7a56626b7259685a34586e426b616a31614a6272674a64623567537545517972717138477562385244564c334a6d3443487471347a664d4e3278654c515158715348425354433966706d58505448586171524d5477555879446e7436574c42676a727365636472382f3434682f31682f30682f302f2a292368346c6370647878537bcb64000000000000000000000000e8030000');
INSERT INTO main VALUES(X'1077616c6c657464657363726970746f723e8e6fe5fb928e0578c5287c7f5f1cedf633a6bb0bf8c24584d42b6f243bffae',X'8b706b68287470756244364e7a56626b7259685a34586e426b616a31614a6272674a64623567537545517972717138477562385244564c334a6d3443487471347a664d4e3278654c515158715348425354433966706d58505448586171524d5477555879446e7436574c42676a727365636472382f3434682f31682f30682f312f2a29237870366575636b37547bcb64000000000000000000000000e8030000');
INSERT INTO main VALUES(X'1077616c6c657464657363726970746f722cf50eb58604c5e8fc815855e9b1c94f1ed98e0923e8479ed68d30dfcf445f39',X'8a7472287470756244364e7a56626b7259685a34586e426b616a31614a6272674a64623567537545517972717138477562385244564c334a6d3443487471347a664d4e3278654c515158715348425354433966706d58505448586171524d5477555879446e7436574c42676a727365636472382f3836682f31682f30682f312f2a292338747a70786c3833547bcb64000000000000000000000000e8030000');
INSERT INTO main VALUES(X'1077616c6c657464657363726970746f72d05dd81a6c47fca61e3c361c06268406b5ac627e32f9e01f7a17ecbb5ed23737',X'9073682877706b68287470756244364e7a56626b7259685a34586e426b616a31614a6272674a64623567537545517972717138477562385244564c334a6d3443487471347a664d4e3278654c515158715348425354433966706d58505448586171524d5477555879446e7436574c42676a727365636472382f3439682f31682f30682f312f2a292923376e36306d307a66547bcb64000000000000000000000000e8030000');
INSERT INTO main VALUES(X'1077616c6c657464657363726970746f72998efcbca89c9e9a166f185fc9f0290e1c5827fba40f3955dc8f14a6dac833c3',X'9073682877706b68287470756244364e7a56626b7259685a34586e426b616a31614a6272674a64623567537545517972717138477562385244564c334a6d3443487471347a664d4e3278654c515158715348425354433966706d58505448586171524d5477555879446e7436574c42676a727365636472382f3439682f31682f30682f302f2a29292363736a32717a6661537bcb64000000000000000000000000e8030000');
INSERT INTO main VALUES(X'07707572706f73652a74623171786a6e71756a3974703036743374656361747a717876796c703667306538326d326b61386c6c',X'0772656365697665');
INSERT INTO main VALUES(X'046e616d652a74623171786a6e71756a3974703036743374656361747a717876796c703667306538326d326b61386c6c',X'00');
INSERT INTO main VALUES(X'07707572706f73653e746231706c78707764343432716d376d68753338676a39396334307761716174356864386b75716a797534796a3273656c6b653773756e716b3072646c67',X'0772656365697665');
INSERT INTO main VALUES(X'046e616d653e746231706c78707764343432716d376d68753338676a39396334307761716174356864386b75716a797534796a3273656c6b653773756e716b3072646c67',X'00');
INSERT INTO main VALUES(X'1077616c6c657464657363726970746f72dfa720e29640a23d214c9d47582725e4e3cb71b54ae9c176e34cbd82b92ab7d3',X'8a7472287470756244364e7a56626b7259685a34586e426b616a31614a6272674a64623567537545517972717138477562385244564c334a6d3443487471347a664d4e3278654c515158715348425354433966706d58505448586171524d5477555879446e7436574c42676a727365636472382f3836682f31682f30682f302f2a29236b6c38716d326866537bcb64000000000100000000000000e9030000');
INSERT INTO main VALUES(X'0274786b746dca2ac39af4038a94a9c166771b9e17c9d520fdfc17172f778582a668e1',X'020000000001013256a3b153e66a96598e041392fd1907e66b4ad447eec90e3867e2508334d3900000000000fdffffff03e538900b1b000000160014447fde1e37d97255b5821d2dee816e8f18f6bac99b9f0c0000000000225120f982e6d6aa06fdbbf227448a5c55eee83aba5da7b7012272a492a19fdb3e872600000000000000000f6a0d6c6561726e20426974636f696e0247304402206d29cea2d22173f4dcab743c7a9e8345d38c45211e2f418028c6132cb1c545ad02205d07f5fc7373200eb0a4a342bf464d2e76ada26056fd706fe6936dbc1d4aca5f012102a8c3fa3dbc022ca7c9a2214c5e673833317b3cff37c0fc170fc347f1a2f6b6e200000000db5acb04e903ed8470b0b14c8669b83cca8e78dade69343323c2f15c1c010000000100000000030b66726f6d6163636f756e7400016e01300974696d65736d6172740a313639313035373530380000000000647dcb640000');
INSERT INTO main VALUES(X'1077616c6c657464657363726970746f722b1b9b48fd74166775b6778d559f8d54d31343e120e6188d195f5c45ea185b64',X'8c77706b68287470756244364e7a56626b7259685a34586e426b616a31614a6272674a64623567537545517972717138477562385244564c334a6d3443487471347a664d4e3278654c515158715348425354433966706d58505448586171524d5477555879446e7436574c42676a727365636472382f3834682f31682f30682f302f2a29233339773973306a34537bcb64000000000200000000000000e9030000');
INSERT INTO main VALUES(X'07707572706f73652a74623171766b6470757339326d366b3037386576687074716c6c336d7573657438397566367036707a65',X'0772656365697665');
INSERT INTO main VALUES(X'046e616d652a74623171766b6470757339326d366b3037386576687074716c6c336d7573657438397566367036707a65',X'00');
INSERT INTO main VALUES(X'0c6f72646572706f736e657874',X'0200000000000000');
INSERT INTO main VALUES(X'1077616c6c657464657363726970746f72c56da0ec8d553443e27cf2439fd158b8aed74e22606b55476dfc9ea4c5ea6474',X'8c77706b68287470756244364e7a56626b7259685a34586e426b616a31614a6272674a64623567537545517972717138477562385244564c334a6d3443487471347a664d4e3278654c515158715348425354433966706d58505448586171524d5477555879446e7436574c42676a727365636472382f3834682f31682f30682f312f2a29237133747964367a64547bcb64000000000100000000000000e9030000');
INSERT INTO main VALUES(X'0274788a42ba28ebea6a32f21698ae39dfc0cf88c145ee8d25c6c87a231f1182c28445',X'020000000001016b746dca2ac39af4038a94a9c166771b9e17c9d520fdfc17172f778582a668e10100000000fdffffff02390b080000000000160014fc8dcae6a94955d00b49166ee72d9b066da41f71e093040000000000160014447fde1e37d97255b5821d2dee816e8f18f6bac90140059be0aba5788132c56d1066808dafbc8109c443bca304b2845a837ec696e620b0e597fdaf2f78ef8b0661d56fbec860a2af96ca5cf040adc11b348a3262e7ef5b5b0200d850a0ace4ecb413d999684ef03e8163ab60e9d3cffb471cddcc0b3e2f010000000300000000030b66726f6d6163636f756e7400016e01310974696d65736d6172740a3136393130363133333800010000005a8ccb640100');
INSERT INTO main VALUES(X'0962657374626c6f636b',X'3cf7030000');
INSERT INTO main VALUES(X'1262657374626c6f636b5f6e6f6d65726b6c65',X'3cf703001ddd15adef25236aa1977490ce19a6a7e534fd97d193bcbebb8bfa2c88bf000000131d64d114facb8f46b68e16fe12ebb4d60150731cfac80756246794460000007af81238abfd623040d8634443b867594e8e75fb2975b63827b5ec41bc00000002047e9106550a8e9539eb38d71442564e9fcf15616a4127479c79beb5000000db037021175293d1508c23c48dc54cb72d7e8e91807b0c8dc79e06fd0601000045bdc5e2b216703e00ddaf69dbdc59a6ffa8f32b2467c1670bd9727f05000000504e7ba80a6e63aae65d95b0f0ab14fcc239e426b37c5f79525494fc6600000000b303ab247eb9c703a51e38b66e6a61e85953a2e0fc02d175d4dd43e8000000300272effaa174f5e3749eca784c9a813af18f03499cb360b3bf34d5cb0000004edcbae37032eacb983c8f9b0bcca15d73139baa2b662a1f892447de88000000a1c55728fcd56898069614b8869b708571fb733ef27625516567d769170100000f0786ccd8d64a001cd87a97dbfd0ca470a4382c932480102ca4920a430000001337f951dd3895cdff5668a5b967e0706cb11c51d04226cc758eb22b22000000cc4a08855bdb2bd633bb1985b9d00e4af8111c5db42cb7ef5ffb6e751e010000793fb041c5b0ca50969819da43fdc409c7c232b17de13eee0ea0c12fd1000000ec226da0ab29c00036e0a5e9375625f4d26c8ce3900ecde5a6b1102a03010000a7956b1c6ed68eec76b46c17e5a4bdc4c702fe8f2e2c1c4f6950e1ff35000000df69bfaa2d50536a7247b1954c2de1142345068302946a6f9c0bf53ac800000008d855cde03522d453c3824da788c385bc710630e664df874caeaa2ba80000008ebc7677430a7118616d94608aabe2d288a5776724a705af7eaa34910600000088728ff409de829256fa94089a042254bb3488294709a49037b8e07d18000000162d72901b16c40d6520766fd0d301da1d944036a68413d7e1a2f101040100007ec427aa72cc655d18cfc723ba5b43b841d2d908b961ea967b9df63f010100005274107a2ae7f427661f034d9d1eb601bddd6267e5cc5c02c4a459d470000000f022e96318bbe6a13c4a924409523b7c589838b718e9a4215378db8bef00000070a46af62689bab6afbf4134b6483c4f26b8e1a55d73d26934ff5cd9020100006ac1f7a814d77735cf4b0a5d60ff83396d587efe7425ea6f18cc38cd970000007e16f2b8ef7ae47a17aa62318bc597bd5c4b931bbe456bb2d5f89c4030000000f61eee3b63a380a477a063af32b2bbc97c9ff9f01f2c4225e973988108000000');
COMMIT;

I'm not sure what is going on here or how to proceed. My guess is it is generating HD child pubkeys and the transaction that sent (signet) Bitcoin to this wallet must be in here somewhere. I'll look at sqlite.cpp and dig around in this dump for data I was expecting to see but any pointers on where to start and what I might be misunderstanding would be appreciated.

1 Answer 1

4

Why does wallet.dat need to be locked permanently if bitcoind is running?

bitcoind does not retrieve data from disk when it is running. It only retrieves data on loading, and will occasionally write to the database. If something were to modify the database while it were running, then the state on disk would mismatch the running state which would result in corruption and possible loss of funds. By locking the database when bitcoind has that wallet loaded, it can ensure that nothing else is going to modify the database and thus have better guarantees that the state on disk matches the state in memory.


Although SQLite is a relational database, Bitcoin Core only uses it as a key-value store like BDB. It uses a single table with two columns, one for the key, the other for the value. Each row is then formatted in the same way that key-value records were formatted for BDB. The parsing of each record is shared for both. You can find the code for that in src/wallet/walletdb.cpp.

3
  • Thanks for this Andrew. How can I inspect the contents of the wallet.dat then? dumpwallet is only compatible with legacy wallets? Commented Aug 9, 2023 at 10:32
  • 1
    Your sqlite command is inspecting the contents of the wallet.dat, just without any interpretation of the records as loading the wallet is. It would be more helpful if you could explain what you are trying to do that requires inspecting the wallet at such a low level. Note that dumpwallet does not actually dump the contents of the wallet.dat nor provide actual inspection of a wallet.dat's contents.
    – Ava Chow
    Commented Aug 9, 2023 at 14:24
  • Just digging around trying to understand how it works from a learning/educational perspective. If it isn't meant to be inspected like this that's fine. I just assumed (perhaps wrongly) that any database including this one could be inspected or at least exported and be made human readable? Essentially view that single table with two columns using some software? Commented Aug 10, 2023 at 9:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.