mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-14 19:25:51 +00:00
Replace use of Charset.forName() with Guava Charsets constants.
This commit is contained in:
parent
b50eddb0a2
commit
4300b2ee40
@ -20,10 +20,10 @@ package org.bitcoinj.core;
|
||||
|
||||
import org.bitcoinj.crypto.*;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.primitives.Ints;
|
||||
import com.google.common.primitives.UnsignedBytes;
|
||||
import org.bitcoin.NativeSecp256k1;
|
||||
import org.bitcoin.NativeSecp256k1Util;
|
||||
@ -53,7 +53,6 @@ import javax.annotation.Nullable;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.math.BigInteger;
|
||||
import java.nio.charset.Charset;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.SignatureException;
|
||||
import java.util.Arrays;
|
||||
@ -885,7 +884,7 @@ public class ECKey implements EncryptableItem {
|
||||
sigData[0] = (byte)headerByte;
|
||||
System.arraycopy(Utils.bigIntegerToBytes(sig.r, 32), 0, sigData, 1, 32);
|
||||
System.arraycopy(Utils.bigIntegerToBytes(sig.s, 32), 0, sigData, 33, 32);
|
||||
return new String(Base64.encode(sigData), Charset.forName("UTF-8"));
|
||||
return new String(Base64.encode(sigData), Charsets.UTF_8);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
package org.bitcoinj.core;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Objects;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
@ -97,11 +98,11 @@ public class RejectMessage extends Message {
|
||||
|
||||
@Override
|
||||
public void bitcoinSerializeToStream(OutputStream stream) throws IOException {
|
||||
byte[] messageBytes = message.getBytes("UTF-8");
|
||||
byte[] messageBytes = message.getBytes(Charsets.UTF_8);
|
||||
stream.write(new VarInt(messageBytes.length).encode());
|
||||
stream.write(messageBytes);
|
||||
stream.write(code.code);
|
||||
byte[] reasonBytes = reason.getBytes("UTF-8");
|
||||
byte[] reasonBytes = reason.getBytes(Charsets.UTF_8);
|
||||
stream.write(new VarInt(reasonBytes.length).encode());
|
||||
stream.write(reasonBytes);
|
||||
if ("block".equals(message) || "tx".equals(message))
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
package org.bitcoinj.core;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.net.InetAddresses;
|
||||
|
||||
@ -172,7 +173,7 @@ public class VersionMessage extends Message {
|
||||
Utils.uint32ToByteStreamLE(0, buf);
|
||||
Utils.uint32ToByteStreamLE(0, buf);
|
||||
// Now comes subVer.
|
||||
byte[] subVerBytes = subVer.getBytes("UTF-8");
|
||||
byte[] subVerBytes = subVer.getBytes(Charsets.UTF_8);
|
||||
buf.write(new VarInt(subVerBytes.length).encode());
|
||||
buf.write(subVerBytes);
|
||||
// Size of known block chain.
|
||||
|
@ -22,6 +22,7 @@ import org.bitcoinj.core.Utils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Stopwatch;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
@ -87,7 +88,7 @@ public class MnemonicCode {
|
||||
* is supplied the digest of the words will be checked.
|
||||
*/
|
||||
public MnemonicCode(InputStream wordstream, String wordListDigest) throws IOException, IllegalArgumentException {
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(wordstream, "UTF-8"));
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(wordstream, Charsets.UTF_8));
|
||||
this.wordList = new ArrayList<>(2048);
|
||||
MessageDigest md = Sha256Hash.newDigest();
|
||||
String word;
|
||||
|
@ -25,6 +25,9 @@ package org.bitcoinj.crypto;
|
||||
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
@ -71,13 +74,13 @@ public class PBKDF2SHA512 {
|
||||
byte[] U_LAST = null;
|
||||
byte[] U_XOR = null;
|
||||
|
||||
SecretKeySpec key = new SecretKeySpec(P.getBytes("UTF-8"), "HmacSHA512");
|
||||
SecretKeySpec key = new SecretKeySpec(P.getBytes(Charsets.UTF_8), "HmacSHA512");
|
||||
Mac mac = Mac.getInstance(key.getAlgorithm());
|
||||
mac.init(key);
|
||||
|
||||
for (int j = 0; j < c; j++) {
|
||||
if (j == 0) {
|
||||
byte[] baS = S.getBytes("UTF-8");
|
||||
byte[] baS = S.getBytes(Charsets.UTF_8);
|
||||
byte[] baI = INT(i);
|
||||
byte[] baU = new byte[baS.length + baI.length];
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
package org.bitcoinj.core;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.collect.*;
|
||||
import org.bitcoinj.core.listeners.*;
|
||||
import org.bitcoinj.params.TestNet3Params;
|
||||
@ -42,7 +43,6 @@ import java.io.OutputStream;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketException;
|
||||
import java.nio.channels.CancelledKeyException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@ -774,7 +774,7 @@ public class PeerTest extends TestWithNetworkConnections {
|
||||
Transaction t2 = new Transaction(PARAMS);
|
||||
t2.setLockTime(999999);
|
||||
// Add a fake input to t3 that goes nowhere.
|
||||
Sha256Hash t3 = Sha256Hash.of("abc".getBytes(Charset.forName("UTF-8")));
|
||||
Sha256Hash t3 = Sha256Hash.of("abc".getBytes(Charsets.UTF_8));
|
||||
t2.addInput(new TransactionInput(PARAMS, t2, new byte[]{}, new TransactionOutPoint(PARAMS, 0, t3)));
|
||||
t2.getInput(0).setSequenceNumber(0xDEADBEEF);
|
||||
t2.addOutput(COIN, new ECKey());
|
||||
|
@ -39,7 +39,6 @@ import org.slf4j.LoggerFactory;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.math.BigInteger;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.*;
|
||||
|
||||
import static org.bitcoinj.core.Utils.HEX;
|
||||
@ -255,7 +254,7 @@ public class ScriptTest {
|
||||
} else if (w.length() >= 2 && w.startsWith("'") && w.endsWith("'")) {
|
||||
// Single-quoted string, pushed as data. NOTE: this is poor-man's
|
||||
// parsing, spaces/tabs/newlines in single-quoted strings won't work.
|
||||
Script.writeBytes(out, w.substring(1, w.length() - 1).getBytes(Charset.forName("UTF-8")));
|
||||
Script.writeBytes(out, w.substring(1, w.length() - 1).getBytes(Charsets.UTF_8));
|
||||
} else if (ScriptOpCodes.getOpCode(w) != OP_INVALIDOPCODE) {
|
||||
// opcode, e.g. OP_ADD or OP_1:
|
||||
out.write(ScriptOpCodes.getOpCode(w));
|
||||
|
Loading…
x
Reference in New Issue
Block a user