private boolean isOutputAvailable(int index) { if (tx instanceof TrimmedTransaction) { return ((TrimmedTransaction) tx).isOutputAvailable(index); } else { return index < getNumberOfOutputs(); } }
@Override public TrimmedOutPoint getOutPointFor() { return new TrimmedOutPoint(this, getTxHash()); }
private TrimmedOutput ensureDetached(TrimmedOutput output) { if (output.isDetached()) { return output; } else { return new TrimmedOutput(output, output.getIndex(), output.getTxHash()); } }
public OutPointOutput(BitTransaction tx, long index) { this(new TrimmedOutput(tx.getOutput((int) index), index, tx.getHash()), tx.isGenerated()); }
public static BitSendRequest emptyWallet(BitAddress destination) { checkNotNull(destination.getType(), "Address is for an unknown network"); checkTypeCompatibility(destination.getType()); BitSendRequest req = new BitSendRequest(destination.getType()); Transaction tx = new Transaction(req.type); tx.addOutput(Coin.ZERO, destination); req.tx = new BitTransaction(tx); req.emptyWallet = true; return req; }
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; }
@Override public BitAddress newAddress(String addressStr) throws AddressMalformedException { return BitAddress.from(this, addressStr); } }
public static BitTransaction fromTrimmed(Sha256Hash transactionId, Transaction transaction, Value valueSent, Value valueReceived, Value fee) { return new BitTransaction(transactionId, transaction, true, valueSent, valueReceived, fee); }
public List<TransactionOutput> getOutputs() { return getOutputs(true); }
/** * {@link #sendCoinsOffline(BitAddress, Value)} */ public BitSendRequest sendCoinsOffline(BitAddress address, Value amount, @Nullable KeyParameter aesKey) throws WalletAccountException { checkState(address.getParameters() instanceof CoinType); BitSendRequest request = BitSendRequest.to(address, amount); request.aesKey = aesKey; return request; }
@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); }
@Override public List<TransactionOutput> getOutputs() { return getOutputs(true); }
@Override public CoinType getType() { return (CoinType) getParameters(); }
public Sha256Hash getTxHash() { return outPoint.getHash(); }
public OutPointOutput(TrimmedOutput txo, boolean isGenerated) { this((CoinType) txo.getParams(), txo, isGenerated); }
public long getIndex() { return outPoint.getIndex(); }
public byte[] getScriptBytes() { return output.getScriptBytes(); }
public Script getScriptPubKey() { return output.getScriptPubKey(); }