Package org.web3j.crypto
Class WalletUtils
java.lang.Object
org.web3j.crypto.WalletUtils
- Direct Known Subclasses:
Bip44WalletUtils
Utility functions for working with Wallet files.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.web3j.crypto.Bip39WalletgenerateBip39Wallet(String password, File destinationDirectory) Generates a BIP-39 compatible Ethereum wallet.static org.web3j.crypto.Bip39WalletgenerateBip39WalletFromMnemonic(String password, String mnemonic, File destinationDirectory) Generates a BIP-39 compatible Ethereum wallet using a mnemonic passed as argument.static StringgenerateFullNewWalletFile(String password, File destinationDirectory) static StringgenerateLightNewWalletFile(String password, File destinationDirectory) static StringgenerateNewWalletFile(String password, File destinationDirectory) static StringgenerateNewWalletFile(String password, File destinationDirectory, boolean useFullScrypt) static StringgenerateWalletFile(String password, org.web3j.crypto.ECKeyPair ecKeyPair, File destinationDirectory, boolean useFullScrypt) static Stringstatic Stringstatic StringGet keystore destination directory for a Rinkeby network.static Stringstatic booleanisValidAddress(String input) static booleanisValidAddress(String input, int addressLength) static booleanisValidPrivateKey(String privateKey) static org.web3j.crypto.CredentialsloadBip39Credentials(String password, String mnemonic) static org.web3j.crypto.CredentialsloadCredentials(String password, File source) static org.web3j.crypto.CredentialsloadCredentials(String password, String source) static org.web3j.crypto.CredentialsloadJsonCredentials(String password, String content) Load credentials from JSON wallet string.
-
Constructor Details
-
WalletUtils
public WalletUtils()
-
-
Method Details
-
generateFullNewWalletFile
public static String generateFullNewWalletFile(String password, File destinationDirectory) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException, org.web3j.crypto.exception.CipherException, IOException - Throws:
NoSuchAlgorithmExceptionNoSuchProviderExceptionInvalidAlgorithmParameterExceptionorg.web3j.crypto.exception.CipherExceptionIOException
-
generateLightNewWalletFile
public static String generateLightNewWalletFile(String password, File destinationDirectory) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException, org.web3j.crypto.exception.CipherException, IOException - Throws:
NoSuchAlgorithmExceptionNoSuchProviderExceptionInvalidAlgorithmParameterExceptionorg.web3j.crypto.exception.CipherExceptionIOException
-
generateNewWalletFile
public static String generateNewWalletFile(String password, File destinationDirectory) throws org.web3j.crypto.exception.CipherException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, NoSuchProviderException, IOException - Throws:
org.web3j.crypto.exception.CipherExceptionInvalidAlgorithmParameterExceptionNoSuchAlgorithmExceptionNoSuchProviderExceptionIOException
-
generateNewWalletFile
public static String generateNewWalletFile(String password, File destinationDirectory, boolean useFullScrypt) throws org.web3j.crypto.exception.CipherException, IOException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, NoSuchProviderException - Throws:
org.web3j.crypto.exception.CipherExceptionIOExceptionInvalidAlgorithmParameterExceptionNoSuchAlgorithmExceptionNoSuchProviderException
-
generateWalletFile
public static String generateWalletFile(String password, org.web3j.crypto.ECKeyPair ecKeyPair, File destinationDirectory, boolean useFullScrypt) throws org.web3j.crypto.exception.CipherException, IOException - Throws:
org.web3j.crypto.exception.CipherExceptionIOException
-
generateBip39Wallet
public static org.web3j.crypto.Bip39Wallet generateBip39Wallet(String password, File destinationDirectory) throws org.web3j.crypto.exception.CipherException, IOException Generates a BIP-39 compatible Ethereum wallet. The private key for the wallet can be calculated using following algorithm:Key = SHA-256(BIP_39_SEED(mnemonic, password))- Parameters:
password- Will be used for both wallet encryption and passphrase for BIP-39 seeddestinationDirectory- The directory containing the wallet- Returns:
- A BIP-39 compatible Ethereum wallet
- Throws:
org.web3j.crypto.exception.CipherException- if the underlying cipher is not availableIOException- if the destination cannot be written to
-
generateBip39WalletFromMnemonic
public static org.web3j.crypto.Bip39Wallet generateBip39WalletFromMnemonic(String password, String mnemonic, File destinationDirectory) throws org.web3j.crypto.exception.CipherException, IOException Generates a BIP-39 compatible Ethereum wallet using a mnemonic passed as argument.- Parameters:
password- Will be used for both wallet encryption and passphrase for BIP-39 seedmnemonic- The mnemonic that will be used to generate the seeddestinationDirectory- The directory containing the wallet- Returns:
- A BIP-39 compatible Ethereum wallet
- Throws:
org.web3j.crypto.exception.CipherException- if the underlying cipher is not availableIOException- if the destination cannot be written to
-
loadCredentials
public static org.web3j.crypto.Credentials loadCredentials(String password, String source) throws IOException, org.web3j.crypto.exception.CipherException - Throws:
IOExceptionorg.web3j.crypto.exception.CipherException
-
loadCredentials
public static org.web3j.crypto.Credentials loadCredentials(String password, File source) throws IOException, org.web3j.crypto.exception.CipherException - Throws:
IOExceptionorg.web3j.crypto.exception.CipherException
-
loadBip39Credentials
-
loadJsonCredentials
public static org.web3j.crypto.Credentials loadJsonCredentials(String password, String content) throws IOException, org.web3j.crypto.exception.CipherException Load credentials from JSON wallet string.- Parameters:
password- - password to decrypt JSON wallet stringcontent- - JSON wallet content string- Returns:
- Ethereum credentials
- Throws:
org.web3j.crypto.exception.CipherException- if the underlying cipher is not availableIOException- if a low-level I/O problem (unexpected end-of-input, network error) occurs
-
getDefaultKeyDirectory
-
getTestnetKeyDirectory
-
getMainnetKeyDirectory
-
getRinkebyKeyDirectory
Get keystore destination directory for a Rinkeby network.- Returns:
- a String containing destination directory
-
isValidPrivateKey
-
isValidAddress
-
isValidAddress
-