From 09286a932c580c6fef62c5b1ef05f0299db8fdd8 Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Tue, 24 Jun 2014 14:11:09 +0200 Subject: [PATCH] Remove some superfluous new String() calls around HEX.encode, now it has a sane API. --- .../main/java/com/google/bitcoin/crypto/DeterministicKey.java | 4 ++-- .../java/com/google/bitcoin/wallet/DeterministicSeed.java | 2 +- core/src/test/java/com/google/bitcoin/crypto/BIP32Test.java | 2 +- core/src/test/java/com/google/bitcoin/crypto/HDUtilsTest.java | 2 +- .../test/java/com/google/bitcoin/crypto/MnemonicCodeTest.java | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/com/google/bitcoin/crypto/DeterministicKey.java b/core/src/main/java/com/google/bitcoin/crypto/DeterministicKey.java index d239f0bab..110c45325 100644 --- a/core/src/main/java/com/google/bitcoin/crypto/DeterministicKey.java +++ b/core/src/main/java/com/google/bitcoin/crypto/DeterministicKey.java @@ -427,7 +427,7 @@ public class DeterministicKey extends ECKey { @Override public String toString() { - return String.format("pub:%s chaincode:%s path:%s", new String(HEX.encode(getPubKey())), - new String(HEX.encode(getChainCode())), getPathAsString()); + return String.format("pub:%s chaincode:%s path:%s", HEX.encode(getPubKey()), + HEX.encode(getChainCode()), getPathAsString()); } } diff --git a/core/src/main/java/com/google/bitcoin/wallet/DeterministicSeed.java b/core/src/main/java/com/google/bitcoin/wallet/DeterministicSeed.java index 50c7807fb..2d1c2d81d 100644 --- a/core/src/main/java/com/google/bitcoin/wallet/DeterministicSeed.java +++ b/core/src/main/java/com/google/bitcoin/wallet/DeterministicSeed.java @@ -94,7 +94,7 @@ public class DeterministicSeed implements EncryptableItem { @Nullable public String toHexString() { if (unencryptedSeed != null) - return new String(HEX.encode(unencryptedSeed)); + return HEX.encode(unencryptedSeed); else return null; } diff --git a/core/src/test/java/com/google/bitcoin/crypto/BIP32Test.java b/core/src/test/java/com/google/bitcoin/crypto/BIP32Test.java index 8419ffd62..10bef3e8f 100644 --- a/core/src/test/java/com/google/bitcoin/crypto/BIP32Test.java +++ b/core/src/test/java/com/google/bitcoin/crypto/BIP32Test.java @@ -144,7 +144,7 @@ public class BIP32Test { } private String testEncode(String what) throws AddressFormatException { - return new String(HEX.encode(Base58.decodeChecked(what))); + return HEX.encode(Base58.decodeChecked(what)); } static class HDWTestVector { diff --git a/core/src/test/java/com/google/bitcoin/crypto/HDUtilsTest.java b/core/src/test/java/com/google/bitcoin/crypto/HDUtilsTest.java index 7bfbf0ad7..ef7e86d1c 100644 --- a/core/src/test/java/com/google/bitcoin/crypto/HDUtilsTest.java +++ b/core/src/test/java/com/google/bitcoin/crypto/HDUtilsTest.java @@ -122,6 +122,6 @@ public class HDUtilsTest { @Test public void testLongToByteArray() throws Exception { byte[] bytes = HDUtils.longTo4ByteArray(1026); - Assert.assertEquals("00000402", new String(HEX.encode(bytes))); + Assert.assertEquals("00000402", HEX.encode(bytes)); } } diff --git a/core/src/test/java/com/google/bitcoin/crypto/MnemonicCodeTest.java b/core/src/test/java/com/google/bitcoin/crypto/MnemonicCodeTest.java index 803d4360e..d84b3a50e 100644 --- a/core/src/test/java/com/google/bitcoin/crypto/MnemonicCodeTest.java +++ b/core/src/test/java/com/google/bitcoin/crypto/MnemonicCodeTest.java @@ -169,9 +169,9 @@ public class MnemonicCodeTest { byte[] seed = MnemonicCode.toSeed(code, "TREZOR"); byte[] entropy = mc.toEntropy(split(vecCode)); - assertEquals(vecData, new String(HEX.encode(entropy))); + assertEquals(vecData, HEX.encode(entropy)); assertEquals(vecCode, Joiner.on(' ').join(code)); - assertEquals(vecSeed, new String(HEX.encode(seed))); + assertEquals(vecSeed, HEX.encode(seed)); } }