private TrimmedOutput ensureDetached(TrimmedOutput output) { if (output.isDetached()) { return output; } else { return new TrimmedOutput(output, output.getIndex(), output.getTxHash()); } }
public byte[] getScriptBytes() { return output.getScriptBytes(); }
private OutPointOutput(CoinType type, TrimmedOutput output, boolean isGenerated) { this.type = type; this.output = ensureDetached(output); this.outPoint = output.getOutPointFor(); this.value = type.value(output.getValue()); this.isGenerated = isGenerated; }
public Sha256Hash getTxHash() { if (isDetached()) { return checkNotNull(txHash); } else { return getParentTransaction().getHash(); } }
public TransactionOutput addOutput(int index, TransactionOutput to) { checkArgument(index >= 0 && index < numberOfOutputs, "Index out of range"); checkNotNull(trimmedOutputs, "Cannot add more outputs") .put(index, new TrimmedOutput(to, index, this)); return to; }
public OutPointOutput(TrimmedOutput txo, boolean isGenerated) { this((CoinType) txo.getParams(), txo, isGenerated); }
public Script getScriptPubKey() { return output.getScriptPubKey(); }
@Override public TrimmedOutPoint getOutPointFor() { return new TrimmedOutPoint(this, getTxHash()); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; OutPointOutput that = (OutPointOutput) o; if (isGenerated != that.isGenerated) return false; if (!type.equals(that.type)) return false; if (!outPoint.equals(that.outPoint)) return false; return output.equals(that.output); }
public void addAllOutputs(List<TransactionOutput> outputs) { checkArgument(outputs.size() == numberOfOutputs, "Number of outputs don't match"); if (trimmedOutputs != null) { trimmedOutputs = null; } long index = 0; for (TransactionOutput output : outputs) { super.addOutput(new TrimmedOutput(output, index++, this)); } }
public OutPointOutput(TransactionOutPoint outPoint, TransactionOutput output, boolean isGenerated) { this(new TrimmedOutput(output, outPoint.getIndex(), outPoint.getHash()), isGenerated); }
public OutPointOutput(BitTransaction tx, long index) { this(new TrimmedOutput(tx.getOutput((int) index), index, tx.getHash()), tx.isGenerated()); }
TrimmedOutput utxo = new TrimmedOutput(coinType, proto.getValue(), byteStringToHash(proto.getOutPointHash()), proto.getOutPointIndex() & 0xFFFFFFFFL,