diff options
Diffstat (limited to 'src/main_gui.cpp')
| -rw-r--r-- | src/main_gui.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/main_gui.cpp b/src/main_gui.cpp index c64dca9..976cd42 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp | |||
| @@ -67,6 +67,10 @@ static void PrintUsage() | |||
| 67 | printf(" /port=N (P2P listen port, default 8433)\n"); | 67 | printf(" /port=N (P2P listen port, default 8433)\n"); |
| 68 | printf(" /btfseed=ADDRESS:ENCHEX (extra bootstrap peer, repeatable)\n"); | 68 | printf(" /btfseed=ADDRESS:ENCHEX (extra bootstrap peer, repeatable)\n"); |
| 69 | printf("\n"); | 69 | printf("\n"); |
| 70 | printf("Wallet:\n"); | ||
| 71 | printf(" /backupwallet=FILE (write a wallet.dat that opens on its own,\n"); | ||
| 72 | printf(" then exit; run it again after new addresses)\n"); | ||
| 73 | printf("\n"); | ||
| 70 | printf("Each option also accepts '-' instead of '/'.\n"); | 74 | printf("Each option also accepts '-' instead of '/'.\n"); |
| 71 | } | 75 | } |
| 72 | 76 | ||
| @@ -219,6 +223,28 @@ int main(int argc, char* argv[]) | |||
| 219 | return 1; | 223 | return 1; |
| 220 | } | 224 | } |
| 221 | printf("Height=%d\n", nBestHeight); | 225 | printf("Height=%d\n", nBestHeight); |
| 226 | |||
| 227 | // Before the node opens sockets or touches anything: the wallet is loaded, | ||
| 228 | // which is all a backup needs, and finishing here means the copy is taken | ||
| 229 | // from a quiet directory rather than from under a running node. | ||
| 230 | string strBackup = argval2(argc, argv, "/backupwallet", "-backupwallet"); | ||
| 231 | if (!strBackup.empty()) | ||
| 232 | { | ||
| 233 | bool fOk = BackupWallet(strBackup); | ||
| 234 | if (fOk) | ||
| 235 | { | ||
| 236 | printf("Backed up to %s\n", strBackup.c_str()); | ||
| 237 | printf("This file opens on its own -- it does not need the database/ " | ||
| 238 | "directory beside it.\n"); | ||
| 239 | printf("It is a snapshot: coins paid to addresses created after now are " | ||
| 240 | "not in it, so back up again whenever you receive to a new address.\n"); | ||
| 241 | } | ||
| 242 | else | ||
| 243 | fprintf(stderr, "Backup failed -- nothing was written.\n"); | ||
| 244 | DBFlush(true); | ||
| 245 | return fOk ? 0 : 1; | ||
| 246 | } | ||
| 247 | |||
| 222 | ReacceptWalletTransactions(); | 248 | ReacceptWalletTransactions(); |
| 223 | 249 | ||
| 224 | if (!StartNode(strErrors)) { fprintf(stderr,"StartNode: %s\n",strErrors.c_str()); return 1; } | 250 | if (!StartNode(strErrors)) { fprintf(stderr,"StartNode: %s\n",strErrors.c_str()); return 1; } |
| @@ -249,6 +275,11 @@ int main(int argc, char* argv[]) | |||
| 249 | printf("Running headless. Ctrl-C to stop.\n"); | 275 | printf("Running headless. Ctrl-C to stop.\n"); |
| 250 | while (!fShutdown) Sleep(500); | 276 | while (!fShutdown) Sleep(500); |
| 251 | StopNode(); | 277 | StopNode(); |
| 278 | // Checkpoints, releases wallet.dat from this directory's Berkeley DB | ||
| 279 | // environment, and closes it. Declared since 2009 and never once | ||
| 280 | // called here, which is why a wallet.dat copied elsewhere would not | ||
| 281 | // open -- issue #40. Not optional. | ||
| 282 | DBFlush(true); | ||
| 252 | return 0; | 283 | return 0; |
| 253 | } | 284 | } |
| 254 | 285 | ||
| @@ -258,6 +289,7 @@ int main(int argc, char* argv[]) | |||
| 258 | int ret = RunGUI(argc, argv); | 289 | int ret = RunGUI(argc, argv); |
| 259 | fShutdown = true; | 290 | fShutdown = true; |
| 260 | StopNode(); | 291 | StopNode(); |
| 292 | DBFlush(true); | ||
| 261 | return ret; | 293 | return ret; |
| 262 | #endif | 294 | #endif |
| 263 | } | 295 | } |