upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/db.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/db.h')
-rw-r--r--src/db.h22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/db.h b/src/db.h
index fee5a82..5bc94b1 100644
--- a/src/db.h
+++ b/src/db.h
@@ -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);
367bool WalletSQLiteRuntimeEraseRecord(const vector<unsigned char>& vchKey); 367bool WalletSQLiteRuntimeEraseRecord(const vector<unsigned char>& vchKey);
368bool WalletSQLiteRuntimeBeginTxn();
369bool WalletSQLiteRuntimeCommitTxn();
370void WalletSQLiteRuntimeRollbackTxn();
371bool WalletSQLiteRuntimeOpenReadOnly(const string& strPath, string& strErrorRet);
372bool 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)