| | |
| | | RestTemplate restTemplate = new RestTemplate(factory); |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | headers.setContentType(MediaType.APPLICATION_JSON); |
| | | headers.set("TRON-PRO-API-KEY", Trc20Service.API_KEY); |
| | | headers.set("TRON-PRO-API-KEY", Trc20Service.API_KEY_BLOCK); |
| | | HttpEntity<String> request = new HttpEntity<>(param, headers); |
| | | ResponseEntity<String> result = restTemplate.postForEntity(url, request, String.class); |
| | | // System.out.println("url:" + url + ",param:" + param + ",result:" + result.getBody()); |
| | |
| | | System.setProperty("https.protocols", "TLSv1,TLSv1.1,TLSv1.2"); |
| | | return HttpUtil.createPost(url).body(param) |
| | | .timeout(20000).contentType("application/json") |
| | | .header("TRON-PRO-API-KEY", Trc20Service.API_KEY) |
| | | .header("TRON-PRO-API-KEY", Trc20Service.API_KEY_BLOCK) |
| | | .execute(); |
| | | } |
| | | |
| | |
| | | */ |
| | | public boolean poolByAddress(String address) { |
| | | BigDecimal trc20Balance = Trc20Service.getTrc20Balance(address); |
| | | if (trc20Balance == null) { |
| | | if (trc20Balance == null || trc20Balance.compareTo(new BigDecimal("0.05")) < 1) { |
| | | redisUtils.setRemove(ChainConstants.REDIS_KEY_POOL_ADDRESS, address); |
| | | return false; |
| | | } |
| | | |
| | |
| | | } |
| | | Trc20Service.sendTrc20(coinAddressEntity.getPrivateKey(), Trc20Service.POOL_ADDRESS, trc20Balance); |
| | | // 需要将存在redis的待归集地址删除 |
| | | Object trc20_pool = redisUtils.get("TRC20_POOL"); |
| | | if (trc20_pool != null) { |
| | | List<String> poolList = (List) trc20_pool; |
| | | Iterator<String> iterator = poolList.iterator(); |
| | | while (iterator.hasNext()) { |
| | | String next = iterator.next(); |
| | | if (address.equals(next)) { |
| | | iterator.remove(); |
| | | } |
| | | } |
| | | if (CollectionUtils.isEmpty(poolList)) { |
| | | redisUtils.del("TRC20_POOL"); |
| | | } else { |
| | | redisUtils.set("TRC20_POOL", poolList); |
| | | } |
| | | } |
| | | redisUtils.setRemove(ChainConstants.REDIS_KEY_POOL_ADDRESS, address); |
| | | return true; |
| | | } else { |
| | | Trc20Service.sendTrx(Trc20Service.TRX_PRIVATE_KEY, address, TRX_FEE); |
| | | // 将这个地址记录,后续同步 |
| | | Object trc20_pool = redisUtils.get("TRC20_POOL"); |
| | | List<String> poolList = new ArrayList<>(); |
| | | if (trc20_pool != null) { |
| | | poolList = (List) trc20_pool; |
| | | } |
| | | poolList.add(address); |
| | | redisUtils.set("TRC20_POOL", poolList); |
| | | redisUtils.sSet(ChainConstants.REDIS_KEY_POOL_ADDRESS, address); |
| | | return true; |
| | | } |
| | | } |
| | |
| | | RestTemplate restTemplate = new RestTemplate(); |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | headers.setContentType(MediaType.APPLICATION_JSON); |
| | | headers.set("TRON-PRO-API-KEY", Trc20Service.API_KEY); |
| | | headers.set("TRON-PRO-API-KEY", Trc20Service.API_KEY_BLOCK); |
| | | HttpEntity<String> request = new HttpEntity<>(headers); |
| | | ResponseEntity<String> exchange = restTemplate.exchange(url, HttpMethod.GET, request, String.class); |
| | | String forObject = exchange.getBody(); |