前提
- 导入springboot 工程
- 导入wallet-cli 到maven中
properties 配置信息
server.port=8080
#密匙
trc20.privateKey=xxxxx
#trx地址
trc20.trxAddress=xxxx
#合约地址 币种
trc20.symbol=LIUJH#TW2VVpjBCZVEAGVrTHftjGPFMHLLWSEV4z
#币种 位数
trc20.wei=TRX#6,LIUJH#18
# http 地址
trc20.http=xxxx
# solidity 地址
trc20.walletSolidityHttp=xxx
#钱包消费最大区块深度
tron_block_deep=100
#初始高度
tron_block=10000
# 手续费 1trx
trc20.fee=1000000
# Redis数据库索引(默认为0)
spring.redis.database=0
# Redis服务器地址
spring.redis.host=000000
# Redis服务器连接端口
spring.redis.port=6379
# Redis服务器连接密码(默认为空)
spring.redis.password=00000
# 连接池最大连接数(使用负值表示没有限制)
spring.redis.jedis.pool.max-active=20
# 连接池最大阻塞等待时间(使用负值表示没有限制)
spring.redis.jedis.pool.max-wait=-1
# 连接池中的最大空闲连接
spring.redis.jedis.pool.max-idle=10
# 连接池中的最小空闲连接
spring.redis.jedis.pool.min-idle=0
# 连接超时时间(毫秒)
spring.redis.timeout=1000
Service类各种接口主要代码
package com.tron.demo.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.protobuf.Any;
import com.tron.demo.util.TransformUtil;
import org.apache.commons.codec.binary.Hex;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.util.DigestUtils;
import org.springframework.web.client.RestTemplate;
import org.tron.api.GrpcAPI;
import org.tron.common.crypto.SignInterface;
import org.tron.common.crypto.SignUtils;
import org.tron.common.utils.ByteArray;
import org.tron.common.utils.Utils;
import org.tron.protos.Protocol;
import org.tron.protos.contract.BalanceContract;
import org.tron.protos.contract.SmartContractOuterClass;
import org.tron.walletserver.WalletApi;
import javax.annotation.PostConstruct;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
@Service
public class TRC20Service {
private static String privateKey;
private static String trxAddress;
private static String http;
private static String walletSolidityHttp;
private static String privateHttp;
private static Long blockNum;
private static Long blockDeep;
private static Long fee;
private static Map<String, String> symbolMap;
private static Map<String, String> contractMap;
private static Map<String, Integer> weiMap;
private BigInteger currentBlock = BigInteger.ZERO;
@Autowired
private Environment environment;
@Autowired
private StringRedisTemplate stringRedisTemplate;
@PostConstruct
public void initService() {
privateKey = environment.getProperty("trc20.privateKey");
trxAddress = environment.getProperty("trc20.trxAddress");
String symbol = environment.getProperty("trc20.symbol");
String wei = environment.getProperty("trc20.wei");
http = environment.getProperty("trc20.http");
walletSolidityHttp = environment.getProperty("trc20.walletSolidityHttp");
blockDeep = Long.valueOf(Objects.requireNonNull(environment.getProperty("tron_block_deep")));
String tronBlock = stringRedisTemplate.opsForValue().get("tron_block");
if (StringUtils.isEmpty(tronBlock)) {
stringRedisTemplate.opsForValue().set("tron_block", Objects.requireNonNull(environment.getProperty("tron_block")));
}
fee = Long.valueOf(Objects.requireNonNull(environment.getProperty("trc20.fee")));
String[] symbols = symbol.split(",");
symbolMap = new HashMap<>();
contractMap = new HashMap<>();
for (String s : symbols) {
symbolMap.put(s.split("#")[0], s.split("#")[1]);
contractMap.put(s.split("#")[1], s.split("#")[0]);
}
String[] weis = wei.split(",");
weiMap = new HashMap<>();
for (String s : weis) {
weiMap.put(s.split("#")[0], Integer.valueOf(s.split("#")[1]));
}
}
public static String createAddress() {
SignInterface sign = SignUtils.getGeneratedRandomSign(Utils.getRandom(), true);
byte[] priKey = sign.getPrivateKey();
byte[] address = sign.getAddress();
String priKeyStr = Hex.encodeHexString(priKey);
String base58check = WalletApi.encode58Check(address);
String hexString = ByteArray.toHexString(address);
JSONObject jsonAddress = new JSONObject();
jsonAddress.put("address", base58check);
jsonAddress.put("hexAddress", hexString);
jsonAddress.put("privateKey", priKeyStr);
return jsonAddress.toJSONString();
}
public static String createAccount(String address) {
String url = http + "/wallet/createaccount";
Map<String, Object> map = new HashMap<>();
map.put("owner_address", ByteArray.toHexString(WalletApi.decodeFromBase58Check(trxAddress)));
map.put("account_address", ByteArray.toHexString(WalletApi.decodeFromBase58Check(address)));
String param = JSON.toJSONString(map);
return signAndBroadcast(postForEntity(url, param).getBody(), privateKey);
}
public static String getAccount(String address) {
String url = http + "/wallet/getaccount";
Map<String, Object> map = new HashMap<>();
map.put("address", ByteArray.toHexString(WalletApi.decodeFromBase58Check(address)));
String param = JSON.toJSONString(map);
return postForEntity(url, param).getBody();
}
public static String getTrc20Account(String symbol, String address) {
String url = http + "/wallet/triggerconstantcontract";
Map<String, Object> map = new HashMap<>();
address = TransformUtil.addZeroForNum(ByteArray.toHexString(WalletApi.decodeFromBase58Check(address)), 64);
map.put("contract_address", ByteArray.toHexString(WalletApi.decodeFromBase58Check(symbolMap.get(symbol))));
map.put("function_selector", "balanceOf(address)");
map.put("parameter", address);
map.put("owner_address", ByteArray.toHexString(WalletApi.decodeFromBase58Check(trxAddress)));
String param = JSON.toJSONString(map);
return postForEntity(url, param).getBody();
}
public static String trc20Transaction(String symbol, String toAddress, BigDecimal amount) {
String url = http + "/wallet/triggersmartcontract";
Map<String, Object> map = new HashMap<>();
String to_address = ByteArray.toHexString(WalletApi.decodeFromBase58Check(toAddress));
to_address = TransformUtil.addZeroForNum(to_address, 64);
amount = amount.multiply(new BigDecimal(1 + TransformUtil.getSeqNumByLong(0L, weiMap.get(symbol))));
String uint256 = TransformUtil.addZeroForNum(amount.toBigInteger().toString(16), 64);
map.put("owner_address", ByteArray.toHexString(WalletApi.decodeFromBase58Check(trxAddress)));
map.put("contract_address", ByteArray.toHexString(WalletApi.decodeFromBase58Check(symbolMap.get(symbol))));
map.put("function_selector", "transfer(address,uint256)");
map.put("parameter", to_address + uint256);
map.put("call_value", 0);
map.put("fee_limit", fee);
String param = JSON.toJSONString(map);
ResponseEntity<String> stringResponseEntity = postForEntity(url, param);
return signAndBroadcast(JSON.parseObject(stringResponseEntity.getBody()).getString("transaction"), privateKey);
}
private static String trc20Transaction(String symbol, String fromAddress, String privateKey, String toAddress, BigDecimal amount) {
String url = http + "/wallet/triggersmartcontract";
Map<String, Object> map = new HashMap<>();
String to_address = ByteArray.toHexString(WalletApi.decodeFromBase58Check(toAddress));
to_address = TransformUtil.addZeroForNum(to_address, 64);
amount = amount.multiply(new BigDecimal(1 + TransformUtil.getSeqNumByLong(0L, weiMap.get(symbol))));
String uint256 = TransformUtil.addZeroForNum(amount.toBigInteger().toString(16), 64);
map.put("owner_address", ByteArray.toHexString(WalletApi.decodeFromBase58Check(fromAddress)));
map.put("contract_address", ByteArray.toHexString(WalletApi.decodeFromBase58Check(symbolMap.get(symbol))));
map.put("function_selector", "transfer(address,uint256)");
map.put("parameter", to_address + uint256);
map.put("call_value", 0);
map.put("fee_limit", fee);
String param = JSON.toJSONString(map);
ResponseEntity<String> stringResponseEntity = postForEntity(url, param);
url = http + "/wallet/gettransactionsign";
map = new HashMap<>();
map.put("transaction", JSON.parseObject(stringResponseEntity.getBody()).get("transaction"));
map.put("privateKey", privateKey);
param = JSON.toJSONString(map);
stringResponseEntity = postForEntity(url, param);
url = http + "/wallet/broadcasttransaction";
stringResponseEntity = postForEntity(url, stringResponseEntity.getBody());
return stringResponseEntity.getBody();
}
private static String signAndBroadcast(String transaction, String privateKey) {
String url = http + "/wallet/gettransactionsign";
Map<String, Object> map = new HashMap<>();
map.put("transaction", transaction);
map.put("privateKey", privateKey);
String param = JSON.toJSONString(map);
ResponseEntity<String> stringResponseEntity = postForEntity(url, param);
url = http + "/wallet/broadcasttransaction";
stringResponseEntity = postForEntity(url, stringResponseEntity.getBody());
return stringResponseEntity.getBody();
}
public static String trxTransaction(String toAddress, BigDecimal amount) {
String url = http + "/wallet/easytransferbyprivate";
Map<String, Object> map = new HashMap<>();
map.put("privateKey", privateKey);
map.put("toAddress", ByteArray.toHexString(WalletApi.decodeFromBase58Check(toAddress)));
amount = amount.multiply(new BigDecimal(1 + TransformUtil.getSeqNumByLong(0L, weiMap.get("TRX"))));
map.put("amount", amount.toBigInteger());
String param = JSON.toJSONString(map);
return postForEntity(url, param).getBody();
}
public static String transaction(String toAddress, BigDecimal amount) {
String url = http + "/wallet/createtransaction";
Map<String, Object> map = new HashMap<>();
map.put("owner_address", ByteArray.toHexString(WalletApi.decodeFromBase58Check(trxAddress)));
map.put("to_address", ByteArray.toHexString(WalletApi.decodeFromBase58Check(toAddress)));
amount = amount.multiply(new BigDecimal(1 + TransformUtil.getSeqNumByLong(0L, weiMap.get("TRX"))));
map.put("amount", amount.toBigInteger());
String param = JSON.toJSONString(map);
return signAndBroadcast(postForEntity(url, param).getBody(), privateKey);
}
public static String getTransactionById(String txId) {
String url = walletSolidityHttp + "/walletsolidity/gettransactionbyid";
Map<String, Object> map = new HashMap<>();
map.put("value", txId);
String param = JSON.toJSONString(map);
return postForEntity(url, param).getBody();
}
public static String getTransactionInfoById(String txId) {
String url = http + "/wallet/gettransactioninfobyid";
Map<String, Object> map = new HashMap<>();
map.put("value", txId);
String param = JSON.toJSONString(map);
return postForEntity(url, param).getBody();
}
public static String getTransactionInfoByBlockNum(BigInteger num) {
String url = http + "/wallet/gettransactioninfobyblocknum";
Map<String, Object> map = new HashMap<>();
map.put("num", num);
String param = JSON.toJSONString(map);
return postForEntity(url, param).getBody();
}
public static String getNowBlock() {
String url = http + "/wallet/getnowblock";
return getForEntity(url);
}
private static ResponseEntity<String> postForEntity(String url, String param) {
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
HttpEntity<String> request = new HttpEntity<>(param, headers);
ResponseEntity<String> result = restTemplate.postForEntity(url, request, String.class);
return result;
}
private static String getForEntity(String url) {
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<String> result = restTemplate.getForEntity(url, String.class);
return result.getBody();
}
public void monitorCoinListener() {
List<String> addressList = new ArrayList<>();
addressList.add("xxxx");
int end = currentBlock.intValue();
for (int i = end; i > 0; i--) {
if (end - i > blockDeep) {
break;
}
httpTransactionInfo(addressList, (long) i);
}
}
private boolean transactionStatus(String txId) {
JSONObject parseObject = JSON.parseObject(getTransactionById(txId));
if (StringUtils.isEmpty(parseObject.toJSONString())) {
return false;
}
String contractRet = parseObject.getJSONArray("ret").getJSONObject(0).getString("contractRet");
return "SUCCESS".equals(contractRet);
}
private void httpTransactionInfo(List<String> addressList, Long num) {
String transactionInfoByBlockNum = getTransactionInfoByBlockNum(BigInteger.valueOf(num));
JSONArray parseArray = JSON.parseArray(transactionInfoByBlockNum);
if (parseArray.size() > 0) {
parseArray.forEach(e -> {
try {
String txId = JSON.parseObject(e.toString()).getString("id");
JSONObject parseObject = JSON.parseObject(getTransactionById(txId));
String contractRet = parseObject.getJSONArray("ret").getJSONObject(0).getString("contractRet");
if ("SUCCESS".equals(contractRet)) {
String type = parseObject.getJSONObject("raw_data").getJSONArray("contract").getJSONObject(0).getString("type");
if ("TriggerSmartContract".equals(type)) {
triggerSmartContract(addressList, txId, parseObject);
} else if ("TransferContract".equals(type)) {
transferContract(parseObject);
}
}
} catch (Exception exception) {
exception.printStackTrace();
}
});
}
}
private void rpcTransactionInfo(List<String> addressList, Long num) {
try {
Optional<GrpcAPI.TransactionInfoList> optional = WalletApi.getTransactionInfoByBlockNum(num);
if (!optional.isPresent()) {
return;
}
List<Protocol.TransactionInfo> transactionInfoList = optional.get().getTransactionInfoList();
for (Protocol.TransactionInfo transactionInfo : transactionInfoList) {
String txId = ByteArray.toHexString(transactionInfo.getId().toByteArray());
Optional<Protocol.Transaction> transaction = WalletApi.getTransactionById(txId);
if (!transaction.isPresent()) {
continue;
}
List<Protocol.Transaction.Result> retList = transaction.get().getRetList();
Protocol.Transaction.Result.contractResult contractRet = retList.get(0).getContractRet();
if (!Protocol.Transaction.Result.contractResult.SUCCESS.name().equals(contractRet.name())) {
continue;
}
Protocol.Transaction.Contract.ContractType type = transaction.get().getRawData().getContract(0).getType();
Any contractParameter = transaction.get().getRawData().getContract(0).getParameter();
if (Protocol.Transaction.Contract.ContractType.TriggerSmartContract.name().equals(type.name())) {
SmartContractOuterClass.TriggerSmartContract deployContract = contractParameter
.unpack(SmartContractOuterClass.TriggerSmartContract.class);
String owner_address = WalletApi.encode58Check(ByteArray.fromHexString(ByteArray.toHexString(deployContract.getOwnerAddress().toByteArray())));
String contract_address = WalletApi.encode58Check(ByteArray.fromHexString(ByteArray.toHexString(deployContract.getContractAddress().toByteArray())));
String dataStr = ByteArray.toHexString(deployContract.getData().toByteArray()).substring(8);
List<String> strList = TransformUtil.getStrList(dataStr, 64);
if (strList.size() != 2) {
continue;
}
String to_address = TransformUtil.delZeroForNum(strList.get(0));
if (!to_address.startsWith("41")) {
to_address = "41" + to_address;
}
to_address = WalletApi.encode58Check(ByteArray.fromHexString(to_address));
String amountStr = TransformUtil.delZeroForNum(strList.get(1));
if (amountStr.length() > 0) {
amountStr = new BigInteger(amountStr, 16).toString(10);
}
BigDecimal amount = BigDecimal.ZERO;
if (!contractMap.containsKey(contract_address)) {
continue;
}
String symbol = contractMap.get(contract_address);
if (StringUtils.isNotEmpty(amountStr)) {
amount = new BigDecimal(amountStr).divide(new BigDecimal(1 + TransformUtil.getSeqNumByLong(0L, weiMap.get(symbol))));
}
for (String address : addressList) {
if (address.equals(to_address)) {
System.out.println("===to_address:" + to_address + "===amount:" + amount);
}
}
} else if (Protocol.Transaction.Contract.ContractType.TransferContract.name().equals(type.name())) {
BalanceContract.TransferContract deployContract = contractParameter
.unpack(BalanceContract.TransferContract.class);
String owner_address = WalletApi.encode58Check(ByteArray.fromHexString(ByteArray.toHexString(deployContract.getOwnerAddress().toByteArray())));
String to_address = WalletApi.encode58Check(ByteArray.fromHexString(ByteArray.toHexString(deployContract.getToAddress().toByteArray())));
BigDecimal amount = new BigDecimal(deployContract.getAmount());
amount = amount.divide(new BigDecimal(1 + TransformUtil.getSeqNumByLong(0L, weiMap.get("TRX"))));
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void transferContract(JSONObject parseObject) {
BigDecimal amount = parseObject.getJSONObject("raw_data").getJSONArray("contract").getJSONObject(0).getJSONObject("parameter").getJSONObject("value").getBigDecimal("amount");
String owner_address = parseObject.getJSONObject("raw_data").getJSONArray("contract").getJSONObject(0).getJSONObject("parameter").getJSONObject("value").getString("owner_address");
owner_address = WalletApi.encode58Check(ByteArray.fromHexString(owner_address));
String to_address = parseObject.getJSONObject("raw_data").getJSONArray("contract").getJSONObject(0).getJSONObject("parameter").getJSONObject("value").getString("to_address");
to_address = WalletApi.encode58Check(ByteArray.fromHexString(to_address));
amount = amount.divide(new BigDecimal(1 + TransformUtil.getSeqNumByLong(0L, weiMap.get("TRX"))));
}
private void triggerSmartContract(List<String> addressList, String txId, JSONObject parseObject) {
String data = parseObject.getJSONObject("raw_data").getJSONArray("contract").getJSONObject(0).getJSONObject("parameter").getJSONObject("value").getString("data");
String owner_address = parseObject.getJSONObject("raw_data").getJSONArray("contract").getJSONObject(0).getJSONObject("parameter").getJSONObject("value").getString("owner_address");
owner_address = WalletApi.encode58Check(ByteArray.fromHexString(owner_address));
String contract_address = parseObject.getJSONObject("raw_data").getJSONArray("contract").getJSONObject(0).getJSONObject("parameter").getJSONObject("value").getString("contract_address");
contract_address = WalletApi.encode58Check(ByteArray.fromHexString(contract_address));
String dataStr = data.substring(8);
List<String> strList = TransformUtil.getStrList(dataStr, 64);
if (strList.size() != 2) {
return;
}
String to_address = TransformUtil.delZeroForNum(strList.get(0));
if (!to_address.startsWith("41")) {
to_address = "41" + to_address;
}
to_address = WalletApi.encode58Check(ByteArray.fromHexString(to_address));
String amountStr = TransformUtil.delZeroForNum(strList.get(1));
if (amountStr.length() > 0) {
amountStr = new BigInteger(amountStr, 16).toString(10);
}
BigDecimal amount = BigDecimal.ZERO;
if (!contractMap.containsKey(contract_address)) {
return;
}
String symbol = contractMap.get(contract_address);
if (StringUtils.isNotEmpty(amountStr)) {
amount = new BigDecimal(amountStr).divide(new BigDecimal(1 + TransformUtil.getSeqNumByLong(0L, weiMap.get(symbol))));
}
for (String address : addressList) {
if (address.equals(to_address)) {
System.out.println("===to_address:" + to_address + "===amount:" + amount);
}
}
}
public void blockDeepListener() {
try {
currentBlock = JSON.parseObject(getNowBlock()).getJSONObject("block_header").getJSONObject("raw_data").getBigInteger("number");
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
public void collectionTrc20Listener() {
try {
Map<String, String> addressMap = new HashMap<>();
addressMap.put("xxx", "xxxx");
String toAddress = "xxx";
String fromAddress = null;
String privateKey = null;
for (String symbol : symbolMap.keySet()) {
for (String key : addressMap.keySet()) {
fromAddress = key;
privateKey = addressMap.get(key);
String trc20Account = getTrc20Account(symbol, fromAddress);
JSONObject jsonObject = JSON.parseObject(trc20Account);
String constant_result = jsonObject.getString("constant_result");
if (StringUtils.isEmpty(constant_result)) {
continue;
}
List<String> strings = JSON.parseArray(constant_result.toString(), String.class);
String data = strings.get(0).replaceAll("^(0+)", "");
if (data.length() == 0) {
continue;
}
String amountStr = new BigInteger(data, 16).toString();
BigDecimal amount = new BigDecimal(amountStr).divide(new BigDecimal(1 + TransformUtil.getSeqNumByLong(0L, weiMap.get(symbol))));
if (amount.compareTo(BigDecimal.ONE) < 0) {
continue;
}
String account = getAccount(fromAddress);
String accountBalance = JSON.parseObject(account).getString("balance");
BigDecimal balance = BigDecimal.ZERO;
if (StringUtils.isNotEmpty(accountBalance)) {
balance = new BigDecimal(accountBalance).divide(new BigDecimal(1 + TransformUtil.getSeqNumByLong(0L, weiMap.get("TRX"))));
}
if (balance.compareTo(new BigDecimal("0.5")) < 0) {
String transaction = transaction(fromAddress, new BigDecimal("0.5"));
continue;
}
String transaction = trc20Transaction(symbol, fromAddress, privateKey, toAddress, amount);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
工具类
package com.tron.demo.util;
import java.util.ArrayList;
import java.util.List;
public class TransformUtil {
public static String addZeroForNum(String str, int strLength) {
int strLen = str.length();
if (strLen < strLength) {
while (strLen < strLength) {
StringBuffer sb = new StringBuffer();
sb.append("0").append(str);
str = sb.toString();
strLen = str.length();
}
}
return str;
}
public static String delZeroForNum(String str) {
return str.replaceAll("^(0+)", "");
}
public static String getSeqNumByLong(Long l, int bitCount) {
return String.format("%0" + bitCount + "d", l);
}
public static String stringToHexString(String s) {
String str = "";
for (int i = 0; i < s.length(); i++) {
int ch = s.charAt(i);
String s4 = Integer.toHexString(ch);
str = str + s4;
}
return str;
}
public static String hexStringToString(String s) {
if (s == null || s.equals("")) {
return null;
}
s = s.replace(" ", "");
byte[] baKeyword = new byte[s.length() / 2];
for (int i = 0; i < baKeyword.length; i++) {
try {
baKeyword[i] = (byte) (0xff & Integer.parseInt(
s.substring(i * 2, i * 2 + 2), 16));
} catch (Exception e) {
e.printStackTrace();
}
}
try {
s = new String(baKeyword, "gbk");
new String();
} catch (Exception e1) {
e1.printStackTrace();
}
return s;
}
public static byte[] hexStringToByteArray(String s) {
int len = s.length();
byte[] b = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
b[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4) + Character
.digit(s.charAt(i + 1), 16));
}
return b;
}
public static final String bytesToHexString(byte[] bArray) {
StringBuffer sb = new StringBuffer(bArray.length);
String sTemp;
for (int i = 0; i < bArray.length; i++) {
sTemp = Integer.toHexString(0xFF & bArray[i]);
if (sTemp.length() < 2)
sb.append(0);
sb.append(sTemp.toUpperCase());
}
return sb.toString();
}
public static int hexToDecimal(String hex) {
int outcome = 0;
for (int i = 0; i < hex.length(); i++) {
char hexChar = hex.charAt(i);
outcome = outcome * 16 + charToDecimal(hexChar);
}
return outcome;
}
public static int charToDecimal(char c) {
if (c >= 'A' && c <= 'F')
return 10 + c - 'A';
else
return c - '0';
}
public static List<String> getStrList(String inputString, int length) {
int size = inputString.length() / length;
if (inputString.length() % length != 0) {
size += 1;
}
return getStrList(inputString, length, size);
}
public static List<String> getStrList(String inputString, int length,
int size) {
List<String> list = new ArrayList<String>();
for (int index = 0; index < size; index++) {
String childStr = substring(inputString, index * length,
(index + 1) * length);
list.add(childStr);
}
return list;
}
public static String substring(String str, int f, int t) {
if (f > str.length())
return null;
if (t > str.length()) {
return str.substring(f, str.length());
} else {
return str.substring(f, t);
}
}
}
参考文档
https://github.com/tronprotocol 官方github
https://cn.developers.tron.network/ 官方对接文档
有什么不对的地方欢迎留言我也好改进 谢谢
关于充值监控有更好的方法也欢迎指导一下小编 谢谢
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)