From 166dcbf5e3837352121dc3cd2fbfd8180f2629e9 Mon Sep 17 00:00:00 2001 From: long <18782126717@163.com> Date: Mon, 10 Oct 2022 15:39:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=A4=E6=98=93=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E6=97=A5=E5=BF=97=EF=BC=8C=E6=96=B0=E5=A2=9E=E4=B8=AA?= =?UTF-8?q?=E4=BA=BA=E8=BD=AC=E8=B5=A0=E5=88=B0=E5=85=AC=E5=85=B1=E8=B4=A6?= =?UTF-8?q?=E6=88=B7=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/nft/domain/CheckArgs.java | 4 +-- .../nft/service/impl/ConfluxServiceImpl.java | 27 +++++++++++++------ .../service/impl/NftAccountServiceImpl.java | 14 +++++++++- .../conflux/web/controller/util/AESUtil.java | 8 +----- 4 files changed, 34 insertions(+), 19 deletions(-) diff --git a/conflux-admin/src/main/java/com/conflux/web/controller/nft/domain/CheckArgs.java b/conflux-admin/src/main/java/com/conflux/web/controller/nft/domain/CheckArgs.java index 5dce508..a351fa0 100644 --- a/conflux-admin/src/main/java/com/conflux/web/controller/nft/domain/CheckArgs.java +++ b/conflux-admin/src/main/java/com/conflux/web/controller/nft/domain/CheckArgs.java @@ -2,9 +2,6 @@ package com.conflux.web.controller.nft.domain; import lombok.Data; -import java.math.BigInteger; -import java.util.List; - /** * @Author _007long * @Date 2022 05 31 @@ -19,6 +16,7 @@ public class CheckArgs { private String appId; private String privateKey; private String toUser; + private String userId; private String nftId; //非批量使用 diff --git a/conflux-admin/src/main/java/com/conflux/web/controller/nft/service/impl/ConfluxServiceImpl.java b/conflux-admin/src/main/java/com/conflux/web/controller/nft/service/impl/ConfluxServiceImpl.java index b3600d7..c4ce81b 100644 --- a/conflux-admin/src/main/java/com/conflux/web/controller/nft/service/impl/ConfluxServiceImpl.java +++ b/conflux-admin/src/main/java/com/conflux/web/controller/nft/service/impl/ConfluxServiceImpl.java @@ -428,7 +428,17 @@ public class ConfluxServiceImpl implements ConfluxService { String contract = contractConfig.getContract(); long start = 0L; Cfx cfx = Cfx.create(collectConfig.getNode(), 3, 1000); - Account account = Account.create(cfx, AESUtil.decrypt(contractConfig.getPrivateKey())); + Account account = null; + NftAccount nftAccount=null; + if (StringUtils.isNotEmpty(checkArgs.getUserId())){ + nftAccount = nftAccountMapper.selectNftAccountByUserId(checkArgs.getUserId()); + String nftPrivatekey = nftAccount.getPrivateKey(); + String decrypt = AESUtil.Decrypt(nftPrivatekey, ConfluxArt.AESKEY); + account= Account.create(cfx, decrypt); + }else { + account=Account.create(cfx, AESUtil.decrypt(contractConfig.getPrivateKey())); + } + Account.Option opt = new Account.Option(); opt.withValue(BigInteger.ZERO); opt.withChainId(collectConfig.getChainId()); @@ -444,10 +454,12 @@ public class ConfluxServiceImpl implements ConfluxService { //剩余燃气值 BigInteger sponsoredBalanceForGas = sponsorWhitelistControl.getSponsoredBalanceForGas(address.getABIAddress()).divide(new BigInteger("1000000000")); log.info("[--------------------->mintNft][balance]{}[sponsoredBalanceForCollateral:]{}[sponsoredBalanceForGas:]{}", balance, sponsoredBalanceForCollateral, sponsoredBalanceForGas); - if (balance.compareTo(new BigInteger("40000000000000000000")) < 0) { - log.info("[--------------------->mintNft][balance not enough 50]{}", balance); - //sms notice - return AjaxResult.error("账户余额不足!"); + if (StringUtils.isEmpty(checkArgs.getUserId())) { + if (balance.compareTo(new BigInteger("40000000000000000000")) < 0) { + log.info("[--------------------->mintNft][balance not enough 50]{}", balance); + //sms notice + return AjaxResult.error("账户余额不足!"); + } } String owner = contractConfig.getOwner(); ConfluxExecutor confluxExecutor = new ConfluxExecutor(account, contract); @@ -658,9 +670,8 @@ public class ConfluxServiceImpl implements ConfluxService { case ConfluxExecutor.SAFETRANSFERFROM://单个转赠 return subgift(est, hash, checkArgs, confluxExecutor, cfx, owner, contract, sponsoredBalanceForGas, opt, nftLog, start); case ConfluxExecutor.PRIVATETOPUBLIC://私人转公共账户 - String toUser=owner; - String toOwner=checkArgs.getToUser(); - checkArgs.setToUser(toUser); + String toOwner=AESUtil.Decrypt(nftAccount.getNftAddress(),ConfluxArt.AESKEY); + checkArgs.setToUser(owner); return subgift(est, hash, checkArgs, confluxExecutor, cfx, toOwner, contract, sponsoredBalanceForGas, opt, nftLog, start); case ConfluxExecutor.AIRDROPCASTING://铸造方式空投 tokenURIs = checkArgs.getStrUri(); diff --git a/conflux-admin/src/main/java/com/conflux/web/controller/nft/service/impl/NftAccountServiceImpl.java b/conflux-admin/src/main/java/com/conflux/web/controller/nft/service/impl/NftAccountServiceImpl.java index 3ab0667..95bf164 100644 --- a/conflux-admin/src/main/java/com/conflux/web/controller/nft/service/impl/NftAccountServiceImpl.java +++ b/conflux-admin/src/main/java/com/conflux/web/controller/nft/service/impl/NftAccountServiceImpl.java @@ -2,9 +2,11 @@ package com.conflux.web.controller.nft.service.impl; import com.conflux.common.utils.DateUtils; +import com.conflux.web.controller.nft.domain.ConfluxArt; import com.conflux.web.controller.nft.domain.NftAccount; import com.conflux.web.controller.nft.mapper.NftAccountMapper; import com.conflux.web.controller.nft.service.INftAccountService; +import com.conflux.web.controller.util.AESUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -43,7 +45,17 @@ public class NftAccountServiceImpl implements INftAccountService @Override public List selectNftAccountList(NftAccount nftAccount) { - return nftAccountMapper.selectNftAccountList(nftAccount); + List nftAccounts = nftAccountMapper.selectNftAccountList(nftAccount); + + + for (NftAccount nft:nftAccounts) { + try { + nft.setNftAddress(AESUtil.Decrypt(nft.getNftAddress(), ConfluxArt.AESKEY)); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + return nftAccounts; } /** diff --git a/conflux-admin/src/main/java/com/conflux/web/controller/util/AESUtil.java b/conflux-admin/src/main/java/com/conflux/web/controller/util/AESUtil.java index 92c739b..4d56361 100644 --- a/conflux-admin/src/main/java/com/conflux/web/controller/util/AESUtil.java +++ b/conflux-admin/src/main/java/com/conflux/web/controller/util/AESUtil.java @@ -1,8 +1,6 @@ package com.conflux.web.controller.util; -import com.alibaba.fastjson.JSONObject; -import com.conflux.common.utils.sign.Md5Utils; import lombok.extern.slf4j.Slf4j; import org.apache.commons.codec.binary.Base64; @@ -11,10 +9,6 @@ import javax.crypto.KeyGenerator; import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; import java.security.SecureRandom; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Map; -import java.util.Set; /** * AES加密解密工具类(提供对称加密) @@ -225,7 +219,7 @@ public final class AESUtil { try { //System.err.println(Integer.valueOf("00000000000000000000000000000017")); //AES - String encrypt = Encrypt("b829e58242004525995cb17323829d1e","CONFLUX@12345678"); + String encrypt = Encrypt("f4152ff440c342e983003d4359c4eb8b","CONFLUX@12345678"); System.err.println(encrypt); //md5 // String hash = Md5Utils.md5Salt("0efc989dea214ed8bff99b0d14714481d660a7e7137c3ef0fc093efad244ee171f4308d9ccda9359add79e029bd169c9");