Skip to content

Commit 86deadb

Browse files
authored
Merge pull request #891 from tronprotocol/release_v4.9.2
Release v4.9.2
2 parents 7a61516 + 9eb2b75 commit 86deadb

20 files changed

+2110
-94
lines changed

README.md

Lines changed: 232 additions & 43 deletions
Large diffs are not rendered by default.

src/main/java/org/tron/common/enums/NetType.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,17 @@ public enum NetType {
1919
728126428L,
2020
"TFFAMQLZybALaLb4uxHA9RBE7pxhUAjF3U",
2121
"https://open.gasfree.io",
22-
"/tron")
22+
"/tron"),
23+
"TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"
2324
),
2425
NILE("https://nile.trongrid.io",
2526
new Grpc(FULLNODE_NILE, FULLNODE_NILE_SOLIDITY),
2627
new GasFree(
2728
3448148188L,
2829
"THQGuFzL87ZqhxkgqYEryRAd7gqFqL5rdc",
2930
"https://open-test.gasfree.io",
30-
"/nile")
31+
"/nile"),
32+
"TXYZopYRdj2D9XRtbG411XZZ3kM5VkAeBf"
3133
),
3234
SHASTA(
3335
"https://api.shasta.trongrid.io",
@@ -36,18 +38,21 @@ public enum NetType {
3638
2494104990L,
3739
"TSwCtDum13k1PodgNgTWx5be7k1c6eWaNP",
3840
"https://open-test.gasfree.io",
39-
"/shasta")
41+
"/shasta"),
42+
"TG3XXyExBkPp9nzdajDZsozEu4BkaSJozs"
4043
),
41-
CUSTOM(null, null, null);
44+
CUSTOM(null, null, null, null);
4245

4346
private final String http;
4447
private final Grpc grpc;
4548
private final GasFree gasFree;
49+
private final String usdtAddress;
4650

47-
NetType(String http, Grpc grpc, GasFree gasFree) {
51+
NetType(String http, Grpc grpc, GasFree gasFree, String usdtAddress) {
4852
this.http = http;
4953
this.grpc = grpc;
5054
this.gasFree = gasFree;
55+
this.usdtAddress = usdtAddress;
5156
}
5257

5358
@Setter

src/main/java/org/tron/common/utils/ByteUtil.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@
1818

1919
package org.tron.common.utils;
2020

21+
import static org.tron.trident.utils.Numeric.hexStringToByteArray;
22+
2123
import com.google.common.base.Preconditions;
2224
import com.google.common.primitives.UnsignedBytes;
2325
import java.math.BigInteger;
2426
import java.nio.ByteBuffer;
2527
import java.util.ArrayList;
2628
import java.util.Arrays;
2729
import java.util.List;
30+
import org.apache.commons.lang3.StringUtils;
2831
import org.bouncycastle.util.encoders.Hex;
2932

3033
public class ByteUtil {
@@ -415,4 +418,31 @@ public static List<Boolean> convertBytesVectorToVector(final byte[] bytes) {
415418
return ret;
416419
}
417420

421+
public static List<Integer> hexStringToIntegerList(String hexString) {
422+
List<Integer> result = new ArrayList<>();
423+
if (StringUtils.isEmpty(hexString)) {
424+
return result;
425+
}
426+
byte[] bytes = hexStringToByteArray(hexString);
427+
428+
for (int byteIndex = 0; byteIndex < bytes.length; byteIndex++) {
429+
byte currentByte = bytes[byteIndex];
430+
431+
for (int bitIndex = 0; bitIndex < 8; bitIndex++) {
432+
if ((currentByte & (1 << bitIndex)) != 0) {
433+
int value = byteIndex * 8 + bitIndex;
434+
result.add(value);
435+
}
436+
}
437+
}
438+
439+
return result;
440+
}
441+
442+
public static String integerListToHexString(List<Integer> currentOps) {
443+
byte[] operations = new byte[32];
444+
currentOps.forEach(e -> operations[e / 8] |= (1 << e % 8));
445+
return Hex.toHexString(operations);
446+
}
447+
418448
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package org.tron.common.utils;
2+
3+
import org.jline.reader.Candidate;
4+
import org.jline.reader.Completer;
5+
import org.jline.reader.LineReader;
6+
import org.jline.reader.ParsedLine;
7+
8+
import java.util.List;
9+
import java.util.Locale;
10+
11+
public class CaseInsensitiveCommandCompleter implements Completer {
12+
13+
private final String[] commands;
14+
15+
public CaseInsensitiveCommandCompleter(String... commands) {
16+
this.commands = commands;
17+
}
18+
19+
@Override
20+
public void complete(LineReader reader, ParsedLine line, List<Candidate> candidates) {
21+
String buffer = line.word().toLowerCase(Locale.ROOT);
22+
23+
for (String cmd : commands) {
24+
if (cmd.toLowerCase(Locale.ROOT).startsWith(buffer)) {
25+
candidates.add(new Candidate(
26+
cmd,
27+
cmd,
28+
null,
29+
null,
30+
null,
31+
null,
32+
true
33+
));
34+
}
35+
}
36+
}
37+
}
38+

src/main/java/org/tron/common/utils/JsonFormat.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1159,7 +1159,7 @@ private void write(CharSequence data, int size) throws IOException {
11591159
*/
11601160
protected static class Tokenizer {
11611161

1162-
// We use possesive quantifiers (*+ and ++) because otherwise the Java
1162+
// We use possessive quantifiers (*+ and ++) because otherwise the Java
11631163
// regex matcher has stack overflows on large inputs.
11641164
private static final Pattern WHITESPACE =
11651165
Pattern.compile("(\\s|(#.*$))++", Pattern.MULTILINE);

src/main/java/org/tron/common/utils/Utils.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
import org.tron.api.GrpcAPI.TransactionSignWeight;
7272
import org.tron.common.crypto.Hash;
7373
import org.tron.common.crypto.Sha256Sm3Hash;
74+
import org.tron.common.enums.NetType;
7475
import org.tron.core.dao.Tx;
7576
import org.tron.keystore.StringUtils;
7677
import org.tron.keystore.WalletFile;
@@ -131,7 +132,7 @@ public class Utils {
131132

132133
public static final int MIN_LENGTH = 2;
133134
public static final int MAX_LENGTH = 14;
134-
public static final String VERSION = " v4.9.1";
135+
public static final String VERSION = " v4.9.2";
135136
public static final String TRANSFER_METHOD_ID = "a9059cbb";
136137

137138
private static SecureRandom random = new SecureRandom();
@@ -610,7 +611,11 @@ public static Tx getTx(Chain.Transaction transaction) {
610611
tx.setType(contract.getType().name());
611612
tx.setFrom(encode58Check(triggerSmartContract.getOwnerAddress().toByteArray()));
612613
tx.setTo(encode58Check(triggerSmartContract.getContractAddress().toByteArray()));
613-
// setTransferParams(tx, triggerSmartContract);
614+
NetType netType = WalletApi.getCurrentNetwork();
615+
if (netType.getUsdtAddress().equals(encode58Check(triggerSmartContract.getContractAddress().toByteArray()))) {
616+
setTransferParams(tx, triggerSmartContract);
617+
tx.setType(contract.getType().name() + "(transferUSDT)");
618+
}
614619
break;
615620
case UpdateSettingContract:
616621
UpdateSettingContract updateSettingContract =
@@ -1179,6 +1184,10 @@ public static String greenBoldHighlight(int i) {
11791184
return ANSI_BOLD + ANSI_GREEN + i + ANSI_RESET;
11801185
}
11811186

1187+
public static String greenBoldHighlight(long i) {
1188+
return ANSI_BOLD + ANSI_GREEN + i + ANSI_RESET;
1189+
}
1190+
11821191
public static String blueBoldHighlight(String str) {
11831192
return ANSI_BOLD + ANSI_BLUE + str + ANSI_RESET;
11841193
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package org.tron.core.dao;
2+
3+
import lombok.Getter;
4+
import lombok.Setter;
5+
6+
@Getter
7+
@Setter
8+
public class AddressEntry {
9+
private String name;
10+
private String address;
11+
private String note;
12+
13+
public AddressEntry(String name, String address, String note) {
14+
this.name = name;
15+
this.address = address;
16+
this.note = note;
17+
}
18+
19+
@Override
20+
public String toString() {
21+
return String.format("%-15s %-35s %s", name, address, note == null ? "" : note);
22+
}
23+
24+
public String toFileString() {
25+
return String.join(",", name, address, note == null ? "" : note);
26+
}
27+
28+
public String getDisplayString(int index) {
29+
return String.format("%d. %s (%s) - %s", index, name, address, note);
30+
}
31+
}

src/main/java/org/tron/core/manager/TxHistoryManager.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,20 @@ public class TxHistoryManager {
5151
}
5252
}
5353

54+
public TxHistoryManager() {
55+
this.currentUserAddress = null;
56+
}
57+
5458
public TxHistoryManager(String currentUserAddress) {
5559
this.currentUserAddress = Objects.requireNonNull(currentUserAddress);
5660
ensureBaseDirectoryExists();
5761
}
5862

59-
private Path getNetworkFilePath(NetType network) {
63+
public Path getNetworkFilePath(NetType network) {
6064
return Paths.get(BASE_DIR, network.name(), HISTORY_FILE);
6165
}
6266

63-
private void ensureNetworkDirectoryExists(NetType network) {
67+
public void ensureNetworkDirectoryExists(NetType network) {
6468
try {
6569
Files.createDirectories(Paths.get(BASE_DIR, network.name()));
6670
} catch (IOException e) {
@@ -240,7 +244,7 @@ private String txToLine(Tx tx) {
240244
);
241245
}
242246

243-
private Optional<Tx> lineToTx(String line) {
247+
public Optional<Tx> lineToTx(String line) {
244248
try {
245249
String[] parts = line.split(",");
246250
if (parts.length != 8) return Optional.empty();

0 commit comments

Comments
 (0)