类 AddressTool


  • public class AddressTool
    extends Object
    • 字段详细资料

      • BLOCK_HOLE_ADDRESS_SET

        public static Set<String> BLOCK_HOLE_ADDRESS_SET
    • 构造器详细资料

      • AddressTool

        public AddressTool()
    • 方法详细资料

      • getAddressPreFixMap

        public static Map<Integer,​String> getAddressPreFixMap()
      • addPrefix

        public static void addPrefix​(int chainId,
                                     String prefix)
      • getPrefix

        public static String getPrefix​(int chainId)
      • getPrefix

        public static String getPrefix​(String address)
      • getRealAddress

        public static String getRealAddress​(String addressString)
      • getAddress

        public static byte[] getAddress​(String addressString)
        根据地址字符串查询地址字节数组
        参数:
        addressString -
        返回:
      • getAddressByRealAddr

        public static byte[] getAddressByRealAddr​(String addressString)
      • getChainIdByAddress

        public static int getChainIdByAddress​(String addressString)
        根据地址字符串查询地址所属链ID
        参数:
        addressString -
        返回:
      • getAddress

        public static byte[] getAddress​(byte[] publicKey,
                                        int chainId)
        根据公钥查询地址字节数组
        参数:
        publicKey -
        chainId -
        返回:
      • getAddressString

        public static String getAddressString​(byte[] publicKey,
                                              int chainId)
        根据公钥查询地址字节数组
        参数:
        publicKey -
        chainId -
        返回:
      • getAddressByPubKeyStr

        public static byte[] getAddressByPubKeyStr​(String publicKeyStr,
                                                   int chainId)
        根据公钥查询地址字节数组
        参数:
        publicKeyStr -
        chainId -
        返回:
      • isBlackHoleAddress

        public static boolean isBlackHoleAddress​(byte[] blackHolePublicKey,
                                                 int chainId,
                                                 byte[] address)
        参数:
        blackHolePublicKey -
        chainId -
        address -
        返回:
      • getAddress

        public static byte[] getAddress​(byte[] publicKey,
                                        int chainId,
                                        String prefix)
      • checkXOR

        public static void checkXOR​(byte[] hashs)
        检查校验位是否正确,XOR(addressType+hash160(pubKey))
        参数:
        hashs -
      • validAddress

        public static boolean validAddress​(int chainId,
                                           String address)
        验证地址字符串是否是有效地址
        参数:
        address -
        chainId -
        返回:
      • getChainIdByAddress

        public static int getChainIdByAddress​(byte[] bytes)
        通过地址获得chainId
        参数:
        bytes -
        返回:
      • validNormalAddress

        public static boolean validNormalAddress​(byte[] bytes,
                                                 int chainId)
        校验是否是普通地址
        参数:
        bytes -
        chainId -
        返回:
      • validAddress

        public static boolean validAddress​(byte[] bytes,
                                           int chainId,
                                           byte type)
        参数:
        bytes - 地址
        chainId - 链id
        type - 账户类型,如果传0,则不验证
        返回:
      • validContractAddress

        public static boolean validContractAddress​(byte[] addressBytes,
                                                   int chainId)
        校验是否是智能合约地址
        参数:
        addressBytes -
        chainId -
        返回:
      • getStringAddressByBytes

        public static String getStringAddressByBytes​(byte[] addressBytes)
        根据地址字节数组生成地址字符串 base58(chainId)+_+base58(addressType+hash160(pubKey)+XOR(addressType+hash160(pubKey)))
        参数:
        addressBytes -
        返回:
      • getStringAddressNoPrefix

        public static String getStringAddressNoPrefix​(byte[] addressBytes)
      • getStringAddressByBytes

        public static String getStringAddressByBytes​(byte[] addressBytes,
                                                     String prefix)
      • checkPublicKeyHash

        public static boolean checkPublicKeyHash​(byte[] address,
                                                 byte[] pubKeyHash)
      • isMultiSignAddress

        public static boolean isMultiSignAddress​(byte[] addr)
      • isMultiSignAddress

        public static boolean isMultiSignAddress​(String address)
      • isNormalAddress

        public static boolean isNormalAddress​(String address,
                                              int chainId)
      • validSignAddress

        public static boolean validSignAddress​(List<byte[]> bytesList,
                                               byte[] bytes)
      • createMultiSigAccountOriginBytes

        public static byte[] createMultiSigAccountOriginBytes​(int chainId,
                                                              int m,
                                                              List<String> pubKeys)
                                                       throws Exception
        抛出:
        Exception