diff options
| author | Nsable-sh <nsable-sh@noreply.git.bitflash.network> | 2026-08-14 11:51:14 -0300 |
|---|---|---|
| committer | Nsable-sh <nsable-sh@noreply.git.bitflash.network> | 2026-08-14 12:13:38 -0300 |
| commit | 83b9c4feddeac14bbc5edf63b44d3a2013384ecc (patch) | |
| tree | 1181df60aaefb3d67c85dd9f5aa816f787835fc1 /src/main_gui.cpp | |
| parent | 225a89b643a79b73351abe530d6eb7af8906be63 (diff) | |
tests: prove wallet storage sanity failures
Diffstat (limited to 'src/main_gui.cpp')
| -rw-r--r-- | src/main_gui.cpp | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/src/main_gui.cpp b/src/main_gui.cpp index 8763211..feda428 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp | |||
| @@ -113,8 +113,9 @@ static void PrintUsage() | |||
| 113 | printf(" /debug\n"); | 113 | printf(" /debug\n"); |
| 114 | printf(" /gen\n"); | 114 | printf(" /gen\n"); |
| 115 | printf(" /nogui or /daemon\n"); | 115 | printf(" /nogui or /daemon\n"); |
| 116 | printf(" /selftest=wallet-keypool, wallet-hd, wallet-format, wallet-crypto, wallet-encrypt,\n"); | 116 | printf(" /selftest=wallet-keypool, wallet-hd, wallet-format, wallet-storage-sanity,\n"); |
| 117 | printf(" wallet-portability, net-message, consensus-limits, pool-stratum,\n"); | 117 | printf(" wallet-crypto, wallet-encrypt, wallet-portability, net-message,\n"); |
| 118 | printf(" consensus-limits, pool-stratum,\n"); | ||
| 118 | printf(" parse-money, socks5-proxy, or managed-tor\n"); | 119 | printf(" parse-money, socks5-proxy, or managed-tor\n"); |
| 119 | printf("\n"); | 120 | printf("\n"); |
| 120 | printf("Mining mode:\n"); | 121 | printf("Mining mode:\n"); |
| @@ -495,10 +496,37 @@ int main(int argc, char* argv[]) | |||
| 495 | 496 | ||
| 496 | ParseStartupArguments(argc, argv); | 497 | ParseStartupArguments(argc, argv); |
| 497 | 498 | ||
| 499 | // Hidden self-test helper. It must run before LoadWallet(): several | ||
| 500 | // storage-sanity scenarios deliberately make wallet.dat unsafe to load. | ||
| 501 | string strSelfTestMutateWallet = | ||
| 502 | argval2(argc, argv, "/selftestmutatewallet", "-selftestmutatewallet"); | ||
| 503 | if (!strSelfTestMutateWallet.empty()) | ||
| 504 | return RunSelfTestMutateWallet(strSelfTestMutateWallet); | ||
| 505 | |||
| 498 | string strSelfTest = argval2(argc, argv, "/selftest", "-selftest"); | 506 | string strSelfTest = argval2(argc, argv, "/selftest", "-selftest"); |
| 499 | if (!strSelfTest.empty()) | 507 | if (!strSelfTest.empty()) |
| 500 | return RunSelfTest(strSelfTest); | 508 | return RunSelfTest(strSelfTest); |
| 501 | 509 | ||
| 510 | // Storage diagnostics must run before LoadWallet(). Their job is to | ||
| 511 | // explain wallet.dat states that the normal wallet loader may refuse. | ||
| 512 | string strWalletStorageAuditJson = | ||
| 513 | argval2(argc, argv, "/walletstorageauditjson", "-walletstorageauditjson"); | ||
| 514 | if (arg(argc,argv,"/walletstorageaudit") || | ||
| 515 | arg(argc,argv,"-walletstorageaudit") || | ||
| 516 | !strWalletStorageAuditJson.empty()) | ||
| 517 | { | ||
| 518 | int nRet = CmdWalletStorageAudit(strWalletStorageAuditJson); | ||
| 519 | DBFlush(true); | ||
| 520 | return nRet; | ||
| 521 | } | ||
| 522 | |||
| 523 | if (arg(argc,argv,"/walletstoragecheck") || arg(argc,argv,"-walletstoragecheck")) | ||
| 524 | { | ||
| 525 | int nRet = CmdWalletStorageCheck(); | ||
| 526 | DBFlush(true); | ||
| 527 | return nRet; | ||
| 528 | } | ||
| 529 | |||
| 502 | // Berkeley DB reports failure by throwing, and CDB's constructor lets it | 530 | // Berkeley DB reports failure by throwing, and CDB's constructor lets it |
| 503 | // through. Nothing on this path caught anything, so an unreadable | 531 | // through. Nothing on this path caught anything, so an unreadable |
| 504 | // blkindex.dat or wallet.dat -- one written by another platform's Berkeley | 532 | // blkindex.dat or wallet.dat -- one written by another platform's Berkeley |
| @@ -710,24 +738,6 @@ int main(int argc, char* argv[]) | |||
| 710 | return nRet; | 738 | return nRet; |
| 711 | } | 739 | } |
| 712 | 740 | ||
| 713 | string strWalletStorageAuditJson = | ||
| 714 | argval2(argc, argv, "/walletstorageauditjson", "-walletstorageauditjson"); | ||
| 715 | if (arg(argc,argv,"/walletstorageaudit") || | ||
| 716 | arg(argc,argv,"-walletstorageaudit") || | ||
| 717 | !strWalletStorageAuditJson.empty()) | ||
| 718 | { | ||
| 719 | int nRet = CmdWalletStorageAudit(strWalletStorageAuditJson); | ||
| 720 | DBFlush(true); | ||
| 721 | return nRet; | ||
| 722 | } | ||
| 723 | |||
| 724 | if (arg(argc,argv,"/walletstoragecheck") || arg(argc,argv,"-walletstoragecheck")) | ||
| 725 | { | ||
| 726 | int nRet = CmdWalletStorageCheck(); | ||
| 727 | DBFlush(true); | ||
| 728 | return nRet; | ||
| 729 | } | ||
| 730 | |||
| 731 | if (arg(argc,argv,"/newphrase") || arg(argc,argv,"-newphrase")) | 741 | if (arg(argc,argv,"/newphrase") || arg(argc,argv,"-newphrase")) |
| 732 | { | 742 | { |
| 733 | int nRet = CmdNewPhrase(); | 743 | int nRet = CmdNewPhrase(); |