想詢問加密何處出錯了,地址不正確,要如何修改才能與線上錢包相符?
import org.bitcoinj.core.ECKey;
import org.bitcoinj.crypto.MnemonicCode;
import org.bitcoinj.crypto.MnemonicException;
import ove.crypto.digest.Blake2b;
ECKey ecKey = new ECKey();
byte[] privKeyBytes = ecKey.getPrivKeyBytes();
byte[] pubKey = ecKey.getPubKey();
if (privKeyBytes == null || privKeyBytes.length < 1) {
throw new RuntimeException("create wallet error");
}
Blake2b.Digest digest = Blake2b.Digest.newInstance(20);
String hash = HexUtil.encodeHexStr(digest.digest(pubKey));
String pubKeyHash = "01" + HexUtil.encodeHexStr(digest.digest(pubKey));
Blake2b.Digest blake2b3 = Blake2b.Digest.newInstance(4);
String checksum = HexUtil.encodeHexStr(blake2b3.digest(HexUtil.decodeHex(pubKeyHash)));
String filAddress = "f1" + Base32.encode(HexUtil.decodeHex(hash + checksum)).toLowerCase();
String privatekey = HexUtil.encodeHexStr(privKeyBytes);
log.info("filAddress " + filAddress);
log.info("privatekey " + privatekey);
計算出的地址和私鑰
filAddress: f16ebk5pxt7e4jnwstipx4idlg6a2zxf6had6xhpq
privatekey: feefd45a6c43ed513c162aa023aeb95256e2fbca23d8de3d321f9b9be9f6aa2b
到FilBox錢包測試計算出的私鑰
結果現在錢包顯示地址為:
程式加密要如何修改才能讓計算出來的filAddress與線上錢包相符?