use of com.whoiszxl.common.EthereumAddress in project shopzz by whoiszxl.
the class ShopzzFeignClientImpl method giveAddress.
@Override
@Transactional
public ResponseResult<RechargeResponse> giveAddress(String orderId, String amount) {
// 1. 获取货币信息
Currency ethInfo = currencyService.getCurrencyByName(currencyName);
AssertUtils.isNotNull(ethInfo, "数据库未配置货币信息:" + currencyName);
// 2. 通过keystore的方式生成一个以太坊地址
EthereumAddress ethereumAddress = ethereumService.createAddressByFile();
String qrCodeData = getQrCodeData(amount, ethereumAddress.getAddress());
// 3. 保存keystore文件与地址的对应关系
CurrencyAccount account = new CurrencyAccount();
account.setAddress(ethereumAddress.getAddress());
account.setCurrencyId(ethInfo.getId());
account.setCurrencyName(ethInfo.getCurrencyName());
account.setKeystoreName(ethereumAddress.getKeystoreName());
account.setMnemonic(ethereumAddress.getMnemonic());
currencyAccountService.save(account);
return ResponseResult.buildSuccess(new RechargeResponse(ethInfo.getId(), ethereumAddress.getAddress(), qrCodeData));
}
use of com.whoiszxl.common.EthereumAddress in project shopzz by whoiszxl.
the class EthereumService method createAddressByFile.
/**
* 通过keystore文件生成地址
* @return 地址与keystore文件名
*/
public EthereumAddress createAddressByFile() {
try {
String fileName = WalletUtils.generateNewWalletFile(keystorePassword, new File(keystorePath), false);
Credentials credentials = WalletUtils.loadCredentials(keystorePassword, keystorePath + File.separator + fileName);
String address = credentials.getAddress();
return new EthereumAddress(address, fileName, null);
} catch (Exception e) {
log.error("通过keystore文件生成地址发生异常:", e);
return null;
}
}
use of com.whoiszxl.common.EthereumAddress in project shopzz by whoiszxl.
the class EthFeignClientImpl method giveAddress.
@Override
@Transactional
@PostMapping("/createRecharge/{orderId}/{amount}")
public ResponseResult<RechargeResponse> giveAddress(String orderId, String amount) {
// 1. 获取货币信息
Currency ethInfo = currencyService.getCurrencyByName(currencyName);
AssertUtils.isNotNull(ethInfo, "数据库未配置货币信息:" + currencyName);
// 2. 通过keystore的方式生成一个以太坊地址
EthereumAddress ethereumAddress = ethereumService.createAddressByFile();
String qrCodeData = getQrCodeData(amount, ethereumAddress.getAddress());
// 3. 保存keystore文件与地址的对应关系
CurrencyAccount account = new CurrencyAccount();
account.setAddress(ethereumAddress.getAddress());
account.setCurrencyId(ethInfo.getId());
account.setCurrencyName(ethInfo.getCurrencyName());
account.setKeystoreName(ethereumAddress.getKeystoreName());
account.setMnemonic(ethereumAddress.getMnemonic());
currencyAccountService.save(account);
return ResponseResult.buildSuccess(new RechargeResponse(ethInfo.getId(), ethereumAddress.getAddress(), qrCodeData));
}
use of com.whoiszxl.common.EthereumAddress in project shopzz by whoiszxl.
the class ZXLFeignClientImpl method giveAddress.
@Override
@Transactional
public ResponseResult<RechargeResponse> giveAddress(String orderId, String amount) {
// 1. 获取货币信息
Currency ethInfo = currencyService.getCurrencyByName(currencyName);
AssertUtils.isNotNull(ethInfo, "数据库未配置货币信息:" + currencyName);
// 2. 通过keystore的方式生成一个以太坊地址
EthereumAddress ethereumAddress = ethereumService.createAddressByFile();
String qrCodeData = getQrCodeData(amount, ethereumAddress.getAddress());
// 3. 保存keystore文件与地址的对应关系
CurrencyAccount account = new CurrencyAccount();
account.setAddress(ethereumAddress.getAddress());
account.setCurrencyId(ethInfo.getId());
account.setCurrencyName(ethInfo.getCurrencyName());
account.setKeystoreName(ethereumAddress.getKeystoreName());
account.setMnemonic(ethereumAddress.getMnemonic());
currencyAccountService.save(account);
return ResponseResult.buildSuccess(new RechargeResponse(ethInfo.getId(), ethereumAddress.getAddress(), qrCodeData));
}
Aggregations