本文整理汇总了Java中org.web3j.crypto.CipherException类的典型用法代码示例。如果您正苦于以下问题:Java CipherException类的具体用法?Java CipherException怎么用?Java CipherException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CipherException类属于org.web3j.crypto包,在下文中一共展示了CipherException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getEchoContract
import org.web3j.crypto.CipherException; //导入依赖的package包/类
public static Echo_sol_Echo getEchoContract()
throws JsonParseException, JsonMappingException, IOException, CipherException {
Web3j web3j = Web3j.build(new HttpService());
logger.debug("[ETH-INFO] Connected to TestRPC");
ObjectMapper objectMapper = ObjectMapperFactory.getObjectMapper();
WalletFile walletFile = objectMapper
.readValue(ContractHelper.class.getResourceAsStream("/accountKeystore.json"), WalletFile.class);
Credentials credentials = Credentials.create(Wallet.decrypt(password, walletFile));
logger.debug("[ETH-INFO] Credentials: " + credentials.getAddress());
logger.debug("[ETH-INFO] Loading contract: " + contractAddress);
ese = Echo_sol_Echo.load(contractAddress, web3j, credentials, GAS_PRICE, GAS_LIMIT);
startObservable();
return ese;
}
示例2: generateWalletFile
import org.web3j.crypto.CipherException; //导入依赖的package包/类
public static String generateWalletFile(
String password, ECKeyPair ecKeyPair, File destinationDirectory, boolean useFullScrypt)
throws CipherException, IOException {
WalletFile walletFile;
if (useFullScrypt) {
walletFile = Wallet.createStandard(password, ecKeyPair);
} else {
walletFile = Wallet.createLight(password, ecKeyPair);
}
String fileName = getWalletFileName(walletFile);
File destination = new File(destinationDirectory, fileName);
ObjectMapper objectMapper = ObjectMapperFactory.getObjectMapper();
objectMapper.writeValue(destination, walletFile);
return fileName;
}
示例3: registerUser
import org.web3j.crypto.CipherException; //导入依赖的package包/类
@BeforeClass(enabled = false)
public void registerUser() throws CipherException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, NoSuchProviderException, IOException {
auditor = createNewMember(2, 100)
.thenApply(papyrusMember -> {
allTransactionsMinedAsync(asList(papyrusMember.refillTransaction, papyrusMember.mintTransaction));
return papyrusMember;
}).join();
auditorRegistrar = createNewMember(2, 100)
.thenApply(papyrusMember -> {
allTransactionsMinedAsync(asList(papyrusMember.refillTransaction, papyrusMember.mintTransaction));
return papyrusMember;
}).join();
dao = loadDaoContract(auditor.transactionManager);
daoRegistrar = loadDaoContract(auditorRegistrar.transactionManager);
token = asCf(dao.token()).thenApply(tokenAddress -> loadTokenContract(tokenAddress.toString(), auditor.transactionManager)).join();
tokenRegistrar = asCf(daoRegistrar.token())
.thenApply(tokenAddress -> loadTokenContract(tokenAddress.toString(), auditorRegistrar.transactionManager)
).join();
auditorRegistry = asCf(daoRegistrar.auditorRegistry())
.thenApply(auditorRegistryAddress -> loadAuditorRegistry(auditorRegistryAddress.toString(), auditor.transactionManager))
.join();
initDepositContract();
}
示例4: registerUser
import org.web3j.crypto.CipherException; //导入依赖的package包/类
@BeforeClass(enabled = false)
public void registerUser() throws CipherException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, NoSuchProviderException, IOException {
publisher = createNewMember(2, 100)
.thenApply(papyrusMember -> {
allTransactionsMinedAsync(asList(papyrusMember.refillTransaction, papyrusMember.mintTransaction));
return papyrusMember;
}).join();
publisherRegistrar = createNewMember(2, 100)
.thenApply(papyrusMember -> {
allTransactionsMinedAsync(asList(papyrusMember.refillTransaction, papyrusMember.mintTransaction));
return papyrusMember;
}).join();
dao = loadDaoContract(publisher.transactionManager);
daoRegistrar = loadDaoContract(publisherRegistrar.transactionManager);
token = asCf(dao.token()).thenApply(tokenAddress -> loadTokenContract(tokenAddress.toString(), publisher.transactionManager)).join();
tokenRegistrar = asCf(daoRegistrar.token())
.thenApply(tokenAddress -> loadTokenContract(tokenAddress.toString(), publisherRegistrar.transactionManager)
).join();
publisherRegistry = asCf(daoRegistrar.publisherRegistry())
.thenApply(publisherRegistryAddress -> loadPublisherRegistry(publisherRegistryAddress.toString(), publisher.transactionManager))
.join();
initDepositContract();
}
示例5: registerUser
import org.web3j.crypto.CipherException; //导入依赖的package包/类
@BeforeClass(enabled = false)
public void registerUser() throws CipherException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, NoSuchProviderException, IOException {
auditor = createNewMember(2, 100)
.thenApply(papyrusMember -> {
allTransactionsMinedAsync(asList(papyrusMember.refillTransaction, papyrusMember.mintTransaction));
return papyrusMember;
}).join();
dao = loadDaoContract(auditor.transactionManager);
ownerDao = loadDaoContract(new ClientTransactionManager(web3j, ownerAddr));
token = asCf(dao.token()).thenApply(tokenAddress -> loadTokenContract(tokenAddress.toString(), auditor.transactionManager)).join();
ownerToken = asCf(dao.token()).thenApply(tokenAddress -> loadTokenContract(tokenAddress.toString(), new ClientTransactionManager(web3j, ownerAddr))).join();
asCf(dao.isAuditorRegistered(auditor.getAddress())).thenAccept(types -> Assert.assertFalse(types.getValue())).join();
asCf(token.approve(daoAddress(), new Uint256(BigInteger.TEN))).join();
asCf(dao.registerAuditor(auditor.getAddress())).thenAccept(receipt -> Assert.assertNotNull(receipt.getTransactionHash())).join();
asCf(dao.isAuditorRegistered(auditor.getAddress())).thenAccept(types -> Assert.assertTrue(types.getValue())).join();
}
示例6: createNewMember
import org.web3j.crypto.CipherException; //导入依赖的package包/类
public static CompletableFuture<PapyrusMember> createNewMember(double initialBalance, long initialPrpBalance) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException, CipherException, IOException {
return parity.ethCoinbase().sendAsync()
//New account with some Ether
.thenCombine(parity.personalNewAccount(randomCitizenPassword).sendAsync(),
(coinbase, newAccount) -> {
if (initialBalance > 0) {
return transferEther(coinbase.getAddress(), newAccount.getAccountId(), initialBalance)
.thenApply(transaction -> new PapyrusMember(newAccount.getAccountId(), web3j)
.withRefillTransaction(transaction.getTransactionHash())
);
} else {
return CompletableFuture.completedFuture(new PapyrusMember(newAccount.getAccountId(), web3j));
}
}
)
//Flat map
.thenCompose(papyrusMember -> papyrusMember)
//Mint some tokens for new member
.thenCompose(papyrusMember -> mintPrp(papyrusMember.address, initialPrpBalance)
.thenApply(transaction -> papyrusMember.withMintTransaction(transaction.getTransactionHash()))
)
//And unlock it
.thenCompose(member -> parity.personalUnlockAccount(member.address, randomCitizenPassword).sendAsync()
.thenApply(unlocked -> member)
);
}
示例7: registerUser
import org.web3j.crypto.CipherException; //导入依赖的package包/类
@BeforeClass(enabled = false)
public void registerUser() throws CipherException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, NoSuchProviderException, IOException {
dsp = createNewMember(2, 100)
.thenApply(papyrusMember -> {
allTransactionsMinedAsync(asList(papyrusMember.refillTransaction, papyrusMember.mintTransaction));
return papyrusMember;
}).join();
dspRegistrar = createNewMember(2, 100)
.thenApply(papyrusMember -> {
allTransactionsMinedAsync(asList(papyrusMember.refillTransaction, papyrusMember.mintTransaction));
return papyrusMember;
}).join();
dao = loadDaoContract(dsp.transactionManager);
daoRegistrar = loadDaoContract(dspRegistrar.transactionManager);
token = asCf(dao.token()).thenApply(tokenAddress -> loadTokenContract(tokenAddress.toString(), dsp.transactionManager)).join();
tokenRegistrar = asCf(daoRegistrar.token())
.thenApply(tokenAddress -> loadTokenContract(tokenAddress.toString(), dspRegistrar.transactionManager)
).join();
dspRegistry = asCf(daoRegistrar.dspRegistry())
.thenApply(dspRegistryAddress -> loadDspRegistry(dspRegistryAddress.toString(), dsp.transactionManager))
.join();
initDepositContract();
}
示例8: registerUser
import org.web3j.crypto.CipherException; //导入依赖的package包/类
@BeforeClass(enabled = false)
public void registerUser() throws CipherException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, NoSuchProviderException, IOException {
ssp = createNewMember(2, 100)
.thenApply(papyrusMember -> {
allTransactionsMinedAsync(asList(papyrusMember.refillTransaction, papyrusMember.mintTransaction));
return papyrusMember;
}).join();
sspRegistrar = createNewMember(2, 100)
.thenApply(papyrusMember -> {
allTransactionsMinedAsync(asList(papyrusMember.refillTransaction, papyrusMember.mintTransaction));
return papyrusMember;
}).join();
dao = loadDaoContract(ssp.transactionManager);
daoRegistrar = loadDaoContract(sspRegistrar.transactionManager);
token = asCf(dao.token()).thenApply(tokenAddress -> loadTokenContract(tokenAddress.toString(), ssp.transactionManager)).join();
tokenRegistrar = asCf(daoRegistrar.token())
.thenApply(tokenAddress -> loadTokenContract(tokenAddress.toString(), sspRegistrar.transactionManager)
).join();
sspRegistry = asCf(daoRegistrar.sspRegistry())
.thenApply(sspRegistryAddress -> loadSspRegistry(sspRegistryAddress.toString(), ssp.transactionManager))
.join();
initDepositContract();
}
示例9: generateWallet
import org.web3j.crypto.CipherException; //导入依赖的package包/类
public static Wallet generateWallet(Context context, ECKeyPair ecKeyPair,
final String password)
throws WalletNotGeneratedException
{
try {
final String address = Numeric.prependHexPrefix(Keys.getAddress(ecKeyPair));
final File destDirectory = Environment.getExternalStorageDirectory().getAbsoluteFile();
Log.d(TAG, Environment.getExternalStorageState());
final String fileName = WalletUtils.generateWalletFile(password, ecKeyPair, destDirectory, false);
final String destFilePath = destDirectory + "/" + fileName;
return new Wallet(ecKeyPair, destFilePath, address);
} catch (CipherException | IOException e)
{
e.printStackTrace();
throw new WalletNotGeneratedException();
}
}
示例10: sign
import org.web3j.crypto.CipherException; //导入依赖的package包/类
public void sign(String pinCode, WalletInfo walletInfo) throws CantSignedException {
try {
final String fullPassword = pinCode + walletInfo.getSalt();
if (getEcKeyPair() != null) {
credentials = Credentials.create(getEcKeyPair());
} else {
credentials = WalletUtils.loadCredentials(fullPassword, getWalletPath());
}
} catch (IOException | CipherException e) {
e.printStackTrace();
throw new CantSignedException();
}
}
示例11: createWalletFile
import org.web3j.crypto.CipherException; //导入依赖的package包/类
private void createWalletFile(String privateKey) {
if (!WalletUtils.isValidPrivateKey(privateKey)) {
exitError("Invalid private key specified, must be "
+ PRIVATE_KEY_LENGTH_IN_HEX
+ " digit hex value");
}
Credentials credentials = Credentials.create(privateKey);
String password = getPassword("Please enter a wallet file password: ");
String destinationDir = getDestinationDir();
File destination = createDir(destinationDir);
try {
String walletFileName = WalletUtils.generateWalletFile(
password, credentials.getEcKeyPair(), destination, true);
console.printf("Wallet file " + walletFileName
+ " successfully created in: " + destinationDir + "\n");
} catch (CipherException | IOException e) {
exitError(e);
}
}
示例12: setUpClass
import org.web3j.crypto.CipherException; //导入依赖的package包/类
@BeforeClass
public static void setUpClass() throws IOException, CipherException {
credentials = WalletUtils.loadCredentials("password", KEY_FILE1);
testData1 = TestData.staticGenerate(credentials.getAddress());
parity = Parity.build(new HttpService("http://localhost:8545"));
// parity.personalUnlockAccount(credentials.getAddress(), "password", new BigInteger("100000"));
Cmc cmc = Cmc.load(CMC_ADDR, parity, credentials, GAS_PRICE, GAS_LIMIT);
cmcWrapper = new CmcWrapper(cmc);
// cmcWrapper.bootstrap();
String dnsManagerAddress = cmcWrapper.getAddress(APP_NAME);
SolDnsApp solDnsApp = SolDnsApp.load(dnsManagerAddress, parity, credentials, GAS_PRICE, GAS_LIMIT);
solDnsAppWrapper = new SolDnsAppWrapper(solDnsApp);
}
示例13: getModumToken
import org.web3j.crypto.CipherException; //导入依赖的package包/类
@Bean
public ModumToken getModumToken() throws IOException, CipherException {
Web3j web3j = Web3j.build(new HttpService());
try {
Credentials credentials = WalletUtils.loadCredentials(password, account);
return ModumToken.load(contract, web3j, credentials, ManagedTransaction.GAS_PRICE, Contract.GAS_LIMIT);
} catch (FileNotFoundException e) {
return null;
}
}
示例14: ContractsManagerFactory
import org.web3j.crypto.CipherException; //导入依赖的package包/类
@Autowired
public ContractsManagerFactory(EthProperties ethProperties, EthereumConfig config, ContractsProperties contractsProperties, Web3j web3j) throws IOException, CipherException {
this.ethProperties = ethProperties;
this.config = config;
this.contractsProperties = contractsProperties;
this.web3j = web3j;
managerMap = new HashMap<>();
log.info("Configuring pre deployed contracts {}", contractsProperties.getAddress());
for (Address address : config.getAddresses()) {
ThreadsafeTransactionManager transactionManager = config.getTransactionManager(address);
managerMap.put(address, createManager(transactionManager, config.getCredentials(address).getAddress()));
}
}
示例15: EthereumConfig
import org.web3j.crypto.CipherException; //导入依赖的package包/类
@Autowired
public EthereumConfig(EthProperties properties, Web3j web3j) throws IOException, CipherException {
this.properties = properties;
this.web3j = web3j;
keyProperties = new HashMap<>();
credentialsMap = new HashMap<>();
transactionManagerMap = new HashMap<>();
Preconditions.checkState(properties.getAccounts().size() > 0, "No accounts defined");
String mainAccount = properties.getMainAccount();
if (mainAccount == null && properties.getAccounts().size() == 1) mainAccount = properties.getAccounts().keySet().iterator().next();
Preconditions.checkState(mainAccount != null, "No main account defined");
Credentials mainCred = null;
for (Map.Entry<String, EthKeyProperties> e : properties.getAccounts().entrySet()) {
EthKeyProperties key = e.getValue();
Credentials credentials = loadCredentials(key);
Address address = new Address(credentials.getAddress());
log.info("Configured participant address {}: {}", e.getKey(), credentials.getAddress());
keyProperties.put(address, key);
credentialsMap.put(address, credentials);
if (e.getKey().equals(mainAccount)) {
mainCred = credentials;
}
ThreadsafeTransactionManager transactionManager = createTransactionManager(credentials);
transactionManagerMap.put(address, transactionManager);
}
assert keyProperties.size() == properties.getAccounts().size();
assert credentialsMap.size() == properties.getAccounts().size();
assert transactionManagerMap.size() == properties.getAccounts().size();
Preconditions.checkState(mainCred != null, "No account defined: %s", mainAccount);
mainCredentials = mainCred;
log.info("Configured rpc server: {}", this.properties.getRpc().getNodeUrl());
}