mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2024-11-20 10:12:19 +01:00
Utils: Inline join().
This commit is contained in:
parent
82fb22a884
commit
afc198600a
@ -126,6 +126,6 @@ public class AddressMessage extends Message {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "addr: " + Utils.join(addresses);
|
||||
return "addr: " + Utils.SPACE_JOINER.join(addresses);
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ public class GetBlocksMessage extends Message {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "getblocks: " + Utils.join(locator);
|
||||
return "getblocks: " + Utils.SPACE_JOINER.join(locator);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -37,7 +37,7 @@ public class GetHeadersMessage extends GetBlocksMessage {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "getheaders: " + Utils.join(locator);
|
||||
return "getheaders: " + Utils.SPACE_JOINER.join(locator);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -54,7 +54,7 @@ public class Utils {
|
||||
public static final String BITCOIN_SIGNED_MESSAGE_HEADER = "Bitcoin Signed Message:\n";
|
||||
public static final byte[] BITCOIN_SIGNED_MESSAGE_HEADER_BYTES = BITCOIN_SIGNED_MESSAGE_HEADER.getBytes(Charsets.UTF_8);
|
||||
|
||||
private static final Joiner SPACE_JOINER = Joiner.on(" ");
|
||||
public static final Joiner SPACE_JOINER = Joiner.on(" ");
|
||||
|
||||
private static BlockingQueue<Boolean> mockSleepQueue;
|
||||
|
||||
@ -411,18 +411,6 @@ public class Utils {
|
||||
return iso8601.format(dateTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string containing the string representation of the given items,
|
||||
* delimited by a single space character.
|
||||
*
|
||||
* @param items the items to join
|
||||
* @param <T> the item type
|
||||
* @return the joined space-delimited string
|
||||
*/
|
||||
public static <T> String join(Iterable<T> items) {
|
||||
return SPACE_JOINER.join(items);
|
||||
}
|
||||
|
||||
public static byte[] copyOf(byte[] in, int length) {
|
||||
byte[] out = new byte[length];
|
||||
System.arraycopy(in, 0, out, 0, Math.min(length, in.length));
|
||||
|
@ -127,7 +127,7 @@ public class MnemonicCode {
|
||||
// used as a pseudo-random function. Desired length of the
|
||||
// derived key is 512 bits (= 64 bytes).
|
||||
//
|
||||
String pass = Utils.join(words);
|
||||
String pass = Utils.SPACE_JOINER.join(words);
|
||||
String salt = "mnemonic" + passphrase;
|
||||
|
||||
final Stopwatch watch = Stopwatch.createStarted();
|
||||
|
@ -135,7 +135,7 @@ public class Script {
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return Utils.join(chunks);
|
||||
return Utils.SPACE_JOINER.join(chunks);
|
||||
}
|
||||
|
||||
/** Returns the serialized program as a newly created byte array. */
|
||||
|
@ -1319,7 +1319,7 @@ public class DeterministicKeyChain implements EncryptableKeyChain {
|
||||
builder.append("Seed is encrypted\n");
|
||||
} else if (includePrivateKeys) {
|
||||
final List<String> words = seed.getMnemonicCode();
|
||||
builder.append("Seed as words: ").append(Utils.join(words)).append('\n');
|
||||
builder.append("Seed as words: ").append(Utils.SPACE_JOINER.join(words)).append('\n');
|
||||
builder.append("Seed as hex: ").append(seed.toHexString()).append('\n');
|
||||
}
|
||||
builder.append("Seed birthday: ").append(seed.getCreationTimeSeconds()).append(" [")
|
||||
|
@ -134,7 +134,7 @@ public class DeterministicSeed implements EncryptableItem {
|
||||
public String toString() {
|
||||
return isEncrypted()
|
||||
? "DeterministicSeed [encrypted]"
|
||||
: "DeterministicSeed " + toHexString() + " " + Utils.join(mnemonicCode);
|
||||
: "DeterministicSeed " + toHexString() + " " + Utils.SPACE_JOINER.join(mnemonicCode);
|
||||
}
|
||||
|
||||
/** Returns the seed as hex or null if encrypted. */
|
||||
@ -188,7 +188,7 @@ public class DeterministicSeed implements EncryptableItem {
|
||||
}
|
||||
|
||||
private byte[] getMnemonicAsBytes() {
|
||||
return Utils.join(mnemonicCode).getBytes(Charsets.UTF_8);
|
||||
return Utils.SPACE_JOINER.join(mnemonicCode).getBytes(Charsets.UTF_8);
|
||||
}
|
||||
|
||||
public DeterministicSeed decrypt(KeyCrypter crypter, String passphrase, KeyParameter aesKey) {
|
||||
|
@ -171,7 +171,7 @@ public class MnemonicCodeTest {
|
||||
byte[] entropy = mc.toEntropy(split(vecCode));
|
||||
|
||||
assertEquals(vecData, HEX.encode(entropy));
|
||||
assertEquals(vecCode, Utils.join(code));
|
||||
assertEquals(vecCode, Utils.SPACE_JOINER.join(code));
|
||||
assertEquals(vecSeed, HEX.encode(seed));
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,6 @@ public class BackupToMnemonicSeed {
|
||||
System.out.println("seed: " + seed.toString());
|
||||
|
||||
System.out.println("creation time: " + seed.getCreationTimeSeconds());
|
||||
System.out.println("mnemonicCode: " + Utils.join(seed.getMnemonicCode()));
|
||||
System.out.println("mnemonicCode: " + Utils.SPACE_JOINER.join(seed.getMnemonicCode()));
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ public class WalletSettingsController {
|
||||
// Set the mnemonic seed words.
|
||||
final List<String> mnemonicCode = seed.getMnemonicCode();
|
||||
checkNotNull(mnemonicCode); // Already checked for encryption.
|
||||
String origWords = Utils.join(mnemonicCode);
|
||||
String origWords = Utils.SPACE_JOINER.join(mnemonicCode);
|
||||
wordsArea.setText(origWords);
|
||||
|
||||
// Validate words as they are being typed.
|
||||
|
Loading…
Reference in New Issue
Block a user