当前位置 : 主页 > 网络编程 > 其它编程 >

org.bitcoinj.core.TransactionInput.verify()方法的使用及代码示例

来源:互联网 收集:自由互联 发布时间:2023-07-02
本文整理了Java中org.bitcoinj.core.TransactionInput.verify()方法的一些代码示例,展示了TransactionI 本文整理了Java中org.bitcoinj.core.TransactionInput.verify()方法的一些代码示例,展示了TransactionInput.ver
本文整理了Java中org.bitcoinj.core.TransactionInput.verify()方法的一些代码示例,展示了TransactionI

本文整理了Java中org.bitcoinj.core.TransactionInput.verify()方法的一些代码示例,展示了TransactionInput.verify()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TransactionInput.verify()方法的具体详情如下:包路径:org.bitcoinj.core.TransactionInput类名称:TransactionInput方法名:verify

TransactionInput.verify介绍

[英]For a connected transaction, runs the script against the connected pubkey and verifies they are correct.[中]对于连接的事务,根据连接的公钥运行脚本,并验证它们是否正确。

代码示例

代码示例来源:origin: fr.acinq/bitcoinj-core

/** * Verifies that this input can spend the given output. Note that this input must be a part of a transaction. * Also note that the consistency of the outpoint will be checked, even if this input has not been connected. * * @param output the output that this input is supposed to spend. * @throws ScriptException If the script doesn't verify. * @throws VerificationException If the outpoint doesn't match the given output. */public void verify(TransactionOutput output) throws VerificationException { verify(output, Script.ALL_VERIFY_FLAGS);}

代码示例来源:origin: fr.acinq/bitcoinj-core

/** * For a connected transaction, runs the script against the connected pubkey and verifies they are correct. * @throws ScriptException if the script did not verify. * @throws VerificationException If the outpoint doesn't match the given output. */public void verify() throws VerificationException { final Transaction fromTx = getOutpoint().fromTx; long spendingIndex = getOutpoint().getIndex(); checkNotNull(fromTx, "Not connected"); final TransactionOutput output = fromTx.getOutput((int) spendingIndex); verify(output);}

代码示例来源:origin: cash.bitcoinj/bitcoinj-core

/** * For a connected transaction, runs the script against the connected pubkey and verifies they are correct. * @throws ScriptException if the script did not verify. * @throws VerificationException If the outpoint doesn't match the given output. */public void verify() throws VerificationException { final Transaction fromTx = getOutpoint().fromTx; long spendingIndex = getOutpoint().getIndex(); checkNotNull(fromTx, "Not connected"); final TransactionOutput output = fromTx.getOutput((int) spendingIndex); verify(output);}

代码示例来源:origin: greenaddress/GreenBits

/** * For a connected transaction, runs the script against the connected pubkey and verifies they are correct. * @throws ScriptException if the script did not verify. * @throws VerificationException If the outpoint doesn't match the given output. */public void verify() throws VerificationException { final Transaction fromTx = getOutpoint().fromTx; long spendingIndex = getOutpoint().getIndex(); checkNotNull(fromTx, "Not connected"); final TransactionOutput output = fromTx.getOutput((int) spendingIndex); verify(output);}

代码示例来源:origin: HashEngineering/dashj

/** * For a connected transaction, runs the script against the connected pubkey and verifies they are correct. * @throws ScriptException if the script did not verify. * @throws VerificationException If the outpoint doesn't match the given output. */public void verify() throws VerificationException { final Transaction fromTx = getOutpoint().fromTx; long spendingIndex = getOutpoint().getIndex(); checkNotNull(fromTx, "Not connected"); final TransactionOutput output = fromTx.getOutput((int) spendingIndex); verify(output);}

代码示例来源:origin: DanielKrawisz/Shufflepuff

@Overridepublic boolean isValid() { for (TransactionInput input : this.bitcoinj.getInputs()) { TransactionOutput output = input.getConnectedOutput(); if (input.getScriptSig() == null) { return false; } try { input.verify(output); } catch (VerificationException e) { return false; } } return true;}

代码示例来源:origin: cash.bitcoinj/bitcoinj-core

/** * Returns true if the tx is a valid settlement transaction. */public synchronized boolean isSettlementTransaction(Transaction tx) { try { tx.verify(); tx.getInput(0).verify(getContractInternal().getOutput(0)); return true; } catch (VerificationException e) { return false; }}

代码示例来源:origin: greenaddress/GreenBits

/** * Returns true if the tx is a valid settlement transaction. */public synchronized boolean isSettlementTransaction(Transaction tx) { try { tx.verify(); tx.getInput(0).verify(getContractInternal().getOutput(0)); return true; } catch (VerificationException e) { return false; }}

代码示例来源:origin: HashEngineering/dashj

/** * Returns true if the tx is a valid settlement transaction. */public synchronized boolean isSettlementTransaction(Transaction tx) { try { tx.verify(); tx.getInput(0).verify(getContractInternal().getOutput(0)); return true; } catch (VerificationException e) { return false; }}

代码示例来源:origin: fr.acinq/bitcoinj-core

/** * Returns true if the tx is a valid settlement transaction. */public synchronized boolean isSettlementTransaction(Transaction tx) { try { tx.verify(); tx.getInput(0).verify(getContractInternal().getOutput(0)); return true; } catch (VerificationException e) { return false; }}

代码示例来源:origin: DanielKrawisz/Shufflepuff

public org.bitcoinj.core.Transaction signTransaction(org.bitcoinj.core.Transaction signTx, List programSignatures) { List inputScripts = new LinkedList(); for (Bytestring programs : programSignatures) { if (!inputScripts.add(bytestringToInputScript(programs))) { return null; } } for (Script inScript : inputScripts) { for (int i = 0; i 代码示例来源:origin: HashEngineering/dashj

TransactionInput refundInput = refundTx.getInput(0);refundInput.setScriptSig(scriptSig);refundInput.verify(multisigContractOutput);stateMachine.transition(State.SAVE_STATE_IN_WALLET);

代码示例来源:origin: fr.acinq/bitcoinj-core

TransactionInput refundInput = refundTx.getInput(0);refundInput.setScriptSig(scriptSig);refundInput.verify(multisigContractOutput);stateMachine.transition(State.SAVE_STATE_IN_WALLET);

代码示例来源:origin: greenaddress/GreenBits

TransactionInput refundInput = refundTx.getInput(0);refundInput.setScriptSig(scriptSig);refundInput.verify(multisigContractOutput);stateMachine.transition(State.SAVE_STATE_IN_WALLET);

代码示例来源:origin: cash.bitcoinj/bitcoinj-core

input.verify(); // Run scripts and ensure it is valid.} catch (InsufficientMoneyException e) { throw e; // Don't fall through.

代码示例来源:origin: cash.bitcoinj/bitcoinj-core

TransactionInput refundInput = refundTx.getInput(0);refundInput.setScriptSig(scriptSig);refundInput.verify(multisigContractOutput);stateMachine.transition(State.SAVE_STATE_IN_WALLET);

代码示例来源:origin: greenaddress/GreenBits

private void basicSanityChecks(Wallet wallet, Transaction t, Address destination) throws VerificationException { assertEquals("Wrong number of tx inputs", 1, t.getInputs().size()); assertEquals("Wrong number of tx outputs",2, t.getOutputs().size()); assertEquals(destination, t.getOutput(0).getScriptPubKey().getToAddress(PARAMS)); assertEquals(wallet.currentChangeAddress(), t.getOutputs().get(1).getScriptPubKey().getToAddress(PARAMS)); assertEquals(valueOf(0, 50), t.getOutputs().get(1).getValue()); // Check the script runs and signatures verify. t.getInputs().get(0).verify();}

代码示例来源:origin: HashEngineering/dashj

final TransactionInput input = proposedTransaction.partialTx.getInput(0);input.verify(output);input.getScriptSig().correctlySpends(outputTransaction, 0, output.getScriptPubKey(), EnumSet.of(Script.VerifyFlag.DERSIG, Script.VerifyFlag.P2SH));

代码示例来源:origin: DanielKrawisz/Shufflepuff

/** * Takes in a transaction and a private key and returns a signature (if possible) * as a Bytestring object. */public Bytestring getSignature(org.bitcoinj.core.Transaction signTx, ECKey privKey) { org.bitcoinj.core.Transaction copyTx = signTx; for (int i = 0; i 代码示例来源:origin: DanielKrawisz/Shufflepuff

@Testpublic void testSigning() throws AddressFormatException { NetworkParameters netParams = TestNet3Params.get(); HexBinaryAdapter adapter = new HexBinaryAdapter(); Context cOntext= Context.getOrCreate(netParams); byte[] bx = adapter.unmarshal("0100000001bd5ee90ffe5eedd67c09c3bb348dd7dc1308800eb221b1c92dda651010519ba3010000006a4730440220467868c0b2ed001a915cca5269b928698bee8aba4fe454e1d775070d9e4041cb02205d1c979dbc75e5dc656c4e9d5969d716a383797bd5ad5df79a13d0d6e3f51ccb012102403adb7674f25212bc8cf4a97797154a4980c60e9f328c90300b71a8a04389c7ffffffff024088db60000000001976a914990628d3670f439a5f9e0dfa6492b8bbf3b3fa1b88ac76cf6edd050000001976a914b679378d01ee7203a454bca2ad25698ef23a056388ac00000000"); org.bitcoinj.core.Transaction testbx = new org.bitcoinj.core.Transaction(netParams, bx); org.bitcoinj.core.Transaction tx = new org.bitcoinj.core.Transaction(netParams); tx.addOutput(org.bitcoinj.core.Coin.SATOSHI.multiply(testbx.getOutput(0).getValue().value - 50000l), new Address(netParams, "mobDb19geJ66kkQnsSYvN9PNEKNDiNBHEp")); System.out.println(testbx.getOutput(0)); tx.addInput(testbx.getOutput(0)); String seckey = "3EC95EBFEDCF77373BABA0DE345A0962E51344CD2D0C8DBDF93AEFD0B66BE240"; byte[] privkey = Hex.decode(seckey); ECKey ecPriv = ECKey.fromPrivate(privkey); Sha256Hash hash2 = tx.hashForSignature(0, testbx.getOutput(0).getScriptPubKey().getProgram(), Transaction.SigHash.ALL, false); ECKey.ECDSASignature ecSig = ecPriv.sign(hash2); TransactionSignature txSig = new TransactionSignature(ecSig, Transaction.SigHash.ALL, false); Script inputScript = ScriptBuilder.createInputScript(txSig, ECKey.fromPublicOnly(ecPriv.getPubKey())); tx.getInput(0).setScriptSig(inputScript); String hexBin = DatatypeConverter.printHexBinary(tx.bitcoinSerialize()); System.out.println(hexBin); tx.getInput(0).verify(testbx.getOutput(0)); // SUCCESSFULLY BROADCAST WOO!}

上一篇:斗鱼盛典之观之二
下一篇:没有了
网友评论