Program: 85866
Project: 85866
Buggy source:
private synchronized void receive(Transaction tx,StoredBlock block,BlockChain.NewBlockType blockType,boolean reorg) throws VerificationException {
  BigInteger prevBalance=getBalance();
  Sha256Hash txHash=tx.getHash();
  boolean bestChain=blockType == BlockChain.NewBlockType.BEST_CHAIN;
  boolean sideChain=blockType == BlockChain.NewBlockType.SIDE_CHAIN;
  BigInteger valueSentFromMe=tx.getValueSentFromMe(this);
  BigInteger valueSentToMe=tx.getValueSentToMe(this);
  BigInteger valueDifference=valueSentToMe.subtract(valueSentFromMe);
  if (!reorg) {
    log.info("String_Node_Str",new Object[]{sideChain ? "String_Node_Str" : "String_Node_Str",bitcoinValueToFriendlyString(valueDifference),tx.getHashAsString()});
  }
  onWalletChangedSuppressions++;
  Transaction wtx;
  if ((wtx=pending.remove(txHash)) != null) {
    tx=wtx;
    log.info("String_Node_Str");
    if (bestChain) {
      if (valueSentToMe.equals(BigInteger.ZERO)) {
        log.info("String_Node_Str");
        addWalletTransaction(Pool.SPENT,tx);
      }
 else {
        log.info("String_Node_Str");
        addWalletTransaction(Pool.UNSPENT,tx);
      }
    }
 else     if (sideChain) {
      log.info("String_Node_Str");
      boolean alreadyPresent=inactive.put(tx.getHash(),tx) != null;
      if (alreadyPresent)       log.info("String_Node_Str");
      pending.put(tx.getHash(),tx);
    }
  }
 else {
    if (sideChain) {
      if (unspent.containsKey(tx.getHash()) || spent.containsKey(tx.getHash())) {
      }
 else {
        log.info("String_Node_Str");
        addWalletTransaction(Pool.INACTIVE,tx);
      }
    }
 else     if (bestChain) {
      processTxFromBestChain(tx);
    }
  }
  log.info("String_Node_Str" + bitcoinValueToFriendlyString(getBalance()));
  if (block != null) {
    tx.setBlockAppearance(block,bestChain);
    if (bestChain) {
      ignoreNextNewBlock.add(txHash);
    }
  }
  boolean wasPending=wtx != null;
  if (!reorg && bestChain && !wasPending) {
    BigInteger newBalance=getBalance();
    int diff=valueDifference.compareTo(BigInteger.ZERO);
    if (diff > 0) {
      invokeOnCoinsReceived(tx,prevBalance,newBalance);
    }
 else     if (diff == 0) {
      invokeOnCoinsSent(tx,prevBalance,newBalance);
    }
 else {
      invokeOnCoinsSent(tx,prevBalance,newBalance);
    }
  }
  onWalletChangedSuppressions--;
  checkState(isConsistent());
  queueAutoSave();
}

Fixed version (ground truth):
private synchronized void receive(Transaction tx,StoredBlock block,BlockChain.NewBlockType blockType,boolean reorg) throws VerificationException {
  BigInteger prevBalance=getBalance();
  Sha256Hash txHash=tx.getHash();
  boolean bestChain=blockType == BlockChain.NewBlockType.BEST_CHAIN;
  boolean sideChain=blockType == BlockChain.NewBlockType.SIDE_CHAIN;
  BigInteger valueSentFromMe=tx.getValueSentFromMe(this);
  BigInteger valueSentToMe=tx.getValueSentToMe(this);
  BigInteger valueDifference=valueSentToMe.subtract(valueSentFromMe);
  if (!reorg) {
    log.info("String_Node_Str",new Object[]{sideChain ? "String_Node_Str" : "String_Node_Str",bitcoinValueToFriendlyString(valueDifference),tx.getHashAsString()});
  }
  onWalletChangedSuppressions++;
  Transaction wtx;
  if ((wtx=pending.remove(txHash)) != null) {
    tx=wtx;
    log.info("String_Node_Str");
    if (bestChain) {
      if (tx.isEveryOwnedOutputSpent(this)) {
        log.info("String_Node_Str");
        addWalletTransaction(Pool.SPENT,tx);
      }
 else {
        log.info("String_Node_Str");
        addWalletTransaction(Pool.UNSPENT,tx);
      }
    }
 else     if (sideChain) {
      log.info("String_Node_Str");
      boolean alreadyPresent=inactive.put(tx.getHash(),tx) != null;
      if (alreadyPresent)       log.info("String_Node_Str");
      pending.put(tx.getHash(),tx);
    }
  }
 else {
    if (sideChain) {
      if (unspent.containsKey(tx.getHash()) || spent.containsKey(tx.getHash())) {
      }
 else {
        log.info("String_Node_Str");
        addWalletTransaction(Pool.INACTIVE,tx);
      }
    }
 else     if (bestChain) {
      processTxFromBestChain(tx);
    }
  }
  log.info("String_Node_Str" + bitcoinValueToFriendlyString(getBalance()));
  if (block != null) {
    tx.setBlockAppearance(block,bestChain);
    if (bestChain) {
      ignoreNextNewBlock.add(txHash);
    }
  }
  boolean wasPending=wtx != null;
  if (!reorg && bestChain && !wasPending) {
    BigInteger newBalance=getBalance();
    int diff=valueDifference.compareTo(BigInteger.ZERO);
    if (diff > 0) {
      invokeOnCoinsReceived(tx,prevBalance,newBalance);
    }
 else     if (diff == 0) {
      invokeOnCoinsSent(tx,prevBalance,newBalance);
    }
 else {
      invokeOnCoinsSent(tx,prevBalance,newBalance);
    }
  }
  onWalletChangedSuppressions--;
  checkState(isConsistent());
  queueAutoSave();
}