TransactionOutPointLock(NetworkParameters params, TransactionOutPoint outpoint) { this.outpoint = new TransactionOutPoint(params, outpoint.getIndex(), outpoint.getHash()); mapMasternodeVotes = new HashMap<TransactionOutPoint, TransactionLockVote>(10); }
/** * Returns the pubkey script from the connected output. * @throws java.lang.NullPointerException if there is no connected output. */ public byte[] getConnectedPubKeyScript() { byte[] result = checkNotNull(getConnectedOutput()).getScriptBytes(); checkState(result.length > 0); return result; }
@Override protected void parse() throws ProtocolException { includeMempool = readBytes(1)[0] == 1; long numOutpoints = readVarInt(); ImmutableList.Builder<TransactionOutPoint> list = ImmutableList.builder(); for (int i = 0; i < numOutpoints; i++) { TransactionOutPoint outPoint = new TransactionOutPoint(params, payload, cursor); list.add(outPoint); cursor += outPoint.getMessageSize(); } outPoints = list.build(); length = cursor; }
int prevIndex = (int) input.getOutpoint().getIndex(); byte[] prevHash = input.getOutpoint().getHash().getBytes(); throw new IllegalArgumentException("Malformed input (no output)"); if (input.getOutpoint().getConnectedOutput() == null) { throw new IllegalArgumentException("Malformed input (no connected output to outpoint)"); if (input.getOutpoint().getConnectedOutput().getParentTransaction() == null) { throw new IllegalArgumentException("Malformed input (connected output to outpoint has no parent)"); Transaction prevTx = input.getOutpoint().getConnectedOutput().getParentTransaction(); int prevIndex = (int) prevInput.getOutpoint().getIndex(); byte[] prevHash = prevInput.getOutpoint().getHash().getBytes();
/** * Creates an input that connects to nothing - used only in creation of coinbase transactions. */ public TransactionInput(NetworkParameters params, @Nullable Transaction parentTransaction, byte[] scriptBytes) { this(params, parentTransaction, scriptBytes, new TransactionOutPoint(params, UNCONNECTED, (Transaction) null)); }
/** Finds whether txA spends txB */ boolean spends(Transaction txA, Transaction txB) { for (TransactionInput txInput : txA.getInputs()) { if (txInput.getOutpoint().getHash().equals(txB.getHash())) { return true; } } return false; }
public UnspentTx(TransactionOutPoint txop, long value, int height) { super(txop, height); this.txPos = (int) txop.getIndex(); this.value = value; }
continue; if (txInput.getOutpoint().getConnectedOutput() == null) { log.warn("Connected output for input {} is null", txInput); continue; if (Arrays.areEqual(txHash, txInput.getOutpoint().getHash().getBytes())) { Transaction parentTx = txInput.getOutpoint().getConnectedOutput().getParentTransaction(); if (parentTx == null) { log.warn("Parent transaction for input {} is null", txInput);
@Test public void removeScriptsBloomFilter() throws Exception { List<Address> addressesForRemoval = new ArrayList<>(); for (int i = 0; i < 10; i++) { Address watchedAddress = new ECKey().toAddress(PARAMS); addressesForRemoval.add(watchedAddress); wallet.addWatchedAddress(watchedAddress); } wallet.removeWatchedAddresses(addressesForRemoval); for (Address addr : addressesForRemoval) { Transaction t1 = createFakeTx(PARAMS, CENT, addr); TransactionOutPoint outPoint = new TransactionOutPoint(PARAMS, 0, t1); // Note that this has a 1e-12 chance of failing this unit test due to a false positive assertFalse(wallet.getBloomFilter(1e-12).contains(outPoint.unsafeBitcoinSerialize())); sendMoneyToWallet(BlockChain.NewBlockType.BEST_CHAIN, t1); assertFalse(wallet.getBloomFilter(1e-12).contains(outPoint.unsafeBitcoinSerialize())); } }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; TransactionInput other = (TransactionInput) o; return sequence == other.sequence && parent == other.parent && outpoint.equals(other.outpoint) && Arrays.equals(scriptBytes, other.scriptBytes); }
final Sha256Hash dephash = tx.getInput(0).getOutpoint().getHash(); final InventoryItem inv = new InventoryItem(InventoryItem.Type.Transaction, dephash); inbound(p1, new NotFoundMessage(PARAMS, ImmutableList.of(inv))); assertTrue(p3.lastReceivedFilter.contains(outpoint.unsafeBitcoinSerialize()));
filter.insert(point.unsafeBitcoinSerialize()); return filter; } finally {
@Override protected void bitcoinSerializeToStream(OutputStream stream) throws IOException { stream.write(txHash.getBytes()); //writes 32 outpoint.bitcoinSerialize(stream); outpointMasternode.bitcoinSerialize(stream); stream.write(new VarInt(vchMasternodeSignature.length).encode()); vchMasternodeSignature.bitcoinSerialize(stream); }
@Override protected void bitcoinSerializeToStream(OutputStream stream) throws IOException { stream.write(new byte[]{includeMempool ? (byte) 1 : 0}); // include mempool. stream.write(new VarInt(outPoints.size()).encode()); for (TransactionOutPoint outPoint : outPoints) { outPoint.bitcoinSerializeToStream(stream); } }
int prevIndex = (int) input.getOutpoint().getIndex(); byte[] prevHash = input.getOutpoint().getHash().getBytes(); throw new IllegalArgumentException("Malformed input (no output)"); if (input.getOutpoint().getConnectedOutput() == null) { throw new IllegalArgumentException("Malformed input (no connected output to outpoint)"); if (input.getOutpoint().getConnectedOutput().getParentTransaction() == null) { throw new IllegalArgumentException("Malformed input (connected output to outpoint has no parent)"); Transaction prevTx = input.getOutpoint().getConnectedOutput().getParentTransaction(); int prevIndex = (int) prevInput.getOutpoint().getIndex(); byte[] prevHash = prevInput.getOutpoint().getHash().getBytes();
/** * Creates an input that connects to nothing - used only in creation of coinbase transactions. */ public TransactionInput(NetworkParameters params, @Nullable Transaction parentTransaction, byte[] scriptBytes) { this(params, parentTransaction, scriptBytes, new TransactionOutPoint(params, UNCONNECTED, (Transaction) null)); }
/** Finds whether txA spends txB */ boolean spends(Transaction txA, Transaction txB) { for (TransactionInput txInput : txA.getInputs()) { if (txInput.getOutpoint().getHash().equals(txB.getHash())) { return true; } } return false; }
/** * 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); }
@Override protected void parse() throws ProtocolException { outpoint = new TransactionOutPoint(params, payload, cursor, this, serializer); cursor += outpoint.getMessageSize(); int scriptLen = (int) readVarInt(); length = cursor - offset + scriptLen + 4; scriptBytes = readBytes(scriptLen); sequence = readUint32(); }