upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/main_gui.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main_gui.cpp')
-rw-r--r--src/main_gui.cpp50
1 files changed, 44 insertions, 6 deletions
diff --git a/src/main_gui.cpp b/src/main_gui.cpp
index 4be4995..af6053f 100644
--- a/src/main_gui.cpp
+++ b/src/main_gui.cpp
@@ -524,19 +524,57 @@ int main(int argc, char* argv[])
524 // explain wallet.dat states that the normal wallet loader may refuse. 524 // explain wallet.dat states that the normal wallet loader may refuse.
525 string strWalletStorageAuditJson = 525 string strWalletStorageAuditJson =
526 argval2(argc, argv, "/walletstorageauditjson", "-walletstorageauditjson"); 526 argval2(argc, argv, "/walletstorageauditjson", "-walletstorageauditjson");
527 if (arg(argc,argv,"/walletstorageaudit") || 527 bool fDiagWantsAudit = arg(argc,argv,"/walletstorageaudit") ||
528 arg(argc,argv,"-walletstorageaudit") || 528 arg(argc,argv,"-walletstorageaudit") ||
529 !strWalletStorageAuditJson.empty()) 529 !strWalletStorageAuditJson.empty();
530 bool fDiagWantsCheck = arg(argc,argv,"/walletstoragecheck") ||
531 arg(argc,argv,"-walletstoragecheck");
532
533 // These diagnostics normally read wallet.dat. Under -walletbackend=sqlite
534 // the live wallet is wallet.sqlite, so open it read-only as the active
535 // store and let the same scan walk the right file. This runs before the
536 // normal backend resolution further down, so validate the value here too.
537 string strDiagBackend = argval2(argc, argv, "/walletbackend", "-walletbackend");
538 if ((fDiagWantsAudit || fDiagWantsCheck) && !strDiagBackend.empty() &&
539 strDiagBackend != "sqlite" && strDiagBackend != "bdb")
540 {
541 AttachTerminal();
542 fprintf(stderr, "Unknown wallet backend '%s'. Use -walletbackend=sqlite "
543 "or -walletbackend=bdb.\n", strDiagBackend.c_str());
544 return 1;
545 }
546 bool fDiagSQLite = (strDiagBackend == "sqlite") &&
547 (fDiagWantsAudit || fDiagWantsCheck);
548 if (fDiagSQLite)
549 {
550 AttachTerminal();
551 string strSQLitePath = GetAppDir() + "/wallet.sqlite";
552 string strOpenErr;
553 if (!WalletSQLiteRuntimeOpenReadOnly(strSQLitePath, strOpenErr))
554 {
555 fprintf(stderr, "Cannot open the SQLite wallet for diagnostics: %s\n",
556 strOpenErr.c_str());
557 return 1;
558 }
559 }
560
561 if (fDiagWantsAudit)
530 { 562 {
531 int nRet = CmdWalletStorageAudit(strWalletStorageAuditJson); 563 int nRet = CmdWalletStorageAudit(strWalletStorageAuditJson);
532 DBFlush(true); 564 if (fDiagSQLite)
565 WalletSQLiteRuntimeClose();
566 else
567 DBFlush(true);
533 return nRet; 568 return nRet;
534 } 569 }
535 570
536 if (arg(argc,argv,"/walletstoragecheck") || arg(argc,argv,"-walletstoragecheck")) 571 if (fDiagWantsCheck)
537 { 572 {
538 int nRet = CmdWalletStorageCheck(); 573 int nRet = CmdWalletStorageCheck();
539 DBFlush(true); 574 if (fDiagSQLite)
575 WalletSQLiteRuntimeClose();
576 else
577 DBFlush(true);
540 return nRet; 578 return nRet;
541 } 579 }
542 580