mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-02-24 06:47:54 +01:00
DeterministicSeed: New method getMnemonicString() to do the string concatenation.
This commit is contained in:
parent
56443ee754
commit
6b309e486f
1 changed files with 11 additions and 5 deletions
|
@ -52,8 +52,8 @@ public class DeterministicSeed implements EncryptableItem {
|
||||||
@Nullable private final EncryptedData encryptedSeed;
|
@Nullable private final EncryptedData encryptedSeed;
|
||||||
private long creationTimeSeconds;
|
private long creationTimeSeconds;
|
||||||
|
|
||||||
public DeterministicSeed(String mnemonicCode, byte[] seed, String passphrase, long creationTimeSeconds) throws UnreadableWalletException {
|
public DeterministicSeed(String mnemonicString, byte[] seed, String passphrase, long creationTimeSeconds) throws UnreadableWalletException {
|
||||||
this(decodeMnemonicCode(mnemonicCode), seed, passphrase, creationTimeSeconds);
|
this(decodeMnemonicCode(mnemonicString), seed, passphrase, creationTimeSeconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeterministicSeed(byte[] seed, List<String> mnemonic, long creationTimeSeconds) {
|
public DeterministicSeed(byte[] seed, List<String> mnemonic, long creationTimeSeconds) {
|
||||||
|
@ -139,11 +139,11 @@ public class DeterministicSeed implements EncryptableItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString(boolean includePrivate) {
|
public String toString(boolean includePrivate) {
|
||||||
MoreObjects.ToStringHelper helper = MoreObjects.toStringHelper(this);
|
MoreObjects.ToStringHelper helper = MoreObjects.toStringHelper(this).omitNullValues();
|
||||||
if (isEncrypted())
|
if (isEncrypted())
|
||||||
helper.addValue("encrypted");
|
helper.addValue("encrypted");
|
||||||
else if (includePrivate)
|
else if (includePrivate)
|
||||||
helper.addValue(toHexString()).add("mnemonicCode", Utils.SPACE_JOINER.join(mnemonicCode));
|
helper.addValue(toHexString()).add("mnemonicCode", getMnemonicString());
|
||||||
else
|
else
|
||||||
helper.addValue("unencrypted");
|
helper.addValue("unencrypted");
|
||||||
return helper.toString();
|
return helper.toString();
|
||||||
|
@ -200,7 +200,7 @@ public class DeterministicSeed implements EncryptableItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] getMnemonicAsBytes() {
|
private byte[] getMnemonicAsBytes() {
|
||||||
return Utils.SPACE_JOINER.join(mnemonicCode).getBytes(StandardCharsets.UTF_8);
|
return getMnemonicString().getBytes(StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeterministicSeed decrypt(KeyCrypter crypter, String passphrase, KeyParameter aesKey) {
|
public DeterministicSeed decrypt(KeyCrypter crypter, String passphrase, KeyParameter aesKey) {
|
||||||
|
@ -247,6 +247,12 @@ public class DeterministicSeed implements EncryptableItem {
|
||||||
return mnemonicCode;
|
return mnemonicCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get the mnemonic code as string, or null if unknown. */
|
||||||
|
@Nullable
|
||||||
|
public String getMnemonicString() {
|
||||||
|
return mnemonicCode != null ? Utils.SPACE_JOINER.join(mnemonicCode) : null;
|
||||||
|
}
|
||||||
|
|
||||||
private static List<String> decodeMnemonicCode(byte[] mnemonicCode) {
|
private static List<String> decodeMnemonicCode(byte[] mnemonicCode) {
|
||||||
return decodeMnemonicCode(new String(mnemonicCode, StandardCharsets.UTF_8));
|
return decodeMnemonicCode(new String(mnemonicCode, StandardCharsets.UTF_8));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue