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


Java HDKeyDerivation.deriveChildKey方法代码示例

本文整理汇总了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));
    }
}
 
开发者ID:ksedgwic,项目名称:BTCReceive,代码行数:25,代码来源:HDChain.java

示例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());
}
 
开发者ID:ksedgwic,项目名称:BTCReceive,代码行数:32,代码来源:HDAddress.java


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