本文整理汇总了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();
}
}
示例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;
}