upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/walletcmd.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/walletcmd.cpp')
-rw-r--r--src/walletcmd.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/walletcmd.cpp b/src/walletcmd.cpp
index b449df9..06f35a5 100644
--- a/src/walletcmd.cpp
+++ b/src/walletcmd.cpp
@@ -406,6 +406,36 @@ int CmdRecoveryAudit()
406 return 0; 406 return 0;
407} 407}
408 408
409int CmdEncryptWallet(const std::string& strPassphrase)
410{
411 AttachTerminal();
412
413 string strBackup;
414 string strError;
415 if (!EncryptWallet(strPassphrase, strBackup, strError))
416 {
417 fprintf(stderr, "Cannot encrypt wallet: %s\n", strError.c_str());
418 fprintf(stderr, "Nothing was changed.\n");
419 return 1;
420 }
421
422 printf("Wallet encrypted.\n");
423 printf("The old unencrypted wallet was moved to:\n");
424 printf(" %s\n", strBackup.c_str());
425 printf("That backup still contains private keys in plain text. Move it offline or\n");
426 printf("delete it after you have a safer backup plan.\n");
427 printf("Restart Bitflash before using the wallet again.\n");
428 fflush(stdout);
429
430 // The rewritten wallet.dat is clean; the environment's write-ahead logs are
431 // not, because every plaintext record this wallet ever wrote passed through
432 // them. Closing the environment and dropping the logs is the last step of
433 // encrypting, not an optimisation -- our own backup advice is to copy the
434 // whole directory, and following it otherwise carries the keys along.
435 PurgeDbEnvironmentLogs();
436 return 0;
437}
438
409// Spend, from the command line. 439// Spend, from the command line.
410// 440//
411// SendMoney() has been in this tree since 0.1.0 and only the window ever called 441// SendMoney() has been in this tree since 0.1.0 and only the window ever called
@@ -421,6 +451,12 @@ int CmdSendTo(const std::string& strArg)
421{ 451{
422 AttachTerminal(); 452 AttachTerminal();
423 453
454 if (IsWalletLocked())
455 {
456 fprintf(stderr, "Wallet is encrypted and locked. Start with /walletpassphrase or /walletpassphrase=@FILE to spend.\n");
457 return 1;
458 }
459
424 std::string::size_type comma = strArg.rfind(','); 460 std::string::size_type comma = strArg.rfind(',');
425 if (comma == std::string::npos) 461 if (comma == std::string::npos)
426 { 462 {