Java Code Examples for org.bitcoinj.wallet.DeterministicSeed#isEncrypted()
The following examples show how to use
org.bitcoinj.wallet.DeterministicSeed#isEncrypted() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WalletSettingsController.java From green_android with GNU General Public License v3.0 | 4 votes |
public void initialize(@Nullable KeyParameter aesKey) { DeterministicSeed seed = Main.bitcoin.wallet().getKeyChainSeed(); if (aesKey == null) { if (seed.isEncrypted()) { log.info("Wallet is encrypted, requesting password first."); // Delay execution of this until after we've finished initialising this screen. Platform.runLater(() -> askForPasswordAndRetry()); return; } } else { this.aesKey = aesKey; seed = seed.decrypt(checkNotNull(Main.bitcoin.wallet().getKeyCrypter()), "", aesKey); // Now we can display the wallet seed as appropriate. passwordButton.setText("Remove password"); } // Set the date picker to show the birthday of this wallet. Instant creationTime = Instant.ofEpochSecond(seed.getCreationTimeSeconds()); LocalDate origDate = creationTime.atZone(ZoneId.systemDefault()).toLocalDate(); datePicker.setValue(origDate); // Set the mnemonic seed words. final List<String> mnemonicCode = seed.getMnemonicCode(); checkNotNull(mnemonicCode); // Already checked for encryption. String origWords = Utils.join(mnemonicCode); wordsArea.setText(origWords); // Validate words as they are being typed. MnemonicCode codec = unchecked(MnemonicCode::new); TextFieldValidator validator = new TextFieldValidator(wordsArea, text -> !didThrow(() -> codec.check(Splitter.on(' ').splitToList(text))) ); // Clear the date picker if the user starts editing the words, if it contained the current wallets date. // This forces them to set the birthday field when restoring. wordsArea.textProperty().addListener(o -> { if (origDate.equals(datePicker.getValue())) datePicker.setValue(null); }); BooleanBinding datePickerIsInvalid = or( datePicker.valueProperty().isNull(), createBooleanBinding(() -> datePicker.getValue().isAfter(LocalDate.now()) , /* depends on */ datePicker.valueProperty()) ); // Don't let the user click restore if the words area contains the current wallet words, or are an invalid set, // or if the date field isn't set, or if it's in the future. restoreButton.disableProperty().bind( or( or( not(validator.valid), equal(origWords, wordsArea.textProperty()) ), datePickerIsInvalid ) ); // Highlight the date picker in red if it's empty or in the future, so the user knows why restore is disabled. datePickerIsInvalid.addListener((dp, old, cur) -> { if (cur) { datePicker.getStyleClass().add("validation_error"); } else { datePicker.getStyleClass().remove("validation_error"); } }); }
Example 2
Source File: WalletSettingsController.java From thunder with GNU Affero General Public License v3.0 | 4 votes |
public void initialize (@Nullable KeyParameter aesKey) { DeterministicSeed seed = Main.wallet.getKeyChainSeed(); if (aesKey == null) { if (seed.isEncrypted()) { log.info("Wallet is encrypted, requesting password first."); // Delay execution of this until after we've finished initialising this screen. Platform.runLater(() -> askForPasswordAndRetry()); return; } } else { this.aesKey = aesKey; seed = seed.decrypt(checkNotNull(Main.wallet.getKeyCrypter()), "", aesKey); // Now we can display the wallet seed as appropriate. passwordButton.setText("Remove password"); } // Set the date picker to show the birthday of this wallet. Instant creationTime = Instant.ofEpochSecond(seed.getCreationTimeSeconds()); LocalDate origDate = creationTime.atZone(ZoneId.systemDefault()).toLocalDate(); datePicker.setValue(origDate); // Set the mnemonic seed words. final List<String> mnemonicCode = seed.getMnemonicCode(); checkNotNull(mnemonicCode); // Already checked for encryption. String origWords = Utils.join(mnemonicCode); wordsArea.setText(origWords); // Validate words as they are being typed. MnemonicCode codec = unchecked(MnemonicCode::new); TextFieldValidator validator = new TextFieldValidator(wordsArea, text -> !didThrow(() -> codec.check(Splitter.on(' ').splitToList(text))) ); // Clear the date picker if the user starts editing the words, if it contained the current wallets date. // This forces them to set the birthday field when restoring. wordsArea.textProperty().addListener(o -> { if (origDate.equals(datePicker.getValue())) { datePicker.setValue(null); } }); BooleanBinding datePickerIsInvalid = or( datePicker.valueProperty().isNull(), createBooleanBinding(() -> datePicker.getValue().isAfter(LocalDate.now()) , /* depends on */ datePicker.valueProperty()) ); // Don't let the user click restore if the words area contains the current wallet words, or are an invalid set, // or if the date field isn't set, or if it's in the future. restoreButton.disableProperty().bind( or( or( not(validator.valid), equal(origWords, wordsArea.textProperty()) ), datePickerIsInvalid ) ); // Highlight the date picker in red if it's empty or in the future, so the user knows why restore is disabled. datePickerIsInvalid.addListener((dp, old, cur) -> { if (cur) { datePicker.getStyleClass().add("validation_error"); } else { datePicker.getStyleClass().remove("validation_error"); } }); }
Example 3
Source File: WalletSettingsController.java From GreenBits with GNU General Public License v3.0 | 4 votes |
public void initialize(@Nullable KeyParameter aesKey) { DeterministicSeed seed = Main.bitcoin.wallet().getKeyChainSeed(); if (aesKey == null) { if (seed.isEncrypted()) { log.info("Wallet is encrypted, requesting password first."); // Delay execution of this until after we've finished initialising this screen. Platform.runLater(() -> askForPasswordAndRetry()); return; } } else { this.aesKey = aesKey; seed = seed.decrypt(checkNotNull(Main.bitcoin.wallet().getKeyCrypter()), "", aesKey); // Now we can display the wallet seed as appropriate. passwordButton.setText("Remove password"); } // Set the date picker to show the birthday of this wallet. Instant creationTime = Instant.ofEpochSecond(seed.getCreationTimeSeconds()); LocalDate origDate = creationTime.atZone(ZoneId.systemDefault()).toLocalDate(); datePicker.setValue(origDate); // Set the mnemonic seed words. final List<String> mnemonicCode = seed.getMnemonicCode(); checkNotNull(mnemonicCode); // Already checked for encryption. String origWords = Utils.join(mnemonicCode); wordsArea.setText(origWords); // Validate words as they are being typed. MnemonicCode codec = unchecked(MnemonicCode::new); TextFieldValidator validator = new TextFieldValidator(wordsArea, text -> !didThrow(() -> codec.check(Splitter.on(' ').splitToList(text))) ); // Clear the date picker if the user starts editing the words, if it contained the current wallets date. // This forces them to set the birthday field when restoring. wordsArea.textProperty().addListener(o -> { if (origDate.equals(datePicker.getValue())) datePicker.setValue(null); }); BooleanBinding datePickerIsInvalid = or( datePicker.valueProperty().isNull(), createBooleanBinding(() -> datePicker.getValue().isAfter(LocalDate.now()) , /* depends on */ datePicker.valueProperty()) ); // Don't let the user click restore if the words area contains the current wallet words, or are an invalid set, // or if the date field isn't set, or if it's in the future. restoreButton.disableProperty().bind( or( or( not(validator.valid), equal(origWords, wordsArea.textProperty()) ), datePickerIsInvalid ) ); // Highlight the date picker in red if it's empty or in the future, so the user knows why restore is disabled. datePickerIsInvalid.addListener((dp, old, cur) -> { if (cur) { datePicker.getStyleClass().add("validation_error"); } else { datePicker.getStyleClass().remove("validation_error"); } }); }
Example 4
Source File: WalletSettingsController.java From devcoretalk with GNU General Public License v2.0 | 4 votes |
public void initialize(@Nullable KeyParameter aesKey) { DeterministicSeed seed = Main.bitcoin.wallet().getKeyChainSeed(); if (aesKey == null) { if (seed.isEncrypted()) { log.info("Wallet is encrypted, requesting password first."); // Delay execution of this until after we've finished initialising this screen. Platform.runLater(() -> askForPasswordAndRetry()); return; } } else { this.aesKey = aesKey; seed = seed.decrypt(checkNotNull(Main.bitcoin.wallet().getKeyCrypter()), "", aesKey); // Now we can display the wallet seed as appropriate. passwordButton.setText("Remove password"); } // Set the date picker to show the birthday of this wallet. Instant creationTime = Instant.ofEpochSecond(seed.getCreationTimeSeconds()); LocalDate origDate = creationTime.atZone(ZoneId.systemDefault()).toLocalDate(); datePicker.setValue(origDate); // Set the mnemonic seed words. final List<String> mnemonicCode = seed.getMnemonicCode(); checkNotNull(mnemonicCode); // Already checked for encryption. String origWords = Joiner.on(" ").join(mnemonicCode); wordsArea.setText(origWords); // Validate words as they are being typed. MnemonicCode codec = unchecked(MnemonicCode::new); TextFieldValidator validator = new TextFieldValidator(wordsArea, text -> !didThrow(() -> codec.check(Splitter.on(' ').splitToList(text))) ); // Clear the date picker if the user starts editing the words, if it contained the current wallets date. // This forces them to set the birthday field when restoring. wordsArea.textProperty().addListener(o -> { if (origDate.equals(datePicker.getValue())) datePicker.setValue(null); }); BooleanBinding datePickerIsInvalid = or( datePicker.valueProperty().isNull(), createBooleanBinding(() -> datePicker.getValue().isAfter(LocalDate.now()) , /* depends on */ datePicker.valueProperty()) ); // Don't let the user click restore if the words area contains the current wallet words, or are an invalid set, // or if the date field isn't set, or if it's in the future. restoreButton.disableProperty().bind( or( or( not(validator.valid), equal(origWords, wordsArea.textProperty()) ), datePickerIsInvalid ) ); // Highlight the date picker in red if it's empty or in the future, so the user knows why restore is disabled. datePickerIsInvalid.addListener((dp, old, cur) -> { if (cur) { datePicker.getStyleClass().add("validation_error"); } else { datePicker.getStyleClass().remove("validation_error"); } }); }
Example 5
Source File: WalletSettingsController.java From thundernetwork with GNU Affero General Public License v3.0 | 4 votes |
public void initialize(@Nullable KeyParameter aesKey) { DeterministicSeed seed = Main.bitcoin.wallet().getKeyChainSeed(); if (aesKey == null) { if (seed.isEncrypted()) { log.info("Wallet is encrypted, requesting password first."); // Delay execution of this until after we've finished initialising this screen. Platform.runLater(() -> askForPasswordAndRetry()); return; } } else { this.aesKey = aesKey; seed = seed.decrypt(checkNotNull(Main.bitcoin.wallet().getKeyCrypter()), "", aesKey); // Now we can display the wallet seed as appropriate. passwordButton.setText("Remove password"); } // Set the date picker to show the birthday of this wallet. Instant creationTime = Instant.ofEpochSecond(seed.getCreationTimeSeconds()); LocalDate origDate = creationTime.atZone(ZoneId.systemDefault()).toLocalDate(); datePicker.setValue(origDate); // Set the mnemonic seed words. final List<String> mnemonicCode = seed.getMnemonicCode(); checkNotNull(mnemonicCode); // Already checked for encryption. String origWords = Utils.join(mnemonicCode); wordsArea.setText(origWords); // Validate words as they are being typed. MnemonicCode codec = unchecked(MnemonicCode::new); TextFieldValidator validator = new TextFieldValidator(wordsArea, text -> !didThrow(() -> codec.check(Splitter.on(' ').splitToList(text))) ); // Clear the date picker if the user starts editing the words, if it contained the current wallets date. // This forces them to set the birthday field when restoring. wordsArea.textProperty().addListener(o -> { if (origDate.equals(datePicker.getValue())) datePicker.setValue(null); }); BooleanBinding datePickerIsInvalid = or( datePicker.valueProperty().isNull(), createBooleanBinding(() -> datePicker.getValue().isAfter(LocalDate.now()) , /* depends on */ datePicker.valueProperty()) ); // Don't let the user click restore if the words area contains the current wallet words, or are an invalid set, // or if the date field isn't set, or if it's in the future. restoreButton.disableProperty().bind( or( or( not(validator.valid), equal(origWords, wordsArea.textProperty()) ), datePickerIsInvalid ) ); // Highlight the date picker in red if it's empty or in the future, so the user knows why restore is disabled. datePickerIsInvalid.addListener((dp, old, cur) -> { if (cur) { datePicker.getStyleClass().add("validation_error"); } else { datePicker.getStyleClass().remove("validation_error"); } }); }
Example 6
Source File: SeedWordsView.java From bisq with GNU Affero General Public License v3.0 | 4 votes |
@Override public void activate() { seedWordsValid.addListener(seedWordsValidChangeListener); seedWordsTextArea.textProperty().addListener(seedWordsTextAreaChangeListener); restoreButton.disableProperty().bind(createBooleanBinding(() -> !seedWordsValid.get() || !seedWordsEdited.get(), seedWordsValid, seedWordsEdited)); restoreButton.setOnAction(e -> { new Popup().information(Res.get("account.seed.restore.info")) .closeButtonText(Res.get("shared.cancel")) .actionButtonText(Res.get("account.seed.restore.ok")) .onAction(this::onRestore) .show(); }); seedWordsTextArea.getStyleClass().remove("validation-error"); restoreDatePicker.getStyleClass().remove("validation-error"); DeterministicSeed keyChainSeed = btcWalletService.getKeyChainSeed(); // wallet creation date is not encrypted walletCreationDate = Instant.ofEpochSecond(walletsManager.getChainSeedCreationTimeSeconds()).atZone(ZoneId.systemDefault()).toLocalDate(); if (keyChainSeed.isEncrypted()) { askForPassword(); } else { String key = "showSeedWordsWarning"; if (DontShowAgainLookup.showAgain(key)) { new Popup().warning(Res.get("account.seed.warn.noPw.msg")) .actionButtonText(Res.get("account.seed.warn.noPw.yes")) .onAction(() -> { DontShowAgainLookup.dontShowAgain(key, true); initSeedWords(keyChainSeed); showSeedScreen(); }) .closeButtonText(Res.get("shared.no")) .show(); } else { initSeedWords(keyChainSeed); showSeedScreen(); } } }