Class Wallet


  • public class Wallet
    extends java.lang.Object
    Ethereum wallet file management. For reference, refer to Web3 Secret Storage Definition or the Go Ethereum client implementation.

    Note: the Bouncy Castle Scrypt implementation SCrypt, fails to comply with the following Ethereum reference Scrypt test vector:

    
     // Only value of r that cost (as an int) could be exceeded for is 1
     if (r == 1 && N_STANDARD > 65536)
     {
         throw new IllegalArgumentException("Cost parameter N_STANDARD must be > 1 and < 65536.");
     }
     
    • Constructor Summary

      Constructors 
      Constructor Description
      Wallet()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static WalletFile create​(java.lang.String password, org.web3j.crypto.ECKeyPair ecKeyPair, int n, int p)
      Creates a wallet
      static WalletFile createLight​(java.lang.String password, org.web3j.crypto.ECKeyPair ecKeyPair)
      Creates a light wallet
      static WalletFile createStandard​(java.lang.String password, org.web3j.crypto.ECKeyPair ecKeyPair)
      Creates a standard wallet
      static org.web3j.crypto.ECKeyPair decrypt​(java.lang.String password, WalletFile walletFile)
      Decrypts a wallet file
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Wallet

        public Wallet()
    • Method Detail

      • create

        public static WalletFile create​(java.lang.String password,
                                        org.web3j.crypto.ECKeyPair ecKeyPair,
                                        int n,
                                        int p)
                                 throws org.web3j.crypto.CipherException
        Creates a wallet
        Parameters:
        password - Will be used for both wallet encryption and passphrase for BIP-39 seed
        ecKeyPair - Elliptic Curve SECP-256k1 generated key pair
        Returns:
        A wallet
        Throws:
        org.web3j.crypto.CipherException - if the underlying cipher is not available
      • createStandard

        public static WalletFile createStandard​(java.lang.String password,
                                                org.web3j.crypto.ECKeyPair ecKeyPair)
                                         throws org.web3j.crypto.CipherException
        Creates a standard wallet
        Parameters:
        password - Will be used for both wallet encryption and passphrase for BIP-39 seed
        ecKeyPair - Elliptic Curve SECP-256k1 generated key pair
        Returns:
        A standard wallet
        Throws:
        org.web3j.crypto.CipherException - if the underlying cipher is not available
      • createLight

        public static WalletFile createLight​(java.lang.String password,
                                             org.web3j.crypto.ECKeyPair ecKeyPair)
                                      throws org.web3j.crypto.CipherException
        Creates a light wallet
        Parameters:
        password - Will be used for both wallet encryption and passphrase for BIP-39 seed
        ecKeyPair - Elliptic Curve SECP-256k1 generated key pair
        Returns:
        A light wallet
        Throws:
        org.web3j.crypto.CipherException - if the underlying cipher is not available
      • decrypt

        public static org.web3j.crypto.ECKeyPair decrypt​(java.lang.String password,
                                                         WalletFile walletFile)
                                                  throws org.web3j.crypto.CipherException
        Decrypts a wallet file
        Parameters:
        password - Wallet password
        walletFile - Wallet to decript
        Returns:
        Elliptic Curve SECP-256k1 generated key pair
        Throws:
        org.web3j.crypto.CipherException - if the underlying cipher is not available