@Override public TrimmedOutPoint getOutPointFor() { return new TrimmedOutPoint(this, getTxHash()); }
public OutPointOutput getUnspentTxOutput(TransactionOutPoint outPoint) { lock.lock(); try { return unspentOutputs.get(TrimmedOutPoint.get(outPoint)); } finally { lock.unlock(); } } }
new TrimmedOutPoint(type, unspentTx.getTxPos(), unspentTx.getTxHash()); BitTransaction tx = checkNotNull(txs.get(outPoint.getHash())); OutPointOutput utxo = new OutPointOutput(tx, outPoint.getIndex()); if (tx.getConfidenceType() == BUILDING) { utxo.setAppearedAtChainHeight(tx.getAppearedAtChainHeight());
public long getIndex() { return outPoint.getIndex(); }
public Sha256Hash getTxHash() { return outPoint.getHash(); }
@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 int hashCode() { int result = type.hashCode(); result = 31 * result + outPoint.hashCode(); result = 31 * result + output.hashCode(); result = 31 * result + (isGenerated ? 1 : 0); return result; } }
public static TrimmedOutPoint get(TransactionOutPoint outPoint) { return new TrimmedOutPoint(outPoint.getParams(), outPoint.getIndex(), outPoint.getHash()); }
public static TrimmedOutPoint get(TransactionOutput txo) { return get(txo.getOutPointFor()); }
private Map<TrimmedOutPoint, OutPointOutput> getDummyUtxoSet() throws AddressMalformedException, JSONException { final HashMap<TrimmedOutPoint, OutPointOutput> unspentOutputs = new HashMap<>(); for (int i = 0; i < statuses.length; i++) { BitAddress address = (BitAddress) DOGE.newAddress(addresses.get(i)); JSONArray utxoArray = new JSONArray(unspent[i]); for (int j = 0; j < utxoArray.length(); j++) { JSONObject utxoObject = utxoArray.getJSONObject(j); //"[{\"tx_hash\": \"ef74da273e8a77e2d60b707414fb7e0ccb35c7b1b936800a49fe953195b1799f\", \"tx_pos\": 11, \"value\": 500000000, \"height\": 160267}]", TrimmedOutPoint outPoint = new TrimmedOutPoint(DOGE, utxoObject.getInt("tx_pos"), new Sha256Hash(utxoObject.getString("tx_hash"))); TransactionOutput output = new TransactionOutput(DOGE, null, Coin.valueOf(utxoObject.getLong("value")), address); OutPointOutput utxo = new OutPointOutput(outPoint, output, false); unspentOutputs.put(outPoint, utxo); } } return unspentOutputs; }
public static TrimmedOutPoint get(TransactionInput input) { return get(input.getOutpoint()); }
private void setAppearedAtChainHeight(BitTransaction tx, int height, boolean updateUtxoSet) { checkState(lock.isHeldByCurrentThread(), "Lock is held by another thread"); tx.setAppearedAtChainHeight(height); fetchTimestamp(tx, height); // Update unspent outputs if (updateUtxoSet) { for (TransactionOutput output : tx.getOutputs(false)) { OutPointOutput unspentOutput = unspentOutputs.get(TrimmedOutPoint.get(output)); if (unspentOutput != null) { unspentOutput.setAppearedAtChainHeight(height); } } } }
private void maybeUpdateBlockDepth(BitTransaction tx, boolean updateUtxoSet) { checkState(lock.isHeldByCurrentThread(), "Lock is held by another thread"); if (tx.getConfidenceType() != BUILDING) return; int newDepth = lastBlockSeenHeight - tx.getAppearedAtChainHeight() + 1; if (newDepth > 1) { tx.setDepthInBlocks(newDepth); // Update unspent outputs if (updateUtxoSet) { for (TransactionOutput output : tx.getOutputs(false)) { OutPointOutput unspentOutput = unspentOutputs.get(TrimmedOutPoint.get(output)); if (unspentOutput != null) { unspentOutput.setDepthInBlocks(newDepth); } } } } }