/** * If the transactions outputs are all marked as spent, and it's in the unspent map, move it. * If the owned transactions outputs are not all marked as spent, and it's in the spent map, move it. */ private void maybeMovePool(BitTransaction tx) { lock.lock(); try { if (tx.getConfidenceType() == BUILDING) { // Transaction is confirmed, move it if (pending.remove(tx.getHash()) != null) { confirmed.put(tx.getHash(), tx); trimTransaction(tx.getHash()); } } } finally { lock.unlock(); } }
public void restoreWalletTransactions(ArrayList<WalletTransaction<BitTransaction>> wtxs) { lock.lock(); try { for (WalletTransaction<BitTransaction> wtx : wtxs) { BitTransaction tx = wtx.getTransaction(); simpleAddTransaction(wtx.getPool(), tx); if (tx.getConfidenceType() == BUILDING && tx.getTimestamp() == 0) { fetchTimestamp(tx, tx.getAppearedAtChainHeight()); } } } finally { lock.unlock(); } }
if (tx.getConfidenceType() == UNKNOWN) {
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); } } } } }
try { if (pool == null) { switch (tx.getConfidenceType()) { case BUILDING: pool = WalletTransaction.Pool.CONFIRMED; default: throw new RuntimeException("Unsupported confidence type: " + tx.getConfidenceType().name());
private void checkTxConfirmation(HistoryTx historyTx, BitTransaction tx) { checkState(lock.isHeldByCurrentThread(), "Lock is held by another thread"); int height = historyTx.getHeight(); TransactionConfidence.ConfidenceType confidence = tx.getConfidenceType(); if (height > 0) { switch (confidence) { case BUILDING: // If the height is the same, don't do anything if (tx.getAppearedAtChainHeight() == historyTx.getHeight()) { break; } case PENDING: setAppearedAtChainHeight(tx, height, true); maybeUpdateBlockDepth(tx, true); maybeMovePool(tx); break; case DEAD: case UNKNOWN: default: throw new RuntimeException("Unsupported confidence type: " + tx.getConfidenceType().name()); } } }
if (txo.isAvailableForSpending() && txo.isMineOrWatched(account)) { OutPointOutput utxo = new OutPointOutput(tx, txo.getIndex()); if (tx.getConfidenceType() == BUILDING) { utxo.setAppearedAtChainHeight(tx.getAppearedAtChainHeight()); utxo.setDepthInBlocks(tx.getDepthInBlocks());
if (tx.getConfidenceType() == BUILDING) { utxo.setAppearedAtChainHeight(tx.getAppearedAtChainHeight()); utxo.setDepthInBlocks(tx.getDepthInBlocks());