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.Bip39Wallet
generateBip39Wallet
(String password, File destinationDirectory) Generates a BIP-39 compatible Ethereum wallet.static org.web3j.crypto.Bip39Wallet
generateBip39WalletFromMnemonic
(String password, String mnemonic, File destinationDirectory) Generates a BIP-39 compatible Ethereum wallet using a mnemonic passed as argument.static String
generateFullNewWalletFile
(String password, File destinationDirectory) static String
generateLightNewWalletFile
(String password, File destinationDirectory) static String
generateNewWalletFile
(String password, File destinationDirectory) static String
generateNewWalletFile
(String password, File destinationDirectory, boolean useFullScrypt) static String
generateWalletFile
(String password, org.web3j.crypto.ECKeyPair ecKeyPair, File destinationDirectory, boolean useFullScrypt) static String
static String
static String
Get keystore destination directory for a Rinkeby network.static String
static boolean
isValidAddress
(String input) static boolean
isValidAddress
(String input, int addressLength) static boolean
isValidPrivateKey
(String privateKey) static org.web3j.crypto.Credentials
loadBip39Credentials
(String password, String mnemonic) static org.web3j.crypto.Credentials
loadCredentials
(String password, File source) static org.web3j.crypto.Credentials
loadCredentials
(String password, String source) static org.web3j.crypto.Credentials
loadJsonCredentials
(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:
NoSuchAlgorithmException
NoSuchProviderException
InvalidAlgorithmParameterException
org.web3j.crypto.exception.CipherException
IOException
-
generateLightNewWalletFile
public static String generateLightNewWalletFile(String password, File destinationDirectory) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException, org.web3j.crypto.exception.CipherException, IOException - Throws:
NoSuchAlgorithmException
NoSuchProviderException
InvalidAlgorithmParameterException
org.web3j.crypto.exception.CipherException
IOException
-
generateNewWalletFile
public static String generateNewWalletFile(String password, File destinationDirectory) throws org.web3j.crypto.exception.CipherException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, NoSuchProviderException, IOException - Throws:
org.web3j.crypto.exception.CipherException
InvalidAlgorithmParameterException
NoSuchAlgorithmException
NoSuchProviderException
IOException
-
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.CipherException
IOException
InvalidAlgorithmParameterException
NoSuchAlgorithmException
NoSuchProviderException
-
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.CipherException
IOException
-
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:
IOException
org.web3j.crypto.exception.CipherException
-
loadCredentials
public static org.web3j.crypto.Credentials loadCredentials(String password, File source) throws IOException, org.web3j.crypto.exception.CipherException - Throws:
IOException
org.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
-