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


Java ECKey.MissingPrivateKeyException方法代码示例

本文整理汇总了Java中org.bitcoinj.core.ECKey.MissingPrivateKeyException方法的典型用法代码示例。如果您正苦于以下问题:Java ECKey.MissingPrivateKeyException方法的具体用法?Java ECKey.MissingPrivateKeyException怎么用?Java ECKey.MissingPrivateKeyException使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bitcoinj.core.ECKey的用法示例。


在下文中一共展示了ECKey.MissingPrivateKeyException方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getKeyChainSeed

import org.bitcoinj.core.ECKey; //导入方法依赖的package包/类
/**
 * Returns the immutable seed for the current active HD chain.
 * @throws org.bitcoinj.core.ECKey.MissingPrivateKeyException if the seed is unavailable (watching wallet)
 */
public DeterministicSeed getKeyChainSeed() {
    keyChainGroupLock.lock();
    try {
        DeterministicSeed seed = keyChainGroup.getActiveKeyChain().getSeed();
        if (seed == null)
            throw new ECKey.MissingPrivateKeyException();
        return seed;
    } finally {
        keyChainGroupLock.unlock();
    }
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:16,代码来源:Wallet.java

示例2: signInputs

import org.bitcoinj.core.ECKey; //导入方法依赖的package包/类
@Override
public boolean signInputs(ProposedTransaction propTx, KeyBag keyBag) {
    if (missingSigsMode == Wallet.MissingSigsMode.USE_OP_ZERO)
        return true;

    int numInputs = propTx.partialTx.getInputs().size();
    byte[] dummySig = TransactionSignature.dummy().encodeToBitcoin();
    for (int i = 0; i < numInputs; i++) {
        TransactionInput txIn = propTx.partialTx.getInput(i);
        if (txIn.getConnectedOutput() == null) {
            log.warn("Missing connected output, assuming input {} is already signed.", i);
            continue;
        }

        Script scriptPubKey = txIn.getConnectedOutput().getScriptPubKey();
        Script inputScript = txIn.getScriptSig();
        if (scriptPubKey.isPayToScriptHash() || scriptPubKey.isSentToMultiSig()) {
            int sigSuffixCount = scriptPubKey.isPayToScriptHash() ? 1 : 0;
            // all chunks except the first one (OP_0) and the last (redeem script) are signatures
            for (int j = 1; j < inputScript.getChunks().size() - sigSuffixCount; j++) {
                ScriptChunk scriptChunk = inputScript.getChunks().get(j);
                if (scriptChunk.equalsOpCode(0)) {
                    if (missingSigsMode == Wallet.MissingSigsMode.THROW) {
                        throw new MissingSignatureException();
                    } else if (missingSigsMode == Wallet.MissingSigsMode.USE_DUMMY_SIG) {
                        txIn.setScriptSig(scriptPubKey.getScriptSigWithSignature(inputScript, dummySig, j - 1));
                    }
                }
            }
        } else {
            if (inputScript.getChunks().get(0).equalsOpCode(0)) {
                if (missingSigsMode == Wallet.MissingSigsMode.THROW) {
                    throw new ECKey.MissingPrivateKeyException();
                } else if (missingSigsMode == Wallet.MissingSigsMode.USE_DUMMY_SIG) {
                    txIn.setScriptSig(scriptPubKey.getScriptSigWithSignature(inputScript, dummySig, 0));
                }
            }
        }
        // TODO handle non-P2SH multisig
    }
    return true;
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:43,代码来源:MissingSigResolutionSigner.java


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