pom.xml | ●●●●● patch | view | raw | blame | history | |
src/main/java/com/xcong/excoin/modules/blackchain/service/TrxUsdtUpdateService.java | ●●●●● patch | view | raw | blame | history | |
src/main/java/com/xcong/excoin/modules/coin/service/impl/BlockCoinServiceImpl.java | ●●●●● patch | view | raw | blame | history | |
src/main/resources/application.yml | ●●●●● patch | view | raw | blame | history | |
src/test/java/com/xcong/excoin/TradeTest.java | ●●●●● patch | view | raw | blame | history |
pom.xml
@@ -37,6 +37,57 @@ <dependencies> <dependency> <groupId>io.grpc</groupId> <artifactId>grpc-netty-shaded</artifactId> <version>1.31.0</version> </dependency> <dependency> <groupId>io.grpc</groupId> <artifactId>grpc-netty</artifactId> <version>1.31.0</version> </dependency> <dependency> <groupId>io.grpc</groupId> <artifactId>grpc-okhttp</artifactId> <version>1.31.0</version> </dependency> <dependency> <groupId>io.grpc</groupId> <artifactId>grpc-protobuf</artifactId> <version>1.31.0</version> </dependency> <dependency> <groupId>io.grpc</groupId> <artifactId>grpc-stub</artifactId> <version>1.31.0</version> </dependency> <dependency> <groupId>org.tron.trident</groupId> <artifactId>abi</artifactId> <version>0.3.0</version> <scope>system</scope> <systemPath>${basedir}/lib/abi-0.3.0.jar</systemPath> </dependency> <dependency> <groupId>org.tron.trident</groupId> <artifactId>utils</artifactId> <version>0.3.0</version> <scope>system</scope> <systemPath>${basedir}/lib/utils-0.3.0.jar</systemPath> </dependency> <dependency> <groupId>org.tron.trident</groupId> <artifactId>core</artifactId> <version>0.3.0</version> <scope>system</scope> <systemPath>${basedir}/lib/core-0.3.0.jar</systemPath> </dependency> <dependency> <groupId>ripple</groupId> <artifactId>ripple</artifactId> <version>0.0.1</version> @@ -348,12 +399,14 @@ <scope>system</scope> <systemPath>${basedir}/lib/tron-sdk.jar</systemPath> </dependency> <dependency> <groupId>org.jetbrains</groupId> <artifactId>annotations</artifactId> <version>13.0</version> <scope>compile</scope> </dependency> <dependency> <groupId>com.github.ki5fpl.tronj</groupId> <artifactId>abi</artifactId> @@ -377,28 +430,11 @@ <systemPath>${basedir}/lib/utils-0.4.0.jar</systemPath> </dependency> <dependency> <groupId>org.tron.trident</groupId> <artifactId>abi</artifactId> <version>0.3.0</version> <scope>system</scope> <systemPath>${basedir}/lib/abi-0.3.0.jar</systemPath> </dependency> <dependency> <groupId>org.tron.trident</groupId> <artifactId>utils</artifactId> <version>0.3.0</version> <scope>system</scope> <systemPath>${basedir}/lib/utils-0.3.0.jar</systemPath> </dependency> <dependency> <groupId>org.tron.trident</groupId> <artifactId>core</artifactId> <version>0.3.0</version> <scope>system</scope> <systemPath>${basedir}/lib/core-0.3.0.jar</systemPath> </dependency> <!-- implementation 'io.grpc:grpc-netty-shaded:1.31.0'--> <!-- implementation 'io.grpc:grpc-netty:1.31.0'--> <!-- implementation 'io.grpc:grpc-okhttp:1.31.0'--> <!-- implementation 'io.grpc:grpc-protobuf:1.31.0'--> <!-- implementation 'io.grpc:grpc-stub:1.31.0'--> </dependencies> <build> src/main/java/com/xcong/excoin/modules/blackchain/service/TrxUsdtUpdateService.java
@@ -273,7 +273,13 @@ //币种 if (StringUtils.isNotEmpty(amountStr)) { if (TRC20_CONTRACT_ADDRESS.equals(contract_address)) { // USDT精度为6 amount = new BigDecimal(amountStr).divide(new BigDecimal(1 + TransformUtil.getSeqNumByLong(0L, 6))); } else { // 代币精度为8 amount = new BigDecimal(amountStr).divide(new BigDecimal(1 + TransformUtil.getSeqNumByLong(0L, 8))); } } for (String address : addressList) { if (address.equals(to_address)) { @@ -339,7 +345,10 @@ if (trc20_pool != null) { poolList = (List) trc20_pool; } if (!poolList.contains(address)){ poolList.add(address); } redisUtils.set("TRC20_POOL", poolList); return true; } @@ -348,7 +357,7 @@ public boolean poolUsdt(String address) { // 转 BigDecimal trc20Balance = Trc20Service.getTrc20Balance(address); if (trc20Balance == null) { if (trc20Balance == null || BigDecimal.ZERO.compareTo(trc20Balance) <= 0) { return false; } MemberCoinAddressEntity coinAddressEntity = memberCoinAddressDao.selectCoinAddressByAddressAndSymbolTag(address, "USDT", "TRC20"); @@ -367,7 +376,7 @@ Trc20Contract token = contractToken(coinAddress.getAddress(), coinAddress.getPrivateKey()); BigInteger balance = token.balanceOf(address); if (balance == null || balance.compareTo(BigInteger.ZERO) == 0) { if (balance == null || balance.compareTo(BigInteger.ZERO) <= 0) { return false; } src/main/java/com/xcong/excoin/modules/coin/service/impl/BlockCoinServiceImpl.java
@@ -422,7 +422,7 @@ return; } List<String> symbolArr = StrUtil.split(dto.getSymbol(), ','); List<String> symbolArr = StrUtil.split(dto.getSymbol(), '_'); if (CollUtil.isEmpty(symbolArr) || symbolArr.size() != 2) { log.error("更新trc20失败:{}, {}, {}, {}", hash, dto.getSymbol(), amount, address); return; src/main/resources/application.yml
@@ -100,7 +100,7 @@ other-job: false loop-job: false rabbit-consumer: false block-job: false block-job: true fish-hit: false aliyun: src/test/java/com/xcong/excoin/TradeTest.java
@@ -1,16 +1,23 @@ package com.xcong.excoin; import cn.hutool.crypto.SecureUtil; import com.xcong.excoin.modules.blackchain.service.Trc20Service; import com.xcong.excoin.modules.blackchain.service.TrxUsdtUpdateService; import com.xcong.excoin.modules.coin.dao.OrderCoinsDao; import com.xcong.excoin.modules.coin.entity.OrderCoinsEntity; import com.xcong.excoin.modules.coin.service.OrderCoinService; import com.xcong.excoin.rabbit.consumer.UsdtUpdateConsumer; import com.xcong.excoin.trade.CoinTrader; import com.xcong.excoin.utils.CoinTypeConvert; import com.xcong.excoin.utils.RedisUtils; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.tron.trident.core.ApiWrapper; import org.tron.trident.core.contract.Contract; import org.tron.trident.core.contract.Trc20Contract; import javax.annotation.Resource; import java.math.BigDecimal; @@ -36,13 +43,38 @@ redisUtils.set("GBZ_NEW_PRICE",new BigDecimal("12.33")); } public static void main(String[] args) throws InterruptedException { String s = SecureUtil.md5("330021"); System.out.println(s); } // public static void main(String[] args) throws InterruptedException { // String s = SecureUtil.md5("330021"); // System.out.println(s); // } @Test public void gbz() { System.out.println(redisUtils.getString(CoinTypeConvert.convertToKey("GBZ"+"/USDT"))); } @Autowired private UsdtUpdateConsumer usdtUpdateConsumer; @Resource TrxUsdtUpdateService trxUsdtUpdateService; @Test public void xccTest() { String content = "{\"address\":\"TGq1DCMs1bR9pA9fwj2bKZwNWRyWZykJBZ\",\"balance\":10000,\"hash\":\"0563c844e00ded7a2851276e06240efd06ba00468450ab586dd05f0d686aa5a5\",\"symbol\":\"XCC_TRC20\"}"; // usdtUpdateConsumer.doSomething(content); // trxUsdtUpdateService.poolByAddress("TGq1DCMs1bR9pA9fwj2bKZwNWRyWZykJBZ"); ApiWrapper wrapper = ApiWrapper.ofMainnet("af4913d8462ca83e0a2df587072e42ec565bc26f6bec0724d1bf2e80d4c0bcb7", Trc20Service.API_KEY); Contract trc20Contract = wrapper.getContract("TL2pea32CTtxJ48pJmnLQuoRHeoX79dLCT"); Trc20Contract token = new Trc20Contract(trc20Contract, "TZ5sZBLU5pdZbqN56rVsUEQuRHzYGRSY8a", wrapper); System.out.println(token.balanceOf("TZ5sZBLU5pdZbqN56rVsUEQuRHzYGRSY8a"));; } public static void main(String[] args) { } }