From f38db4c91a3655a9024aa2f1ada81a153741b855 Mon Sep 17 00:00:00 2001 From: xiaoyong931011 <15274802129@163.com> Date: Fri, 24 Mar 2023 14:29:28 +0800 Subject: [PATCH] 后台修改 --- src/test/java/cc/mrbird/febs/ProfitTest.java | 92 ++++++++++++++++++++++++++++++--------------- 1 files changed, 61 insertions(+), 31 deletions(-) diff --git a/src/test/java/cc/mrbird/febs/ProfitTest.java b/src/test/java/cc/mrbird/febs/ProfitTest.java index af3cd35..882ede7 100644 --- a/src/test/java/cc/mrbird/febs/ProfitTest.java +++ b/src/test/java/cc/mrbird/febs/ProfitTest.java @@ -32,8 +32,11 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.web3j.crypto.Credentials; +import org.web3j.crypto.WalletUtils; import javax.annotation.Resource; +import java.io.File; import java.math.BigDecimal; import java.math.BigInteger; import java.text.DecimalFormat; @@ -102,6 +105,33 @@ @Autowired private DataDictionaryCustomMapper dataDictionaryCustomMapper; + + @Test + public void tetstgetPrikey(){ + Map<String, String> wallet = new HashMap<String, String>(); + try { + String walletPassword = "secr3t"; + // 文件路径 + String walletDirectory = "E:\\address"; + String walletName = "UTC--2023-01-13T08-03-47.600000000Z--aec294ac13f0a64c57a7b9ddb3aee5e791cff06a.json"; + +// String walletName = WalletUtils.generateNewWalletFile(walletPassword, new File(walletDirectory)); +// System.out.println("wallet location: " + walletDirectory + "/" + walletName); + Credentials credentials = WalletUtils.loadCredentials(walletPassword, walletDirectory + "/" + walletName); + String accountAddress = credentials.getAddress(); + String privateKey = credentials.getEcKeyPair().getPrivateKey().toString(16); + // 钱包地址 + wallet.put("address", accountAddress); + // 钱包私钥 + wallet.put("privateKey", privateKey); + System.out.println(accountAddress); + System.out.println(privateKey); + // 产生的钱包文件地址 + wallet.put("walletLocation", walletDirectory + "/" + walletName); + } catch (Exception e) { + e.printStackTrace(); + } + } @Test public void directorProfitTest() { @@ -449,38 +479,38 @@ @Test public void scorePool(){ - String next = "0xc1be17a02127e5cc1e6b2298436e8b467531f798"; - MemberCoinAddressEntity memberCoinAddressEntity = memberCoinAddressDao.selectCoinAddressByAddressAndSymbolTag(next, "USDT", "ERC20"); - if(ObjectUtil.isEmpty(memberCoinAddressEntity)){ - return; - } - BigDecimal balanceOf = ChainService.getInstance(ChainEnum.BSC_USDT.name()).balanceOf(next); - if (balanceOf == null || balanceOf.compareTo(new BigDecimal("0.05")) < 1) { - return; - } - //查询手续费 - BigDecimal balanceOfBaseToken = ChainService.getInstance(ChainEnum.BSC_USDT.name()).balanceOfBaseToken(next); - - String gas = "5"; - if(balanceOfBaseToken.compareTo(new BigDecimal(gas)) < 0){ - //转手续费 - ChainService.getInstance(ChainEnum.BSC_USDT.name()).transferBaseToken(next, new BigDecimal(gas)); - } - ChainService.getInstance(ChainEnum.BSC_USDT.name()).transfer(memberCoinAddressEntity.getPrivateKey(), - memberCoinAddressEntity.getAddress(), - AppContants.ERC20_POOL_ADDRESS, - balanceOf.toString()); -// long start = System.currentTimeMillis(); -// Object incrementObj = redisUtils.get(AppContants.REDIS_KEY_BLOCK_ETH_INCREMENT_NUM); -// BigInteger newest = ChainService.getInstance(ChainEnum.BSC_USDT.name()).blockNumber(); -// BigInteger block; -// if (incrementObj == null) { -// block = newest; -// } else { -// block = (BigInteger) incrementObj; +// String next = "0xc1be17a02127e5cc1e6b2298436e8b467531f798"; +// MemberCoinAddressEntity memberCoinAddressEntity = memberCoinAddressDao.selectCoinAddressByAddressAndSymbolTag(next, "USDT", "ERC20"); +// if(ObjectUtil.isEmpty(memberCoinAddressEntity)){ +// return; // } -//// ChainService.wssBaseCoinEventListener(BigInteger.valueOf(24317595), baseCoinService); -// ChainService.wssContractEventListener(BigInteger.valueOf(24317595), bscUsdtContractEvent, ChainEnum.BSC_USDT.name()); +// BigDecimal balanceOf = ChainService.getInstance(ChainEnum.BSC_USDT.name()).balanceOf(next); +// if (balanceOf == null || balanceOf.compareTo(new BigDecimal("0.05")) < 1) { +// return; +// } +// //查询手续费 +// BigDecimal balanceOfBaseToken = ChainService.getInstance(ChainEnum.BSC_USDT.name()).balanceOfBaseToken(next); +// +// String gas = "5"; +// if(balanceOfBaseToken.compareTo(new BigDecimal(gas)) < 0){ +// //转手续费 +// ChainService.getInstance(ChainEnum.BSC_USDT.name()).transferBaseToken(next, new BigDecimal(gas)); +// } +// ChainService.getInstance(ChainEnum.BSC_USDT.name()).transfer(memberCoinAddressEntity.getPrivateKey(), +// memberCoinAddressEntity.getAddress(), +// AppContants.ERC20_POOL_ADDRESS, +// balanceOf.toString()); + long start = System.currentTimeMillis(); + Object incrementObj = redisUtils.get(AppContants.REDIS_KEY_BLOCK_ETH_INCREMENT_NUM); + BigInteger newest = ChainService.getInstance(ChainEnum.BSC_USDT.name()).blockNumber(); + BigInteger block; + if (incrementObj == null) { + block = newest; + } else { + block = newest; + } + ChainService.wssBaseCoinEventListener(block, baseCoinService); +// ChainService.wssContractEventListener2(block, bscUsdtContractEvent, ChainEnum.BSC_USDT.name()); } // // @Test -- Gitblit v1.9.1