protected Wallet doInBackground(Bundle... params) {
      ArrayList<String> seedWords = new ArrayList<String>();
      for (String word : seed.trim().split(" ")) {
        if (word.isEmpty()) continue;
        seedWords.add(word);
      }

      Wallet wallet = null;
      try {
        if (seedProtect) {
          wallet = new Wallet(seedWords, password);
        } else {
          wallet = new Wallet(seedWords);
        }

        KeyParameter aesKey = null;
        if (password != null && !password.isEmpty()) {
          KeyCrypterScrypt crypter = new KeyCrypterScrypt();
          aesKey = crypter.deriveKey(password);
          wallet.encrypt(crypter, aesKey);
        }

        wallet.createAccounts(coinsToCreate, true, aesKey);
        getWalletApplication().setWallet(wallet);
        getWalletApplication().saveWalletNow();
        getWalletApplication().startBlockchainService(CoinService.ServiceMode.RESET_WALLET);
      } catch (Exception e) {
        log.error("Error creating a wallet", e);
        errorMessage = e.getMessage();
      }
      return wallet;
    }
 public static void estimateKeyDerivationTime() {
   // This is run in the background after startup. If we haven't recorded it before, do a key
   // derivation to see
   // how long it takes. This helps us produce better progress feedback, as on Windows we don't
   // currently have a
   // native Scrypt impl and the Java version is ~3 times slower, plus it depends a lot on CPU
   // speed.
   checkGuiThread();
   estimatedKeyDerivationTime = Main.instance.prefs.getExpectedKeyDerivationTime();
   if (estimatedKeyDerivationTime == null) {
     new Thread(
             () -> {
               log.info("Doing background test key derivation");
               KeyCrypterScrypt scrypt = new KeyCrypterScrypt(SCRYPT_PARAMETERS);
               long start = System.currentTimeMillis();
               scrypt.deriveKey("test password");
               long msec = System.currentTimeMillis() - start;
               log.info("Background test key derivation took {}msec", msec);
               Platform.runLater(
                   () -> {
                     estimatedKeyDerivationTime = Duration.ofMillis(msec);
                     Main.instance.prefs.setExpectedKeyDerivationTime(estimatedKeyDerivationTime);
                   });
             })
         .start();
   }
 }
 @Test(expected = KeyCrypterException.class)
 public void cannotMixParams() throws Exception {
   chain = chain.toEncrypted("foobar");
   KeyCrypterScrypt scrypter = new KeyCrypterScrypt(2); // Some bogus params.
   ECKey key1 = new ECKey().encrypt(scrypter, scrypter.deriveKey("other stuff"));
   chain.importKeys(key1);
 }