public static boolean isSelectable(Transaction tx) { // Only pick chain-included transactions, or transactions that are ours and pending. TransactionConfidence confidence = tx.getConfidence(); TransactionConfidence.ConfidenceType type = confidence.getConfidenceType(); return type.equals(TransactionConfidence.ConfidenceType.BUILDING) || type.equals(TransactionConfidence.ConfidenceType.PENDING) && confidence.getSource().equals(TransactionConfidence.Source.SELF) && // 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().getId().equals(NetworkParameters.ID_REGTEST)); } }
public static boolean isSelectable(Transaction tx) { // Only pick chain-included transactions, or transactions that are ours and pending. TransactionConfidence confidence = tx.getConfidence(); TransactionConfidence.ConfidenceType type = confidence.getConfidenceType(); return type.equals(TransactionConfidence.ConfidenceType.BUILDING) || type.equals(TransactionConfidence.ConfidenceType.PENDING) && confidence.getSource().equals(TransactionConfidence.Source.SELF) && // 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().getId().equals(NetworkParameters.ID_REGTEST)); } }
public static boolean isSelectable(Transaction tx) { // Only pick chain-included transactions, or transactions that are ours and pending. TransactionConfidence confidence = tx.getConfidence(); TransactionConfidence.ConfidenceType type = confidence.getConfidenceType(); return type.equals(TransactionConfidence.ConfidenceType.BUILDING) || type.equals(TransactionConfidence.ConfidenceType.PENDING) && confidence.getSource().equals(TransactionConfidence.Source.SELF) && // 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().getId().equals(NetworkParameters.ID_REGTEST)); } }
if (TransactionConfidence.ConfidenceType.BUILDING.equals(confidenceType)) { return paymentStatus; } else if (TransactionConfidence.ConfidenceType.PENDING.equals(confidenceType)) { if (numberOfPeers >= 2) { } else if (TransactionConfidence.ConfidenceType.DEAD.equals(confidenceType)) { } else if (TransactionConfidence.ConfidenceType.UNKNOWN.equals(confidenceType)) {
@Override public void onConfidenceChanged(TransactionConfidence confidence, ChangeReason reason) { if (reason.equals(ChangeReason.TYPE)) { if (confidence.getConfidenceType().equals(ConfidenceType.PENDING)) { processPendingTransactions(tx); // Continue tracking the transaction. } else if (confidence.getConfidenceType().equals(ConfidenceType.BUILDING)) { processBuildingTransaction(tx); // Continue tracking the transaction for confirmation. } else if (confidence.getConfidenceType().equals(DEAD)) { // Stop tracking the transaction. tx.getBitcoinjTransaction().getConfidence().removeEventListener(this); } } else if (reason.equals(ChangeReason.DEPTH)) { if (confidence.getDepthInBlocks() >= configHolder.getBitcoinConfirmationBlockdepth()) { confirmTransaction(tx); tx.getBitcoinjTransaction().getConfidence().removeEventListener(this); } } } });
private PaymentType calculatePaymentType(Coin amountBTC, int depth, TransactionConfidence.ConfidenceType confidenceType) { PaymentType paymentType; if (amountBTC.compareTo(Coin.ZERO) < 0) { // Debit if (depth > 0 || TransactionConfidence.ConfidenceType.BUILDING.equals(confidenceType)) { paymentType = PaymentType.SENT; } else { paymentType = PaymentType.SENDING; } } else { // Credit if (depth > 0 || TransactionConfidence.ConfidenceType.BUILDING.equals(confidenceType)) { paymentType = PaymentType.RECEIVED; } else { paymentType = PaymentType.RECEIVING; } } return paymentType; }
/** * @param transaction The Bitcoinj transaction providing the information * @param amount The amount as calculated from the wallet */ public TransactionSeenEvent(Transaction transaction, Coin amount) { transactionId = transaction.getHashAsString(); TransactionConfidence confidence = transaction.getConfidence(); confidenceType = confidence.getConfidenceType(); if (confidenceType.equals(TransactionConfidence.ConfidenceType.BUILDING)) { depthInBlocks = confidence.getDepthInBlocks(); } else { depthInBlocks = DEPTH_IN_BLOCKS_IS_UNDEFINED; } coinbase = transaction.isCoinBase(); numberOfPeers = confidence.numBroadcastPeers(); this.amount = amount; firstAppearanceInWallet = false; }
private boolean isPending(Transaction tx) { return tx.getConfidence().getConfidenceType().equals(ConfidenceType.PENDING); }
private boolean isUnknown(Transaction tx) { return tx.getConfidence().getConfidenceType().equals(ConfidenceType.UNKNOWN); }
private boolean isBuilding(Transaction bitcoinjTx) { return bitcoinjTx.getConfidence().getConfidenceType().equals(ConfidenceType.BUILDING); }
private boolean isConfirmed(TransactionOutput output) { return output.getParentTransaction().getConfidence().getConfidenceType().equals(TransactionConfidence.ConfidenceType.BUILDING); } }
private boolean isConfirmed(TransactionOutput output) { return output.getParentTransaction().getConfidence().getConfidenceType().equals(TransactionConfidence.ConfidenceType.BUILDING); } }
private boolean isConfirmed(TransactionOutput output) { return output.getParentTransaction().getConfidence().getConfidenceType().equals(TransactionConfidence.ConfidenceType.BUILDING); } }
private boolean isConfirmed(TransactionOutput output) { return output.getParentTransaction().getConfidence().getConfidenceType().equals(TransactionConfidence.ConfidenceType.BUILDING); } }
/** Finds if tx is NOT spending other txns which are in the specified confidence type */ private boolean isNotSpendingTxnsInConfidenceType(Transaction tx, ConfidenceType confidenceType) { for (TransactionInput txInput : tx.getInputs()) { Transaction connectedTx = this.getTransaction(txInput.getOutpoint().getHash()); if (connectedTx != null && connectedTx.getConfidence().getConfidenceType().equals(confidenceType)) { return false; } } return true; }
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()); } }
/** Finds if tx is NOT spending other txns which are in the specified confidence type */ private boolean isNotSpendingTxnsInConfidenceType(Transaction tx, ConfidenceType confidenceType) { for (TransactionInput txInput : tx.getInputs()) { Transaction connectedTx = this.getTransaction(txInput.getOutpoint().getHash()); if (connectedTx != null && connectedTx.getConfidence().getConfidenceType().equals(confidenceType)) { return false; } } return true; }
public static boolean isSelectable(Transaction tx) { // Only pick chain-included transactions, or transactions that are ours and pending. TransactionConfidence confidence = tx.getConfidence(); TransactionConfidence.ConfidenceType type = confidence.getConfidenceType(); return type.equals(TransactionConfidence.ConfidenceType.BUILDING) || type.equals(TransactionConfidence.ConfidenceType.PENDING) && confidence.getSource().equals(TransactionConfidence.Source.SELF) && // 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().getId().equals(NetworkParameters.ID_REGTEST)); } }
/** Finds if tx is NOT spending other txns which are in the specified confidence type */ private boolean isNotSpendingTxnsInConfidenceType(Transaction tx, ConfidenceType confidenceType) { for (TransactionInput txInput : tx.getInputs()) { Transaction connectedTx = this.getTransaction(txInput.getOutpoint().getHash()); if (connectedTx != null && connectedTx.getConfidence().getConfidenceType().equals(confidenceType)) { return false; } } return true; }
/** Finds if tx is NOT spending other txns which are in the specified confidence type */ private boolean isNotSpendingTxnsInConfidenceType(Transaction tx, ConfidenceType confidenceType) { for (TransactionInput txInput : tx.getInputs()) { Transaction connectedTx = this.getTransaction(txInput.getOutpoint().getHash()); if (connectedTx != null && connectedTx.getConfidence().getConfidenceType().equals(confidenceType)) { return false; } } return true; }