DeterministicSeed: New method getMnemonicString() to do the string concatenation.
@@ -52,8 +52,8 @@ public class DeterministicSeed implements EncryptableItem {
@Nullable private final EncryptedData encryptedSeed;
private long creationTimeSeconds;
- public DeterministicSeed(String mnemonicCode, byte[] seed, String passphrase, long creationTimeSeconds) throws UnreadableWalletException {
- this(decodeMnemonicCode(mnemonicCode), seed, passphrase, creationTimeSeconds);
+ public DeterministicSeed(String mnemonicString, byte[] seed, String passphrase, long creationTimeSeconds) throws UnreadableWalletException {
+ this(decodeMnemonicCode(mnemonicString), seed, passphrase, creationTimeSeconds);
}
public DeterministicSeed(byte[] seed, List<String> mnemonic, long creationTimeSeconds) {
@@ -139,11 +139,11 @@ public class DeterministicSeed implements EncryptableItem {
}
public String toString(boolean includePrivate) {
- MoreObjects.ToStringHelper helper = MoreObjects.toStringHelper(this);
+ MoreObjects.ToStringHelper helper = MoreObjects.toStringHelper(this).omitNullValues();
if (isEncrypted())
helper.addValue("encrypted");
else if (includePrivate)
- helper.addValue(toHexString()).add("mnemonicCode", Utils.SPACE_JOINER.join(mnemonicCode));
+ helper.addValue(toHexString()).add("mnemonicCode", getMnemonicString());
else
helper.addValue("unencrypted");
return helper.toString();
@@ -200,7 +200,7 @@ public class DeterministicSeed implements EncryptableItem {
}
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) {
@@ -247,6 +247,12 @@ public class DeterministicSeed implements EncryptableItem {
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) {
return decodeMnemonicCode(new String(mnemonicCode, StandardCharsets.UTF_8));
}
