@Nullable @Override public VerificationException call() throws Exception { try { ListIterator<Script> prevOutIt = prevOutScripts.listIterator(); for (int index = 0; index < tx.getInputs().size(); index++) { tx.getInputs().get(index).getScriptSig().correctlySpends(tx, index, prevOutIt.next(), verifyFlags); } } catch (VerificationException e) { return e; } return null; } }
@Nullable @Override public VerificationException call() throws Exception { try { ListIterator<Script> prevOutIt = prevOutScripts.listIterator(); for (int index = 0; index < tx.getInputs().size(); index++) { tx.getInputs().get(index).getScriptSig().correctlySpends(tx, index, prevOutIt.next(), verifyFlags); } } catch (VerificationException e) { return e; } return null; } }
@Nullable @Override public VerificationException call() throws Exception { try { ListIterator<Script> prevOutIt = prevOutScripts.listIterator(); for (int index = 0; index < tx.getInputs().size(); index++) { tx.getInputs().get(index).getScriptSig().correctlySpends(tx, index, prevOutIt.next(), verifyFlags); } } catch (VerificationException e) { return e; } return null; } }
/** * The priority (coin age) calculation doesn't use the regular message size, but rather one adjusted downwards * for the number of inputs. The goal is to incentivise cleaning up the UTXO set with free transactions, if one * can do so. */ public int getMessageSizeForPriorityCalc() { int size = getMessageSize(); for (TransactionInput input : inputs) { // 41: min size of an input // 110: enough to cover a compressed pubkey p2sh redemption (somewhat arbitrary). int benefit = 41 + Math.min(110, input.getScriptSig().getProgram().length); if (size > benefit) size -= benefit; } return size; }
/** * The priority (coin age) calculation doesn't use the regular message size, but rather one adjusted downwards * for the number of inputs. The goal is to incentivise cleaning up the UTXO set with free transactions, if one * can do so. */ public int getMessageSizeForPriorityCalc() { int size = getMessageSize(); for (TransactionInput input : inputs) { // 41: min size of an input // 110: enough to cover a compressed pubkey p2sh redemption (somewhat arbitrary). int benefit = 41 + Math.min(110, input.getScriptSig().getProgram().length); if (size > benefit) size -= benefit; } return size; }
/** * The priority (coin age) calculation doesn't use the regular message size, but rather one adjusted downwards * for the number of inputs. The goal is to incentivise cleaning up the UTXO set with free transactions, if one * can do so. */ public int getMessageSizeForPriorityCalc() { int size = getMessageSize(); for (TransactionInput input : inputs) { // 41: min size of an input // 110: enough to cover a compressed pubkey p2sh redemption (somewhat arbitrary). int benefit = 41 + Math.min(110, input.getScriptSig().getProgram().length); if (size > benefit) size -= benefit; } return size; }
/** * The priority (coin age) calculation doesn't use the regular message size, but rather one adjusted downwards * for the number of inputs. The goal is to incentivise cleaning up the UTXO set with free transactions, if one * can do so. */ public int getMessageSizeForPriorityCalc() { int size = getMessageSize(); for (TransactionInput input : inputs) { // 41: min size of an input // 110: enough to cover a compressed pubkey p2sh redemption (somewhat arbitrary). int benefit = 41 + Math.min(110, input.getScriptSig().getProgram().length); if (size > benefit) size -= benefit; } return size; }
private boolean isInputMine(TransactionInput input) { lock.lock(); try { try { Script script = input.getScriptSig(); // TODO check multi sig scripts return isPubKeyMine(script.getPubKey()); } catch (ScriptException e) { // We didn't understand this input ScriptSig: ignore it. log.debug("Could not parse tx input script: {}", e.toString()); return false; } } finally { lock.unlock(); } }
String toStringCpp() { String str; str = "CTxIn("; str = str + getOutpoint().toStringCpp(); if (isCoinBase()) str = str + ", coinbase " + scriptSig.toString(); else str = str + ", scriptSig="+ (getScriptSig().getChunks().size() != 0 ? getScriptSig().toString().substring(0,24) : ""); if (this.sequence != 4294967295L) str = str + ", nSequence=" + sequence; str = str + ")"; return str; }
private boolean isInputMine(TransactionInput input) { lock.lock(); try { try { Script script = input.getScriptSig(); // TODO check multi sig scripts return isPubKeyMine(script.getPubKey()); } catch (ScriptException e) { // We didn't understand this input ScriptSig: ignore it. log.debug("Could not parse tx input script: {}", e.toString()); return false; } } finally { lock.unlock(); } }
/** * Convenience method that returns the from address of this input by parsing the scriptSig. The concept of a * "from address" is not well defined in Bitcoin and you should not assume that senders of a transaction can * actually receive coins on the same address they used to sign (e.g. this is not true for shared wallets). */ @Deprecated public Address getFromAddress() throws ScriptException { if (isCoinBase()) { throw new ScriptException( "This is a coinbase transaction which generates new coins. It does not have a from address."); } return getScriptSig().getFromAddress(params); }
/** * Convenience method that returns the from address of this input by parsing the scriptSig. The concept of a * "from address" is not well defined in Bitcoin and you should not assume that senders of a transaction can * actually receive coins on the same address they used to sign (e.g. this is not true for shared wallets). */ @Deprecated public Address getFromAddress() throws ScriptException { if (isCoinBase()) { throw new ScriptException( "This is a coinbase transaction which generates new coins. It does not have a from address."); } return getScriptSig().getFromAddress(params); }
/** * Convenience method that returns the from address of this input by parsing the scriptSig. The concept of a * "from address" is not well defined in Bitcoin and you should not assume that senders of a transaction can * actually receive coins on the same address they used to sign (e.g. this is not true for shared wallets). */ @Deprecated public Address getFromAddress() throws ScriptException { if (isCoinBase()) { throw new ScriptException( "This is a coinbase transaction which generates new coins. It does not have a from address."); } return getScriptSig().getFromAddress(params); }
/** * Convenience method that returns the from address of this input by parsing the scriptSig. The concept of a * "from address" is not well defined in Bitcoin and you should not assume that senders of a transaction can * actually receive coins on the same address they used to sign (e.g. this is not true for shared wallets). */ @Deprecated public Address getFromAddress() throws ScriptException { if (isCoinBase()) { throw new ScriptException( ScriptError.SCRIPT_ERR_UNKNOWN_ERROR, "This is a coinbase transaction which generates new coins. It does not have a from address."); } return getScriptSig().getFromAddress(params); }
@Nullable @Override public VerificationException call() throws Exception { try { ListIterator<Script> prevOutIt = prevOutScripts.listIterator(); for (int index = 0; index < tx.getInputs().size(); index++) { Coin value = tx.getInput(index).getConnectedOutput() != null ? tx.getInput(index).getConnectedOutput().getValue() : Coin.ZERO; tx.getInputs().get(index).getScriptSig().correctlySpends(tx, index, prevOutIt.next(), value, verifyFlags); } } catch (VerificationException e) { return e; } return null; } }
@Override public 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; }
boolean addSig(final TransactionInput vin) { for(DarkSendEntryVin s : sev) { if(s.vin.getOutpoint().equals(vin.getOutpoint()) && s.vin.getSequenceNumber() == vin.getSequenceNumber()){ if(s.isSigSet){return false;} s.vin.setScriptSig(vin.getScriptSig()); //TODO: ???? s.vin.prevPubKey = vin.prevPubKey; s.isSigSet = true; return true; } } return false; }
public void completeTxPartiallySignedMarried(Wallet.MissingSigsMode missSigMode, byte[] expectedSig) throws Exception { // create married wallet without signer createMarriedWallet(2, 2, false); myAddress = wallet.currentAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS); sendMoneyToWallet(AbstractBlockChain.NewBlockType.BEST_CHAIN, COIN, myAddress); SendRequest req = SendRequest.emptyWallet(OTHER_ADDRESS); req.missingSigsMode = missSigMode; wallet.completeTx(req); TransactionInput input = req.tx.getInput(0); boolean firstSigIsMissing = Arrays.equals(expectedSig, input.getScriptSig().getChunks().get(1).data); boolean secondSigIsMissing = Arrays.equals(expectedSig, input.getScriptSig().getChunks().get(2).data); assertTrue("Only one of the signatures should be missing/dummy", firstSigIsMissing ^ secondSigIsMissing); int localSigIndex = firstSigIsMissing ? 2 : 1; int length = input.getScriptSig().getChunks().get(localSigIndex).data.length; assertTrue("Local sig should be present: " + length, length >= 70); }
/** * 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 { if (output.parent != null) { if (!getOutpoint().getHash().equals(output.getParentTransaction().getHash())) throw new VerificationException("This input does not refer to the tx containing the output."); if (getOutpoint().getIndex() != output.getIndex()) throw new VerificationException("This input refers to a different output on the given tx."); } Script pubKey = output.getScriptPubKey(); int myIndex = getParentTransaction().getInputs().indexOf(this); getScriptSig().correctlySpends(getParentTransaction(), myIndex, pubKey); }
/** * 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. * @param flagSet flags for script interpreter. * @throws ScriptException If the script doesn't verify. * @throws VerificationException If the outpoint doesn't match the given output. */ public void verify(TransactionOutput output, Set<Script.VerifyFlag> flagSet) throws VerificationException { if (output.parent != null) { if (!getOutpoint().getHash().equals(output.getParentTransaction().getHash())) throw new VerificationException("This input does not refer to the tx containing the output."); if (getOutpoint().getIndex() != output.getIndex()) throw new VerificationException("This input refers to a different output on the given tx."); } Script pkScript = output.getScriptPubKey(); int myIndex = getParentTransaction().getInputs().indexOf(this); getScriptSig().correctlySpends(getParentTransaction(), myIndex, pkScript, output.getValue(), flagSet); }