本文整理汇总了Java中net.bither.bitherj.api.SignatureHDMApi类的典型用法代码示例。如果您正苦于以下问题:Java SignatureHDMApi类的具体用法?Java SignatureHDMApi怎么用?Java SignatureHDMApi使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SignatureHDMApi类属于net.bither.bitherj.api包,在下文中一共展示了SignatureHDMApi类的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();
}
}