本文整理汇总了Java中com.google.bitcoin.core.ECKey.getPubKeyHash方法的典型用法代码示例。如果您正苦于以下问题:Java ECKey.getPubKeyHash方法的具体用法?Java ECKey.getPubKeyHash怎么用?Java ECKey.getPubKeyHash使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.bitcoin.core.ECKey
的用法示例。
在下文中一共展示了ECKey.getPubKeyHash方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSharing
import com.google.bitcoin.core.ECKey; //导入方法依赖的package包/类
public static String createSharing(int shares, int threshold) {
ThresholdSecretSharing tss = new ThresholdSecretSharing();
// Create 5 shares, secret recoverable from at least 3 different shares
ECKey key = new ECKey();
Address addr = new Address(MainNetParams.get(), key.getPubKeyHash());
System.out.println("Bitcoin address : " + addr);
byte[] secret = key.getPrivKeyBytes();
byte[][] sharesArr = tss.createShares(secret, shares, threshold,
new SecureRandom());
showKeyDetail(key);
for (int i = 0; i < sharesArr.length; i++) {
System.out.printf("sharing_%d=%s\n", i + 1,
Utils.bytesToHexString(sharesArr[i]));
}
// byte[][] sharesTarget = { sharesArr[0], sharesArr[2], sharesArr[3] };
// recoverPrivateKey(sharesTarget);
return "";
}
示例2: HDAddress
import com.google.bitcoin.core.ECKey; //导入方法依赖的package包/类
public HDAddress(NetworkParameters params,
DeterministicKey chainKey,
JSONObject addrNode)
throws RuntimeException, JSONException {
mParams = params;
mAddrNum = addrNode.getInt("addrNum");
mPath = addrNode.getString("path");
// Derive ECKey.
byte[] prvBytes = null;
try {
mPubBytes = Base58.decode(addrNode.getString("pubBytes"));
} catch (AddressFormatException ex) {
throw new RuntimeException("failed to decode pubBytes");
}
mECKey = new ECKey(prvBytes, mPubBytes);
// Set creation time to BTCReceive epoch.
mECKey.setCreationTimeSeconds(EPOCH);
// Derive public key, public hash and address.
mPubKey = mECKey.getPubKey();
mPubKeyHash = mECKey.getPubKeyHash();
mAddress = mECKey.toAddress(mParams);
// Initialize transaction count and balance. If we don't have
// a persisted available amount, presume it is all available.
mNumTrans = addrNode.getInt("numTrans");
mBalance = addrNode.getLong("balance");
mAvailable = addrNode.has("available") ?
addrNode.getLong("available") : mBalance;
mLogger.info("read address " + mPath + ": " + mAddress.toString());
}
示例3: CommitTx
import com.google.bitcoin.core.ECKey; //导入方法依赖的package包/类
public CommitTx(TransactionOutput out, ECKey sk, List<byte[]> pks, int position,
byte[] hash, int minLength, BigInteger fee, boolean testnet) throws VerificationException {
this.hash = hash;
this.commiterAddress = sk.getPubKeyHash();
this.minLength = minLength;
this.noPlayers = pks.size();
this.position = position;
this.stake = out.getValue().subtract(fee).divide(BigInteger.valueOf(noPlayers-1));
NetworkParameters params = getNetworkParameters(testnet);
tx = new Transaction(params);
for (int k = 0; k < noPlayers; ++k) {
BigInteger currentStake = stake;
if (k == position) { //TODO: simplier script?
currentStake = BigInteger.ZERO;
}
tx.addOutput(currentStake, getCommitOutScript(Utils.sha256hash160(pks.get(k))));
}
tx.addInput(out);
if (out.getScriptPubKey().isSentToAddress()) {
tx.getInput(0).setScriptSig(ScriptBuilder.createInputScript(sign(0, sk), sk));
}
else if (out.getScriptPubKey().isSentToRawPubKey()) {
tx.getInput(0).setScriptSig(ScriptBuilder.createInputScript(sign(0, sk)));
}
else {
throw new VerificationException("Bad transaction output.");
}
this.addresses = new ArrayList<byte[]>();
for (byte[] pk : pks) {
this.addresses.add(Utils.sha256hash160(pk));
}
tx.verify();
tx.getInput(0).verify();
}
示例4: TxOutputVerifier
import com.google.bitcoin.core.ECKey; //导入方法依赖的package包/类
public TxOutputVerifier(ECKey sk, BigInteger value, boolean testnet) {
this.pkHash = sk.getPubKeyHash();
this.value = value;
params = LotteryTx.getNetworkParameters(testnet);
}