本文整理汇总了Java中org.web3j.crypto.WalletUtils.loadCredentials方法的典型用法代码示例。如果您正苦于以下问题:Java WalletUtils.loadCredentials方法的具体用法?Java WalletUtils.loadCredentials怎么用?Java WalletUtils.loadCredentials使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.web3j.crypto.WalletUtils
的用法示例。
在下文中一共展示了WalletUtils.loadCredentials方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUpClass
import org.web3j.crypto.WalletUtils; //导入方法依赖的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);
}
示例2: loadCredentials
import org.web3j.crypto.WalletUtils; //导入方法依赖的package包/类
public static Credentials loadCredentials(EthKeyProperties keyProperties) {
if (keyProperties.getKeyLocation() != null) {
try {
return WalletUtils.loadCredentials(keyProperties.getKeyPassword(), keyProperties.getKeyLocation());
} catch (Exception e) {
throw Throwables.propagate(e);
}
} else if (keyProperties.getPrivateKey() != null) {
return Credentials.create(keyProperties.getPrivateKey());
} else {
throw new IllegalStateException("Either node.eth.key-location or node.eth.test.private-key required");
}
}
示例3: getCredentials
import org.web3j.crypto.WalletUtils; //导入方法依赖的package包/类
public Credentials getCredentials() {
if (credentials != null) {
return credentials;
}
try {
String fileWithPath = getFile().getAbsolutePath();
credentials = WalletUtils.loadCredentials(password, fileWithPath);
// TODO verify again (performance issue gone now?)
// tried to figure out where the time is used up
// File file = new File(fileWithPath);
// ObjectMapper objectMapper = ObjectMapperFactory.getObjectMapper(); // 8sec
// WalletFile walletFile = objectMapper.readValue(file, WalletFile.class);
// ECKeyPair keyPair = org.web3j.crypto.Wallet.decrypt(password, walletFile); // > 30s
// -> "culprit" is Wallet.generateDerivedScryptKey() inside of Wallet.decrypt
// Credentials credentials = Credentials.create(keyPair);
return credentials;
}
catch (Exception e) {
LOG.error("failed to access credentials in file '" + getFile().getAbsolutePath() + "'", e);
return null;
}
}
示例4: sign
import org.web3j.crypto.WalletUtils; //导入方法依赖的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();
}
}
示例5: getModumToken
import org.web3j.crypto.WalletUtils; //导入方法依赖的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;
}
}
示例6: getSignedWallet
import org.web3j.crypto.WalletUtils; //导入方法依赖的package包/类
public static Wallet getSignedWallet(String walletFile, String pinCode, String salt)
throws CantSignedException
{
try {
Credentials credentials = WalletUtils.loadCredentials(pinCode + salt, walletFile);
return new Wallet(walletFile, credentials);
} catch (IOException | CipherException e) {
e.printStackTrace();
throw new CantSignedException();
}
}
示例7: PaperWallet
import org.web3j.crypto.WalletUtils; //导入方法依赖的package包/类
public PaperWallet(String passPhrase, File walletFile) {
// check if provided file exists
if(!walletFile.exists() || walletFile.isDirectory()) {
System.err.println(String.format("%s file does not exist or is a directory", WALLET_ERROR));
}
try {
credentials = WalletUtils.loadCredentials(passPhrase, walletFile);
}
catch (Exception e) {
System.err.println(String.format("%s failed to load credentials with provided password", WALLET_ERROR));
}
}
示例8: getCredentials
import org.web3j.crypto.WalletUtils; //导入方法依赖的package包/类
public Credentials getCredentials(String passPhrase) throws Exception {
if (credentials != null) {
return credentials;
}
try {
String fileWithPath = getFile().getAbsolutePath();
credentials = WalletUtils.loadCredentials(passPhrase, fileWithPath);
return credentials;
}
catch (Exception e) {
throw new Exception ("Failed to access credentials in file '" + getFile().getAbsolutePath() + "'", e);
}
}
示例9: getFullWallet
import org.web3j.crypto.WalletUtils; //导入方法依赖的package包/类
public Credentials getFullWallet(Context context, String password, String wallet) throws IOException, JSONException, CipherException {
if (wallet.startsWith("0x"))
wallet = wallet.substring(2, wallet.length());
return WalletUtils.loadCredentials(password, new File(context.getFilesDir(), wallet));
}
示例10: loadCredentials
import org.web3j.crypto.WalletUtils; //导入方法依赖的package包/类
public void loadCredentials(String password, File file) throws IOException, CipherException {
credentials = WalletUtils.loadCredentials(password, file);
}
示例11: PapyrusMember
import org.web3j.crypto.WalletUtils; //导入方法依赖的package包/类
public PapyrusMember(String address, Web3j web3j, File credentials, String pass) throws IOException, CipherException {
this.address = address;
this.transactionManager = new RawTransactionManager(web3j, WalletUtils.loadCredentials(pass, credentials));
}
示例12: openWallet
import org.web3j.crypto.WalletUtils; //导入方法依赖的package包/类
/**
* Abrir una cuenta ethereum
*
* @param password
* @param walletName
* @return
* @throws Exception
*/
public Credentials openWallet(String password, String walletName) throws Exception {
Credentials credentials = WalletUtils.loadCredentials(password, WALLET_PATH + walletName);
return credentials;
}