JAVA 离线生成波场(TRX)地址


波场代币迁移说明:TRX的ERC20代币迁移至波场主网代币.
废话不多说 不明白的可以看下上面的公告

生成地址

	  public TrxApi newAddress(String pwd) {
        try{
            ObjectMapper objectMapper = ObjectMapperFactory.getObjectMapper();
            ECKeyPair ecKeyPair = Keys.createEcKeyPair();
            WalletFile walletFile = Wallet.createStandard(pwd, ecKeyPair);
            String keystore = objectMapper.writeValueAsString(walletFile);
            WalletFile walletFile2 = objectMapper.readValue(keystore, WalletFile.class);
            ECKeyPair ecKeyPair1 = Wallet.decrypt(pwd, walletFile2);
            return new TrxApi("41"+walletFile.getAddress(),ecKeyPair1.getPrivateKey().toString(16)) ;
        }catch (Exception e){
            e.printStackTrace();
            logger.info("虚拟币"+COIN_NAME+"创建地址失败,错误代码:{}",new Object[]{e.getMessage()});
            return null ;
        }
    }

转换地址(T -----> 41)

 /**
     *  T ---->  41
     * @param address
     * @return
     */
    public String toHexAddress(String address){
       return  ByteArray.toHexString(WalletApi.decodeFromBase58Check(address));
    }

转换地址(41 -----> T)

 /**
     * 41 ---- > T
     * @param address
     * @return
     */
    public String fromHexAddress(String address){
       return WalletApi.encode58Check(ByteArray.fromHexString(address));
    }

Wallet-cli jar包

$ git clone https://github.com/tronprotocol/wallet-cli.git
$ cd wallet-cli
$ ./gradlew build
$ cd build/libs

波场钱包接下来的内容稍后更新

©️2020 CSDN 皮肤主题: 1024 设计师:上身试试 返回首页