Class Account


  • public class Account
    extends java.lang.Object
    Account is a class to hold all private key, public key and address info, and is on duty of sign tx
    • Method Detail

      • fromHexString

        public static Account fromHexString​(java.lang.String hexString)
        Create account by private key in hex string format
        Parameters:
        hexString - private key in hex string
        Returns:
        created account
      • fromByteArray

        public static Account fromByteArray​(byte[] b)
        Create account by private key in byte[] format
        Parameters:
        b - private key in byte[] format
        Returns:
        created account
      • generate

        public static Account generate()
        Create account by a random private key
        Returns:
        created account
      • defaultAccount

        public static Account defaultAccount()
        Return account with default private key, this is easy in dev and test env
        Returns:
        created account
      • convertBech32AddressToBytesAddress

        public static byte[] convertBech32AddressToBytesAddress​(java.lang.String bech32Address)
        Get inner address in bech32 format and return in byte array
        Parameters:
        bech32Address - address in bech32 format
        Returns:
        inner address in byte array
      • convertBech32AddressToHexAddress

        public static java.lang.String convertBech32AddressToHexAddress​(java.lang.String bech32Address)
        Get inner address in bech32 format and return in hex string
        Parameters:
        bech32Address - address in bech32 format
        Returns:
        inner address in hex string
      • convertBech32AddressToHexAddress

        public static java.lang.String convertBech32AddressToHexAddress​(java.lang.String bech32Address,
                                                                        java.lang.String hrp)
      • convertBytesAddressToBech32Address

        public static java.lang.String convertBytesAddressToBech32Address​(byte[] address)
        Get bech32 format address from inner address in byte array
        Parameters:
        address - address in bech32 format
        Returns:
        bech32 address
      • convertHexAddressToBech32Address

        public static java.lang.String convertHexAddressToBech32Address​(java.lang.String address)
        Get bech32 format address from inner address in hex string
        Parameters:
        address - address in bech32 format
        Returns:
        bech32 address
      • convertHexAddressToBech32Address

        public static java.lang.String convertHexAddressToBech32Address​(java.lang.String address,
                                                                        java.lang.String hrp)
      • getPrivateKeyByteArray

        public byte[] getPrivateKeyByteArray()
      • getPrivateKeyHex

        public java.lang.String getPrivateKeyHex()
      • getPrivateKeyBigInteger

        public java.math.BigInteger getPrivateKeyBigInteger()
      • getPublicKeyByteArray

        public byte[] getPublicKeyByteArray()
      • getPublicKeyHex

        public java.lang.String getPublicKeyHex()
      • getPublicKeyECPoint

        public org.bouncycastle.math.ec.ECPoint getPublicKeyECPoint()
      • getAddressByteArray

        public byte[] getAddressByteArray()
      • getGAddress

        public GAddress getGAddress()
      • getAddress

        public Address getAddress()
      • getAddressHex

        public java.lang.String getAddressHex()
      • getBech32Address

        public java.lang.String getBech32Address()
      • sign

        public byte[] sign​(byte[] msgHash)
        Sign a data by this account's private key, the data should be a digest of certain message
        Parameters:
        msgHash - digest of message
        Returns:
        signed signature
      • validate_bech32_address

        public static boolean validate_bech32_address​(java.lang.String bech32Address,
                                                      java.lang.String hrp)