diff options
Diffstat (limited to 'src/main_gui.cpp')
| -rw-r--r-- | src/main_gui.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/main_gui.cpp b/src/main_gui.cpp index 2743429..25cde1c 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp | |||
| @@ -196,6 +196,9 @@ static void PrintUsage() | |||
| 196 | printf(" /walletsqlite=FILE (stage-load a SQLite wallet export, then exit)\n"); | 196 | printf(" /walletsqlite=FILE (stage-load a SQLite wallet export, then exit)\n"); |
| 197 | printf(" /walletbackend=sqlite (opt-in: run the node on <datadir>/wallet.sqlite\n"); | 197 | printf(" /walletbackend=sqlite (opt-in: run the node on <datadir>/wallet.sqlite\n"); |
| 198 | printf(" instead of wallet.dat; export one first)\n"); | 198 | printf(" instead of wallet.dat; export one first)\n"); |
| 199 | printf(" /createwallet (headless only: permit creating a new wallet in a\n"); | ||
| 200 | printf(" datadir that has none -- otherwise refused, since\n"); | ||
| 201 | printf(" a missing wallet is usually a mount/backup fault)\n"); | ||
| 199 | printf(" /rescan (walk the chain for coins this wallet owns\n"); | 202 | printf(" /rescan (walk the chain for coins this wallet owns\n"); |
| 200 | printf(" but never recorded, then exit)\n"); | 203 | printf(" but never recorded, then exit)\n"); |
| 201 | printf("\n"); | 204 | printf("\n"); |
| @@ -835,6 +838,32 @@ int main(int argc, char* argv[]) | |||
| 835 | else { fUseSQLite = true; fCreateSQLite = true; } | 838 | else { fUseSQLite = true; fCreateSQLite = true; } |
| 836 | } | 839 | } |
| 837 | 840 | ||
| 841 | // A headless node whose datadir holds no wallet of either kind is | ||
| 842 | // far more often an operations fault -- datadir not mounted, or | ||
| 843 | // wallet.dat caught mid-rename by a backup -- than a first run. | ||
| 844 | // Creating one here is not the harmless default it looks like: | ||
| 845 | // success also writes the backend marker, and from then on | ||
| 846 | // restoring the real wallet.dat no longer takes effect, because the | ||
| 847 | // marker keeps the node on the empty wallet it just made. Under | ||
| 848 | // 1.2.19 the same fault created a wallet.dat that a restore | ||
| 849 | // overwrote, so operators could recover by putting the file back. | ||
| 850 | // Refuse instead, and name the flag that makes it deliberate. | ||
| 851 | if (fCreateSQLite && fHeadlessStartup && | ||
| 852 | !arg(argc, argv, "/createwallet") && !arg(argc, argv, "-createwallet")) | ||
| 853 | { | ||
| 854 | AttachTerminal(); | ||
| 855 | fprintf(stderr, | ||
| 856 | "No wallet found in %s\n" | ||
| 857 | "Refusing to create one. On a headless node an absent wallet is\n" | ||
| 858 | "usually a mount or backup fault, and creating one would record a\n" | ||
| 859 | "backend marker that makes restoring the real wallet a no-op.\n" | ||
| 860 | "Pass -createwallet to start a new one deliberately, or\n" | ||
| 861 | "-walletbackend=bdb to run on a Berkeley DB wallet.dat.\n", | ||
| 862 | GetAppDir().c_str()); | ||
| 863 | fflush(stderr); | ||
| 864 | return 1; | ||
| 865 | } | ||
| 866 | |||
| 838 | if (fUseSQLite) | 867 | if (fUseSQLite) |
| 839 | { | 868 | { |
| 840 | AttachTerminal(); | 869 | AttachTerminal(); |