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/main_gui.cpp | |
| 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/main_gui.cpp')
| -rw-r--r-- | src/main_gui.cpp | 50 |
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 | ||