本文整理汇总了Java中org.bitcoinj.wallet.DeterministicSeed.getMnemonicCode方法的典型用法代码示例。如果您正苦于以下问题:Java DeterministicSeed.getMnemonicCode方法的具体用法?Java DeterministicSeed.getMnemonicCode怎么用?Java DeterministicSeed.getMnemonicCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bitcoinj.wallet.DeterministicSeed
的用法示例。
在下文中一共展示了DeterministicSeed.getMnemonicCode方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSeeds
import org.bitcoinj.wallet.DeterministicSeed; //导入方法依赖的package包/类
@Test
public void testSeeds() throws MnemonicLengthException, MnemonicWordException, MnemonicChecksumException {
int bits = 128;
byte [] entropy = getEntropy(bits);
List<String> mnemonic = MnemonicCode.INSTANCE.toMnemonic(entropy);
String passphrase = "";
long creationTimeSeconds = System.currentTimeMillis() / 1000;
DeterministicSeed ds1 = new DeterministicSeed(entropy, passphrase, creationTimeSeconds);
DeterministicSeed ds2 = new DeterministicSeed(mnemonic, null, passphrase, creationTimeSeconds);
byte [] ds1seed = ds1.getSeedBytes();
byte [] ds2seed = ds2.getSeedBytes();
Assert.assertArrayEquals(ds1seed, ds2seed);
List<String> ds1mnemonic = ds1.getMnemonicCode();
List<String> ds2mnemonic = ds2.getMnemonicCode();
assertEquals(mnemonic, ds1mnemonic);
assertEquals(ds1mnemonic, ds2mnemonic);
printMnemonic(mnemonic);
}
示例2: seedToString
import org.bitcoinj.wallet.DeterministicSeed; //导入方法依赖的package包/类
private String seedToString(final DeterministicSeed seed) {
if (seed == null || seed.getMnemonicCode() == null) {
return null;
}
final StringBuilder sb = new StringBuilder();
for (final String word : seed.getMnemonicCode()) {
sb.append(word).append(" ");
}
// Remove the extraneous space character
sb.deleteCharAt(sb.length() - 1);
return sb.toString();
}
示例3: seedToString
import org.bitcoinj.wallet.DeterministicSeed; //导入方法依赖的package包/类
private String seedToString(final DeterministicSeed seed) {
final StringBuilder sb = new StringBuilder();
for (final String word : seed.getMnemonicCode()) {
sb.append(word).append(" ");
}
// Remove the extraneous space character
sb.deleteCharAt(sb.length() - 1);
return sb.toString();
}
示例4: initialize
import org.bitcoinj.wallet.DeterministicSeed; //导入方法依赖的package包/类
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");
}
});
}
示例5: initialize
import org.bitcoinj.wallet.DeterministicSeed; //导入方法依赖的package包/类
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");
}
});
}
示例6: initialize
import org.bitcoinj.wallet.DeterministicSeed; //导入方法依赖的package包/类
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");
}
});
}
示例7: initSeedWords
import org.bitcoinj.wallet.DeterministicSeed; //导入方法依赖的package包/类
private void initSeedWords(DeterministicSeed seed) {
List<String> mnemonicCode = seed.getMnemonicCode();
if (mnemonicCode != null) {
seedWordText = Joiner.on(" ").join(mnemonicCode);
}
}
示例8: getMCode
import org.bitcoinj.wallet.DeterministicSeed; //导入方法依赖的package包/类
public static List<String> getMCode (Wallet wallet){
DeterministicSeed seed = wallet.getKeyChainSeed();
System.out.println("seed: " + seed.toString());
return seed.getMnemonicCode();
}
示例9: initialize
import org.bitcoinj.wallet.DeterministicSeed; //导入方法依赖的package包/类
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.SPACE_JOINER.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");
}
});
}