diff options
| author | Bitflash <admin@bitflash.network> | 2026-08-18 15:48:17 -0300 |
|---|---|---|
| committer | Bitflash <admin@bitflash.network> | 2026-08-18 15:48:17 -0300 |
| commit | f3fb7ce6759ac98a7cc39d586fc2824982c74acd (patch) | |
| tree | 23e39a26b340324a7a33a115aded3b70b5332816 /src/db.h | |
| parent | beb5c1435a0d85b7b24d4d371933758ebed90907 (diff) | |
| parent | 84a60275569dca5d1fb12db38ce184caf7487ed6 (diff) | |
Merge pull request 'wallet: complete SQLite backend activation (encrypt, atomicity, one-shot commands)' (#61) from wallet-sqlite-encrypt into main
Diffstat (limited to 'src/db.h')
| -rw-r--r-- | src/db.h | 22 |
1 files changed, 20 insertions, 2 deletions
| @@ -365,6 +365,11 @@ bool WalletSQLiteRuntimeWriteRecord(const vector<unsigned char>& vchKey, | |||
| 365 | const vector<unsigned char>& vchValue, | 365 | const vector<unsigned char>& vchValue, |
| 366 | bool fOverwrite); | 366 | bool fOverwrite); |
| 367 | bool WalletSQLiteRuntimeEraseRecord(const vector<unsigned char>& vchKey); | 367 | bool WalletSQLiteRuntimeEraseRecord(const vector<unsigned char>& vchKey); |
| 368 | bool WalletSQLiteRuntimeBeginTxn(); | ||
| 369 | bool WalletSQLiteRuntimeCommitTxn(); | ||
| 370 | void WalletSQLiteRuntimeRollbackTxn(); | ||
| 371 | bool WalletSQLiteRuntimeOpenReadOnly(const string& strPath, string& strErrorRet); | ||
| 372 | bool WalletSQLiteRuntimeCheckpoint(string& strErrorRet); | ||
| 368 | 373 | ||
| 369 | 374 | ||
| 370 | 375 | ||
| @@ -531,8 +536,21 @@ public: | |||
| 531 | 536 | ||
| 532 | bool WriteHDMaster(const vector<unsigned char>& vchMaster, const vector<unsigned char>& vchChainCode) | 537 | bool WriteHDMaster(const vector<unsigned char>& vchMaster, const vector<unsigned char>& vchChainCode) |
| 533 | { | 538 | { |
| 534 | return WriteWalletRecord(string("hdmaster"), vchMaster) | 539 | // hdmaster and hdchaincode are halves of one seed: a wallet with one but |
| 535 | && WriteWalletRecord(string("hdchaincode"), vchChainCode); | 540 | // not the other is an incomplete HD wallet (-walletstoragecheck flags |
| 541 | // exactly that). Under the SQLite runtime write them in one transaction | ||
| 542 | // so a failure or crash between the two cannot leave that half-state. | ||
| 543 | // Berkeley DB keeps its existing per-write behaviour -- the bracket is a | ||
| 544 | // no-op there. | ||
| 545 | if (!WalletSQLiteRuntimeBeginTxn()) | ||
| 546 | return false; | ||
| 547 | if (!WriteWalletRecord(string("hdmaster"), vchMaster) || | ||
| 548 | !WriteWalletRecord(string("hdchaincode"), vchChainCode)) | ||
| 549 | { | ||
| 550 | WalletSQLiteRuntimeRollbackTxn(); | ||
| 551 | return false; | ||
| 552 | } | ||
| 553 | return WalletSQLiteRuntimeCommitTxn(); | ||
| 536 | } | 554 | } |
| 537 | 555 | ||
| 538 | bool WriteWalletMinVersion(int nVersion) | 556 | bool WriteWalletMinVersion(int nVersion) |