当前位置: 首页>>代码示例>>Java>>正文


Java SignatureHDMApi.getResult方法代码示例

本文整理汇总了Java中net.bither.bitherj.api.SignatureHDMApi.getResult方法的典型用法代码示例。如果您正苦于以下问题:Java SignatureHDMApi.getResult方法的具体用法?Java SignatureHDMApi.getResult怎么用?Java SignatureHDMApi.getResult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.bither.bitherj.api.SignatureHDMApi的用法示例。


在下文中一共展示了SignatureHDMApi.getResult方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCreateHDAddress

import net.bither.bitherj.api.SignatureHDMApi; //导入方法依赖的package包/类
@Test
public void testCreateHDAddress() {
    try {
        HttpsTest.trust();
        ECKey ecKey = new DumpedPrivateKey("L4rK1yDtCWekvXuE6oXD9jCYfFNV2cWRpVuPLBcCU2z8TrisoyY1").getKey();
        String address = ecKey.toAddress();
        GetHDMBIdRandomApi getHDMBIdRandomApi = new GetHDMBIdRandomApi(address);
        getHDMBIdRandomApi.handleHttpGet();
        long randomKey = getHDMBIdRandomApi.getResult();
        byte[] decryptedPassword = new byte[32];
        for (int i = 0; i < decryptedPassword.length; i++) {
            decryptedPassword[i] = 0;
        }

        String message = Utils.format(HDMBId.BITID_STRING, address, Utils.bytesToHexString(decryptedPassword).toLowerCase(Locale.US), randomKey);
        byte[] hash = Utils.getPreSignMessage(message);
        byte[] signBytes = ecKey.signHash(hash, null);
        UploadHDMBidApi uploadHDMBidApi = new UploadHDMBidApi(address, address, signBytes, decryptedPassword);
        uploadHDMBidApi.handleHttpPost();
        boolean str = uploadHDMBidApi.getResult();
        HDMAddress.Pubs pubs = new HDMAddress.Pubs(ecKey.getPubKey(), ecKey.getPubKey(), null, 0);
        List<HDMAddress.Pubs> pubsList = new ArrayList<HDMAddress.Pubs>();
        pubsList.add(pubs);

        CreateHDMAddressApi createHDMAddressApi = new CreateHDMAddressApi(address, pubsList, decryptedPassword);
        createHDMAddressApi.handleHttpPost();


        List<byte[]> remotePubs = createHDMAddressApi.getResult();
        for (int i = 0;
             i < pubsList.size();
             i++) {
            HDMAddress.Pubs pubss = pubsList.get(i);
            pubss.remote = remotePubs.get(i);
            System.out.println("hot:" + Utils.bytesToHexString(pubss.hot));
            System.out.println("cold:" + Utils.bytesToHexString(pubss.cold));
            System.out.println("remote:" + Utils.bytesToHexString(pubss.remote));
            System.out.println("create,Address:" + pubss.getAddress());
        }

        List<byte[]> unsigns = new ArrayList<byte[]>();
        unsigns.add(Utils.doubleDigest(decryptedPassword));
        SignatureHDMApi signatureHDMApi = new SignatureHDMApi(address, 0, decryptedPassword, unsigns);
        signatureHDMApi.handleHttpPost();
        List<byte[]> bytesList = signatureHDMApi.getResult();

    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:bither,项目名称:bitherj,代码行数:51,代码来源:HDMIdTest.java


注:本文中的net.bither.bitherj.api.SignatureHDMApi.getResult方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。