Exemple #1
0
 private static void saveWallet(File walletFile) {
   try {
     // This will save the new state of the wallet to a temp file then rename, in case anything
     // goes wrong.
     wallet.saveToFile(walletFile);
   } catch (IOException e) {
     System.err.println("Failed to save wallet! Old wallet should be left untouched.");
     e.printStackTrace();
     System.exit(1);
   }
 }
Exemple #2
0
 private static void createWallet(OptionSet options, NetworkParameters params, File walletFile)
     throws IOException {
   if (walletFile.exists() && !options.has("force")) {
     System.err.println(
         "Wallet creation requested but " + walletFile + " already exists, use --force");
     return;
   }
   wallet = new Wallet(params);
   if (password != null) {
     wallet.encrypt(password);
     wallet.addNewEncryptedKey(password);
   }
   wallet.saveToFile(walletFile);
 }