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


Java ScriptBuilder.createMultiSigInputScript方法代码示例

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


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

示例1: provideRefundSignature

import com.google.bitcoin.script.ScriptBuilder; //导入方法依赖的package包/类
/**
 * <p>When the servers signature for the refund transaction is received, call this to verify it and sign the
 * complete refund ourselves.</p>
 *
 * <p>If this does not throw an exception, we are secure against the loss of funds and can safely provide the server
 * with the multi-sig contract to lock in the agreement. In this case, both the multisig contract and the refund
 * transaction are automatically committed to wallet so that it can handle broadcasting the refund transaction at
 * the appropriate time if necessary.</p>
 */
public synchronized void provideRefundSignature(byte[] theirSignature) throws VerificationException {
    checkNotNull(theirSignature);
    checkState(state == State.WAITING_FOR_SIGNED_REFUND);
    TransactionSignature theirSig = TransactionSignature.decodeFromBitcoin(theirSignature, true);
    if (theirSig.sigHashMode() != Transaction.SigHash.NONE || !theirSig.anyoneCanPay())
        throw new VerificationException("Refund signature was not SIGHASH_NONE|SIGHASH_ANYONECANPAY");
    // Sign the refund transaction ourselves.
    final TransactionOutput multisigContractOutput = multisigContract.getOutput(0);
    try {
        multisigScript = multisigContractOutput.getScriptPubKey();
    } catch (ScriptException e) {
        throw new RuntimeException(e);  // Cannot happen: we built this ourselves.
    }
    TransactionSignature ourSignature =
            refundTx.calculateSignature(0, myKey, multisigScript, Transaction.SigHash.ALL, false);
    // Insert the signatures.
    Script scriptSig = ScriptBuilder.createMultiSigInputScript(ourSignature, theirSig);
    log.info("Refund scriptSig: {}", scriptSig);
    log.info("Multi-sig contract scriptPubKey: {}", multisigScript);
    TransactionInput refundInput = refundTx.getInput(0);
    refundInput.setScriptSig(scriptSig);
    refundInput.verify(multisigContractOutput);
    state = State.SAVE_STATE_IN_WALLET;
}
 
开发者ID:HashEngineering,项目名称:megacoinj,代码行数:34,代码来源:PaymentChannelClientState.java


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