@Override public void onConfidenceChanged(TransactionConfidence confidence, ChangeReason reason) { if (getDepthInBlocks() >= depth) { removeEventListener(this); result.set(confidence); } } });
@Override public int getDepthInBlocks() { return tx.getConfidence().getDepthInBlocks(); }
@Override public void onConfidenceChanged(TransactionConfidence confidence, ChangeReason reason) { if (getDepthInBlocks() >= depth) { removeEventListener(this); result.set(confidence); } } });
@Override public void onConfidenceChanged(TransactionConfidence confidence, ChangeReason reason) { if (getDepthInBlocks() >= depth) { removeEventListener(this); result.set(confidence); } } });
@Override public void onConfidenceChanged(TransactionConfidence confidence, ChangeReason reason) { if (getDepthInBlocks() >= depth) { removeEventListener(this); result.set(confidence); } } });
@Override public int getDepthInBlocks() { return tx.getConfidence().getDepthInBlocks(); }
@Override public void onTransactionConfidenceChanged(Wallet wallet, Transaction tx) { System.out.println("-----> confidence changed: " + tx.getHashAsString()); TransactionConfidence confidence = tx.getConfidence(); System.out.println("new block depth: " + confidence.getDepthInBlocks()); } });
@Override public void serialize(Transaction value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { jgen.writeStartObject(); // See RawTransactionInfo POJO for a more complete JSON representation of a Transaction that is used by JSON-RPC jgen.writeNumberField("confirmations", value.getConfidence().getDepthInBlocks()); jgen.writeNumberField("version", value.getVersion()); jgen.writeStringField("hash", value.getHashAsString()); jgen.writeEndObject(); } }
/** * Subtract the supplied depth from the given transactions. */ private void subtractDepth(int depthToSubtract, Collection<Transaction> transactions) { for (Transaction tx : transactions) { if (tx.getConfidence().getConfidenceType() == ConfidenceType.BUILDING) { tx.getConfidence().setDepthInBlocks(tx.getConfidence().getDepthInBlocks() - depthToSubtract); confidenceChanged.put(tx, TransactionConfidence.Listener.ChangeReason.DEPTH); } } }
/** * Subtract the supplied depth from the given transactions. */ private void subtractDepth(int depthToSubtract, Collection<Transaction> transactions) { for (Transaction tx : transactions) { if (tx.getConfidence().getConfidenceType() == ConfidenceType.BUILDING) { tx.getConfidence().setDepthInBlocks(tx.getConfidence().getDepthInBlocks() - depthToSubtract); confidenceChanged.put(tx, TransactionConfidence.Listener.ChangeReason.DEPTH); } } }
/** * Subtract the supplied depth from the given transactions. */ private void subtractDepth(int depthToSubtract, Collection<Transaction> transactions) { for (Transaction tx : transactions) { if (tx.getConfidence().getConfidenceType() == ConfidenceType.BUILDING) { tx.getConfidence().setDepthInBlocks(tx.getConfidence().getDepthInBlocks() - depthToSubtract); confidenceChanged.put(tx, TransactionConfidence.Listener.ChangeReason.DEPTH); } } }
/** * Subtract the supplied depth from the given transactions. */ private void subtractDepth(int depthToSubtract, Collection<Transaction> transactions) { for (Transaction tx : transactions) { if (tx.getConfidence().getConfidenceType() == ConfidenceType.BUILDING) { tx.getConfidence().setDepthInBlocks(tx.getConfidence().getDepthInBlocks() - depthToSubtract); confidenceChanged.put(tx, TransactionConfidence.Listener.ChangeReason.DEPTH); } } }
/** * Returns the depth in blocks of the parent tx. * * <p>If the transaction appears in the top block, the depth is one. If it's anything else (pending, dead, unknown) * then -1.</p> * @return The tx depth or -1. */ public int getParentTransactionDepthInBlocks() { if (getParentTransaction() != null) { TransactionConfidence confidence = getParentTransaction().getConfidence(); if (confidence.getConfidenceType() == TransactionConfidence.ConfidenceType.BUILDING) { return confidence.getDepthInBlocks(); } } return -1; }
/** * Returns the depth in blocks of the parent tx. * * <p>If the transaction appears in the top block, the depth is one. If it's anything else (pending, dead, unknown) * then -1.</p> * @return The tx depth or -1. */ public int getParentTransactionDepthInBlocks() { if (getParentTransaction() != null) { TransactionConfidence confidence = getParentTransaction().getConfidence(); if (confidence.getConfidenceType() == TransactionConfidence.ConfidenceType.BUILDING) { return confidence.getDepthInBlocks(); } } return -1; }
/** * Returns the depth in blocks of the parent tx. * * <p>If the transaction appears in the top block, the depth is one. If it's anything else (pending, dead, unknown) * then -1.</p> * @return The tx depth or -1. */ public int getParentTransactionDepthInBlocks() { if (getParentTransaction() != null) { TransactionConfidence confidence = getParentTransaction().getConfidence(); if (confidence.getConfidenceType() == TransactionConfidence.ConfidenceType.BUILDING) { return confidence.getDepthInBlocks(); } } return -1; }
/** * A transaction is mature if it is either a building coinbase tx that is as deep or deeper than the required coinbase depth, or a non-coinbase tx. */ public boolean isMature() { if (!isCoinBase()) return true; if (getConfidence().getConfidenceType() != ConfidenceType.BUILDING) return false; return getConfidence().getDepthInBlocks() >= params.getSpendableCoinbaseDepth(); }
/** * A transaction is mature if it is either a building coinbase tx that is as deep or deeper than the required coinbase depth, or a non-coinbase tx. */ public boolean isMature() { if (!isCoinBase()) return true; if (getConfidence().getConfidenceType() != ConfidenceType.BUILDING) return false; return getConfidence().getDepthInBlocks() >= params.getSpendableCoinbaseDepth(); }
/** * A transaction is mature if it is either a building coinbase tx that is as deep or deeper than the required * coinbase depth, or a non-coinbase tx. */ public boolean isMature() { if (!isCoinBase()) return true; if (getConfidence().getConfidenceType() != ConfidenceType.BUILDING) return false; return getConfidence().getDepthInBlocks() >= params.getSpendableCoinbaseDepth(); }
/** * A transaction is mature if it is either a building coinbase tx that is as deep or deeper than the required coinbase depth, or a non-coinbase tx. */ public boolean isMature() { if (!isCoinBase()) return true; if (getConfidence().getConfidenceType() != ConfidenceType.BUILDING) return false; return getConfidence().getDepthInBlocks() >= params.getSpendableCoinbaseDepth(); }
public static boolean isSelectable(Transaction tx, boolean usingInstantX) { // Only pick chain-included transactions, or transactions that are pending (whether ours or not). // InstantSend requires 6 confirmations TransactionConfidence confidence = tx.getConfidence(); TransactionConfidence.ConfidenceType type = confidence.getConfidenceType(); return (type.equals(TransactionConfidence.ConfidenceType.BUILDING) && (usingInstantX ? confidence.getDepthInBlocks() >= 6 : true)) || type.equals(TransactionConfidence.ConfidenceType.PENDING) && (usingInstantX ? false : true) && // In regtest mode we expect to have only one peer, so we won't see transactions propagate. // TODO: The value 1 below dates from a time when transactions we broadcast *to* were counted, set to 0 (confidence.numBroadcastPeers() > 1 || tx.getParams() == RegTestParams.get()); } }