| | |
| | | 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; |
| | |
| | | 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() { |
| | | Long directRewardId = 701L; |
| | | MallOrderInfo orderInfo = mallOrderInfoMapper.selectById(directRewardId); |