本文整理汇总了Java中com.google.bitcoin.crypto.HDKeyDerivation.deriveChildKey方法的典型用法代码示例。如果您正苦于以下问题:Java HDKeyDerivation.deriveChildKey方法的具体用法?Java HDKeyDerivation.deriveChildKey怎么用?Java HDKeyDerivation.deriveChildKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.bitcoin.crypto.HDKeyDerivation
的用法示例。
在下文中一共展示了HDKeyDerivation.deriveChildKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: HDChain
import com.google.bitcoin.crypto.HDKeyDerivation; //导入方法依赖的package包/类
public HDChain(NetworkParameters params,
DeterministicKey accountKey,
JSONObject chainNode)
throws RuntimeException, JSONException {
mParams = params;
mChainName = chainNode.getString("name");
mIsReceive = chainNode.getBoolean("isReceive");
int chainnum = mIsReceive ? 0 : 1;
mChainKey = HDKeyDerivation.deriveChildKey(accountKey, chainnum);
mLogger.info("deserialized HDChain " + mChainName + ": " +
mChainKey.getPath());
mAddrs = new ArrayList<HDAddress>();
JSONArray addrobjs = chainNode.getJSONArray("addrs");
for (int ii = 0; ii < addrobjs.length(); ++ii) {
JSONObject addrNode = addrobjs.getJSONObject(ii);
mAddrs.add(new HDAddress(mParams, mChainKey, addrNode));
}
}
示例2: HDAddress
import com.google.bitcoin.crypto.HDKeyDerivation; //导入方法依赖的package包/类
public HDAddress(NetworkParameters params,
DeterministicKey chainKey,
int addrnum) {
mParams = params;
mAddrNum = addrnum;
DeterministicKey addrKey =
HDKeyDerivation.deriveChildKey(chainKey, addrnum);
mPath = addrKey.getPath();
// Derive ECKey.
byte[] prvBytes = addrKey.getPrivKeyBytes();
mPubBytes = addrKey.getPubKeyBytes(); // Expensive, save.
mECKey = new ECKey(prvBytes, mPubBytes);
// Set creation time to now.
mECKey.setCreationTimeSeconds(EPOCH);
// Derive path, public key, public hash and address.
mPubKey = mECKey.getPubKey();
mPubKeyHash = mECKey.getPubKeyHash();
mAddress = mECKey.toAddress(mParams);
// Initialize transaction count and balance.
mNumTrans = 0;
mBalance = 0;
mAvailable = 0;
mLogger.info("created address " + mPath + ": " + mAddress.toString());
}