Skip to content

Commit b2f3b98

Browse files
authored
Merge pull request #846 from tronprotocol/release_v4.8.1
Release v4.8.1
2 parents 2878de0 + 87c1d1f commit b2f3b98

File tree

21 files changed

+1566
-105
lines changed

21 files changed

+1566
-105
lines changed

README.md

Lines changed: 155 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ For more information on a specific command, just type the command on terminal wh
104104
| [GenerateSubAccount](#generate-sub-account) | [ClearWalletKeystore](#clear-wallet-keystore) | [ExportWalletKeystore](#export-import-wallet-keystore) |
105105
| [ImportWalletByKeystore](#export-import-wallet-keystore) | [ImportWalletByLedger](#import-wallet-by-ledger) | [LoginAll](#login-all) |
106106
| [Lock](#lock) | [Unlock](#unlock) | [ResetWallet](#reset-wallet) |
107-
| [CreateAccount](#create-account) | [SwitchWallet](#switch-wallet) |
107+
| [CreateAccount](#create-account) | [SwitchWallet](#switch-wallet) | [SwitchNetwork](#switch-network) |
108+
| [CurrentNetwork](#current-network) | [GasFreeInfo](#gas-free-info) | [GasFreeTransfer](#gas-free-transfer) |
109+
| [GasFreeTrace](#gas-free-trace) | | |
108110

109111

110112
Type any one of the listed commands, to display how-to tips.
@@ -204,10 +206,10 @@ Update the ratio of brokerage, this command is usually used by a witness account
204206
> updateBrokerage OwnerAddress brokerage
205207

206208
OwnerAddress
207-
> The address of the witness's account, it is a base58check type address.
209+
> The witness's account address is a base58check type address.
208210
209211
brokerage
210-
> The ratio of brokerage you want to update to, the limit of it: 0-100.
212+
> The ratio of brokerage you want to update, from 0 to 100. If the input is 10, it means 10% of the total reward would be distributed to the SR and the rest would be rewarded to all the voters, which is 90% in this case
211213
212214
For example:
213215

@@ -1640,6 +1642,156 @@ password:
16401642
unlock successful !!!
16411643
```
16421644

1645+
## switch network
1646+
> SwitchNetwork
1647+
>This command allows for flexible network switching at any time. Unlocking can specify parameters in seconds.
1648+
>`switchnetwork local` will switch to the network configured in local config.conf.
1649+
1650+
Example:
1651+
```console
1652+
wallet> switchnetwork
1653+
Please select network:
1654+
1. MAIN
1655+
2. NILE
1656+
3. SHASTA
1657+
Enter numbers to select a network (1-3):1
1658+
Now, current network is : MAIN
1659+
SwitchNetwork successful !!!
1660+
```
1661+
```console
1662+
wallet> switchnetwork main
1663+
Now, current network is : MAIN
1664+
SwitchNetwork successful !!!
1665+
```
1666+
1667+
```console
1668+
wallet> switchnetwork empty localhost:50052
1669+
Now, current network is : CUSTOM
1670+
SwitchNetwork successful !!!
1671+
```
1672+
1673+
## current network
1674+
> CurrentNetwork
1675+
>View current network.
1676+
1677+
Example:
1678+
```console
1679+
wallet> currentnetwork
1680+
currentNetwork: NILE
1681+
```
1682+
1683+
```console
1684+
wallet> currentnetwork
1685+
current network: CUSTOM
1686+
fullNode: EMPTY, solidityNode: localhost:50052
1687+
```
1688+
1689+
## gas free info
1690+
> GasFreeInfo
1691+
>Get gasfree info of the current address.
1692+
1693+
Example:
1694+
```console
1695+
wallet> gasfreeinfo
1696+
balanceOf(address):70a08231
1697+
{
1698+
"gasFreeAddress":"TCtSt8fCkZcVdrGpaVHUr6P8EmdjysswMF",
1699+
"active":true,
1700+
"tokenBalance":998696000,
1701+
"activateFee":0,
1702+
"transferFee":2000,
1703+
"maxTransferValue":998694000
1704+
}
1705+
gasFreeInfo: successful !!
1706+
```
1707+
1708+
```console
1709+
wallet> gasfreeinfo TRvVXgqddDGYRMx3FWf2tpVxXQQXDZxJQe
1710+
balanceOf(address):70a08231
1711+
{
1712+
"gasFreeAddress":"TCtSt8fCkZcVdrGpaVHUr6P8EmdjysswMF",
1713+
"active":true,
1714+
"tokenBalance":998696000,
1715+
"activateFee":0,
1716+
"transferFee":2000,
1717+
"maxTransferValue":998694000
1718+
}
1719+
gasFreeInfo: successful !!
1720+
```
1721+
1722+
## gas free transfer
1723+
> GasFreeTransfer
1724+
>Transfer funds through gas-free.
1725+
1726+
Example:
1727+
```console
1728+
wallet> gasfreetransfer TEkj3ndMVEmFLYaFrATMwMjBRZ1EAZkucT 100000
1729+
1730+
GasFreeTransfer result: {
1731+
"code":200,
1732+
"data":{
1733+
"amount":100000,
1734+
"providerAddress":"TKtWbdzEq5ss9vTS9kwRhBp5mXmBfBns3E",
1735+
"apiKey":"",
1736+
"accountAddress":"TUUSMd58eC3fKx3fn7whxJyr1FR56tgaP8",
1737+
"signature":"",
1738+
"targetAddress":"TEkj3ndMVEmFLYaFrATMwMjBRZ1EAZkucT",
1739+
"maxFee":2000000,
1740+
"version":1,
1741+
"nonce":8,
1742+
"tokenAddress":"TXYZopYRdj2D9XRtbG411XZZ3kM5VkAeBf",
1743+
"createdAt":1747909635678,
1744+
"expiredAt":1747909695000,
1745+
"estimatedTransferFee":2000,
1746+
"id":"6c3ff67e-0bf4-4c09-91ca-0c7c254b01a0",
1747+
"state":"WAITING",
1748+
"estimatedActivateFee":0,
1749+
"gasFreeAddress":"TNER12mMVWruqopsW9FQtKxCGfZcEtb3ER",
1750+
"updatedAt":1747909635678
1751+
}
1752+
}
1753+
GasFreeTransfer successful !!!
1754+
```
1755+
1756+
## gas free trace
1757+
> GasFreeTrace
1758+
>Query GasFreeTrace to obtain transfer details by using the transaction ID returned by GasFreeTransfer as the traceId.
1759+
1760+
Example:
1761+
```console
1762+
wallet> gasfreetrace 6c3ff67e-0bf4-4c09-91ca-0c7c254b01a0
1763+
GasFreeTrace result: {
1764+
"code":200,
1765+
"data":{
1766+
"amount":100000,
1767+
"providerAddress":"TKtWbdzEq5ss9vTS9kwRhBp5mXmBfBns3E",
1768+
"txnTotalCost":102000,
1769+
"accountAddress":"TUUSMd58eC3fKx3fn7whxJyr1FR56tgaP8",
1770+
"txnActivateFee":0,
1771+
"estimatedTotalCost":102000,
1772+
"targetAddress":"TEkj3ndMVEmFLYaFrATMwMjBRZ1EAZkucT",
1773+
"txnBlockTimestamp":1747909638000,
1774+
"txnTotalFee":2000,
1775+
"nonce":8,
1776+
"estimatedTotalFee":2000,
1777+
"tokenAddress":"TXYZopYRdj2D9XRtbG411XZZ3kM5VkAeBf",
1778+
"txnHash":"858f9a00776163b1f8a34467b9c5727657f8971a9f4e9d492f0a247fac0384f9",
1779+
"txnBlockNum":57175988,
1780+
"createdAt":1747909635678,
1781+
"expiredAt":1747909695000,
1782+
"estimatedTransferFee":2000,
1783+
"txnState":"ON_CHAIN",
1784+
"id":"6c3ff67e-0bf4-4c09-91ca-0c7c254b01a0",
1785+
"state":"CONFIRMING",
1786+
"estimatedActivateFee":0,
1787+
"gasFreeAddress":"TNER12mMVWruqopsW9FQtKxCGfZcEtb3ER",
1788+
"txnTransferFee":2000,
1789+
"txnAmount":100000
1790+
}
1791+
}
1792+
GasFreeTrace: successful!!
1793+
```
1794+
16431795
## switch wallet
16441796
> SwitchWallet
16451797
>After logging in with the LoginAll command, you can switch wallets

build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ dependencies {
9393
}
9494
implementation group: 'org.hid4java', name: 'hid4java', version: '0.8.0'
9595
//implementation 'javax.annotation:javax.annotation-api:1.3.2'
96+
implementation("com.squareup.okhttp3:okhttp:4.12.0")
97+
implementation("io.github.tronprotocol:trident:0.10.0") {
98+
exclude group: "com.google.guava", module: "guava"
99+
}
100+
96101
}
97102

98103
protobuf {

src/main/java/org/tron/common/crypto/ECKey.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public ECKey(SecureRandom secureRandom) {
179179
* <p>All private key operations will use the provider.
180180
*/
181181

182-
// isPrivateKey true 私钥 其他公钥
182+
// isPrivateKey true
183183
public ECKey(byte[] key, boolean isPrivateKey) {
184184
if (isPrivateKey) {
185185
BigInteger pk = new BigInteger(1, key);
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package org.tron.common.enums;
2+
3+
import lombok.Getter;
4+
import lombok.Setter;
5+
6+
@Getter
7+
public enum NetType {
8+
MAIN(
9+
"https://api.trongrid.io",
10+
new Grpc("grpc.trongrid.io:50051", "grpc.trongrid.io:50052"),
11+
new GasFree(
12+
728126428L,
13+
"TFFAMQLZybALaLb4uxHA9RBE7pxhUAjF3U",
14+
"https://open.gasfree.io",
15+
"/tron")
16+
),
17+
NILE("https://nile.trongrid.io",
18+
new Grpc("grpc.nile.trongrid.io:50051", "grpc.nile.trongrid.io:50061"),
19+
new GasFree(
20+
3448148188L,
21+
"THQGuFzL87ZqhxkgqYEryRAd7gqFqL5rdc",
22+
"https://open-test.gasfree.io",
23+
"/nile")
24+
),
25+
SHASTA(
26+
"https://api.shasta.trongrid.io",
27+
new Grpc("grpc.shasta.trongrid.io:50051", "grpc.shasta.trongrid.io:50052"),
28+
new GasFree(
29+
2494104990L,
30+
"TSwCtDum13k1PodgNgTWx5be7k1c6eWaNP",
31+
"https://open-test.gasfree.io",
32+
"/shasta")
33+
),
34+
CUSTOM(null, null, null);
35+
36+
private final String http;
37+
private final Grpc grpc;
38+
private final GasFree gasFree;
39+
40+
NetType(String http, Grpc grpc, GasFree gasFree) {
41+
this.http = http;
42+
this.grpc = grpc;
43+
this.gasFree = gasFree;
44+
}
45+
46+
@Setter
47+
@Getter
48+
public static class Grpc {
49+
public Grpc(String fullNode, String solidityNode) {
50+
this.fullNode = fullNode;
51+
this.solidityNode = solidityNode;
52+
}
53+
54+
private String fullNode;
55+
private String solidityNode;
56+
}
57+
58+
@Setter
59+
@Getter
60+
public static class GasFree {
61+
private long chainId;
62+
private String verifyingContract;
63+
private String httpUrl;
64+
private String apiPrefix;
65+
66+
public GasFree(long chainId, String verifyingContract, String httpUrl, String apiPrefix) {
67+
this.chainId = chainId;
68+
this.verifyingContract = verifyingContract;
69+
this.httpUrl = httpUrl;
70+
this.apiPrefix = apiPrefix;
71+
}
72+
73+
74+
}
75+
}
76+
77+
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package org.tron.common.utils;
2+
3+
import java.net.InetAddress;
4+
import java.net.UnknownHostException;
5+
import java.util.regex.Pattern;
6+
7+
public class DomainValidator {
8+
private static final Pattern DOMAIN_PATTERN = Pattern.compile(
9+
"^((?!-)[A-Za-z0-9-]{1,63}(?<!-)\\.)+" +
10+
"([A-Za-z]{2,63}|xn--[A-Za-z0-9]{1,59})$"
11+
);
12+
13+
// IPv4
14+
private static final Pattern IPV4_PATTERN = Pattern.compile(
15+
"^((25[0-5]|2[0-4]\\d|1\\d{2}|[1-9]?\\d)(\\.|$)){4}$"
16+
);
17+
18+
// IPv6
19+
public static boolean isIPv6(String input) {
20+
try {
21+
InetAddress address = InetAddress.getByName(input);
22+
return address.getHostAddress().contains(":");
23+
} catch (UnknownHostException e) {
24+
return false;
25+
}
26+
}
27+
28+
public static boolean isIPv4(String input) {
29+
return IPV4_PATTERN.matcher(input).matches();
30+
}
31+
32+
public static boolean isDomain(String input) {
33+
return DOMAIN_PATTERN.matcher(input).matches();
34+
}
35+
36+
public static boolean isDomainOrIP(String input) {
37+
if (input == null || input.isEmpty()) return false;
38+
if ("localhost".equalsIgnoreCase(input)) return true;
39+
return isIPv4(input) || isDomain(input);
40+
}
41+
}

0 commit comments

Comments
 (0)