nus-yam/ex-repair huggingface dataset:
Program: 85678
Project: 85678
Buggy source:
/** 
 * Checks the output to see if the script violates a standardness rule. Not complete.
 */
public static RuleViolation isOutputStandard(TransactionOutput output){
  if (MIN_ANALYSIS_NONDUST_OUTPUT.compareTo(output.getValue()) > 0)   return RuleViolation.DUST;
  for (  ScriptChunk chunk : output.getScriptPubKey().getChunks()) {
    if (chunk.isPushData() && !chunk.isShortestPossiblePushData())     return RuleViolation.SHORTEST_POSSIBLE_PUSHDATA;
  }
  return RuleViolation.NONE;
}

Fixed version (ground truth):
/** 
 * Checks the output to see if the script violates a standardness rule. Not complete.
 */
public static RuleViolation isOutputStandard(TransactionOutput output){
  if (output.getValue().compareTo(MIN_ANALYSIS_NONDUST_OUTPUT) < 0)   return RuleViolation.DUST;
  for (  ScriptChunk chunk : output.getScriptPubKey().getChunks()) {
    if (chunk.isPushData() && !chunk.isShortestPossiblePushData())     return RuleViolation.SHORTEST_POSSIBLE_PUSHDATA;
  }
  return RuleViolation.NONE;
}
Program: 85679
Project: 85679
Buggy source:
/** 
 * Convert entropy data to mnemonic word list.
 */
public List<String> toMnemonic(byte[] entropy) throws MnemonicException.MnemonicLengthException {
  if (entropy.length % 4 > 0)   throw new MnemonicException.MnemonicLengthException("String_Node_Str");
  byte[] hash=Sha256Hash.create(entropy).getBytes();
  boolean[] hashBits=bytesToBits(hash);
  boolean[] entropyBits=bytesToBits(entropy);
  int checksumLengthBits=entropyBits.length / 32;
  boolean[] concatBits=new boolean[entropyBits.length + checksumLengthBits];
  System.arraycopy(entropyBits,0,concatBits,0,entropyBits.length);
  System.arraycopy(hashBits,0,concatBits,entropyBits.length,checksumLengthBits);
  ArrayList<String> words=new ArrayList<String>();
  int nwords=concatBits.length / 11;
  for (int i=0; i < nwords; ++i) {
    int index=0;
    for (int j=0; j < 11; ++j) {
      index<<=1;
      if (concatBits[(i * 11) + j])       index|=0x1;
    }
    words.add(this.wordList.get(index));
  }
  return words;
}

Fixed version (ground truth):
/** 
 * Convert entropy data to mnemonic word list.
 */
public List<String> toMnemonic(byte[] entropy) throws MnemonicException.MnemonicLengthException {
  if (entropy.length % 4 > 0)   throw new MnemonicException.MnemonicLengthException("String_Node_Str");
  if (entropy.length == 0)   throw new MnemonicException.MnemonicLengthException("String_Node_Str");
  byte[] hash=Sha256Hash.create(entropy).getBytes();
  boolean[] hashBits=bytesToBits(hash);
  boolean[] entropyBits=bytesToBits(entropy);
  int checksumLengthBits=entropyBits.length / 32;
  boolean[] concatBits=new boolean[entropyBits.length + checksumLengthBits];
  System.arraycopy(entropyBits,0,concatBits,0,entropyBits.length);
  System.arraycopy(hashBits,0,concatBits,entropyBits.length,checksumLengthBits);
  ArrayList<String> words=new ArrayList<String>();
  int nwords=concatBits.length / 11;
  for (int i=0; i < nwords; ++i) {
    int index=0;
    for (int j=0; j < 11; ++j) {
      index<<=1;
      if (concatBits[(i * 11) + j])       index|=0x1;
    }
    words.add(this.wordList.get(index));
  }
  return words;
}
Program: 85680
Project: 85680
Buggy source:
/** 
 * Convert mnemonic word list to original entropy value.
 */
public byte[] toEntropy(List<String> words) throws MnemonicException.MnemonicLengthException, MnemonicException.MnemonicWordException, MnemonicException.MnemonicChecksumException {
  if (words.size() % 3 > 0)   throw new MnemonicException.MnemonicLengthException("String_Node_Str");
  int concatLenBits=words.size() * 11;
  boolean[] concatBits=new boolean[concatLenBits];
  int wordindex=0;
  for (  String word : words) {
    int ndx=Collections.binarySearch(this.wordList,word);
    if (ndx < 0)     throw new MnemonicException.MnemonicWordException(word);
    for (int ii=0; ii < 11; ++ii)     concatBits[(wordindex * 11) + ii]=(ndx & (1 << (10 - ii))) != 0;
    ++wordindex;
  }
  int checksumLengthBits=concatLenBits / 33;
  int entropyLengthBits=concatLenBits - checksumLengthBits;
  byte[] entropy=new byte[entropyLengthBits / 8];
  for (int ii=0; ii < entropy.length; ++ii)   for (int jj=0; jj < 8; ++jj)   if (concatBits[(ii * 8) + jj])   entropy[ii]|=1 << (7 - jj);
  byte[] hash=Sha256Hash.create(entropy).getBytes();
  boolean[] hashBits=bytesToBits(hash);
  for (int i=0; i < checksumLengthBits; ++i)   if (concatBits[entropyLengthBits + i] != hashBits[i])   throw new MnemonicException.MnemonicChecksumException();
  return entropy;
}

Fixed version (ground truth):
/** 
 * Convert mnemonic word list to original entropy value.
 */
public byte[] toEntropy(List<String> words) throws MnemonicException.MnemonicLengthException, MnemonicException.MnemonicWordException, MnemonicException.MnemonicChecksumException {
  if (words.size() % 3 > 0)   throw new MnemonicException.MnemonicLengthException("String_Node_Str");
  if (words.size() == 0)   throw new MnemonicException.MnemonicLengthException("String_Node_Str");
  int concatLenBits=words.size() * 11;
  boolean[] concatBits=new boolean[concatLenBits];
  int wordindex=0;
  for (  String word : words) {
    int ndx=Collections.binarySearch(this.wordList,word);
    if (ndx < 0)     throw new MnemonicException.MnemonicWordException(word);
    for (int ii=0; ii < 11; ++ii)     concatBits[(wordindex * 11) + ii]=(ndx & (1 << (10 - ii))) != 0;
    ++wordindex;
  }
  int checksumLengthBits=concatLenBits / 33;
  int entropyLengthBits=concatLenBits - checksumLengthBits;
  byte[] entropy=new byte[entropyLengthBits / 8];
  for (int ii=0; ii < entropy.length; ++ii)   for (int jj=0; jj < 8; ++jj)   if (concatBits[(ii * 8) + jj])   entropy[ii]|=1 << (7 - jj);
  byte[] hash=Sha256Hash.create(entropy).getBytes();
  boolean[] hashBits=bytesToBits(hash);
  for (int i=0; i < checksumLengthBits; ++i)   if (concatBits[entropyLengthBits + i] != hashBits[i])   throw new MnemonicException.MnemonicChecksumException();
  return entropy;
}
Program: 85682
Project: 85682
Buggy source:
private void handleKey(SelectionKey key) throws IOException {
  if (key.isValid() && key.isConnectable()) {
    StreamParser parser=(StreamParser)key.attachment();
    SocketChannel sc=(SocketChannel)key.channel();
    ConnectionHandler handler=new ConnectionHandler(parser,key,connectedHandlers);
    try {
      if (sc.finishConnect()) {
        log.info("String_Node_Str",sc.socket().getRemoteSocketAddress());
        key.interestOps(key.interestOps() | SelectionKey.OP_READ).attach(handler);
        handler.parser.connectionOpened();
      }
 else {
        log.error("String_Node_Str",sc.socket().getRemoteSocketAddress());
        handler.closeConnection();
      }
    }
 catch (    Exception e) {
      log.error("String_Node_Str",Throwables.getRootCause(e).getMessage());
      handler.closeConnection();
    }
  }
 else   ConnectionHandler.handleKey(key);
}

Fixed version (ground truth):
private void handleKey(SelectionKey key) throws IOException {
  if (key.isValid() && key.isConnectable()) {
    StreamParser parser=(StreamParser)key.attachment();
    SocketChannel sc=(SocketChannel)key.channel();
    ConnectionHandler handler=new ConnectionHandler(parser,key,connectedHandlers);
    try {
      if (sc.finishConnect()) {
        log.info("String_Node_Str",sc.socket().getRemoteSocketAddress());
        key.interestOps((key.interestOps() | SelectionKey.OP_READ) & ~SelectionKey.OP_CONNECT).attach(handler);
        handler.parser.connectionOpened();
      }
 else {
        log.error("String_Node_Str",sc.socket().getRemoteSocketAddress());
        handler.closeConnection();
      }
    }
 catch (    Exception e) {
      log.error("String_Node_Str",Throwables.getRootCause(e).getMessage());
      handler.closeConnection();
    }
  }
 else   ConnectionHandler.handleKey(key);
}
Program: 85684
Project: 85684
Buggy source:
private boolean isTxOutputBloomFilterable(TransactionOutput out){
  boolean isScriptTypeSupported=out.getScriptPubKey().isSentToRawPubKey() || out.getScriptPubKey().isPayToScriptHash();
  return (out.isMine(this) && isScriptTypeSupported) || out.isWatched(this);
}

Fixed version (ground truth):
private boolean isTxOutputBloomFilterable(TransactionOutput out){
  checkState(lock.isHeldByCurrentThread());
  boolean isScriptTypeSupported=out.getScriptPubKey().isSentToRawPubKey() || out.getScriptPubKey().isPayToScriptHash();
  return (out.isMine(this) && isScriptTypeSupported) || out.isWatched(this);
}
Program: 85685
Project: 85685
Buggy source:
/** 
 * If we are watching any scripts, the bloom filter must update on peers whenever an output is identified.  This is because we don't necessarily have the associated pubkey, so we can't watch for it on spending transactions.
 */
@Override public boolean isRequiringUpdateAllBloomFilter(){
  return !watchedScripts.isEmpty();
}

Fixed version (ground truth):
/** 
 * If we are watching any scripts, the bloom filter must update on peers whenever an output is identified.  This is because we don't necessarily have the associated pubkey, so we can't watch for it on spending transactions.
 */
@Override public boolean isRequiringUpdateAllBloomFilter(){
  lock.lock();
  try {
    return !watchedScripts.isEmpty();
  }
  finally {
    lock.unlock();
  }
}
Program: 85686
Project: 85686
Buggy source:
/** 
 * Returns the number of distinct data items (note: NOT keys) that will be inserted into a bloom filter, when it is constructed.
 */
@Override public int getBloomFilterElementCount(){
  int size=keychain.getBloomFilterElementCount();
  for (  Transaction tx : getTransactions(false)) {
    for (    TransactionOutput out : tx.getOutputs()) {
      try {
        if (isTxOutputBloomFilterable(out))         size++;
      }
 catch (      ScriptException e) {
        throw new RuntimeException(e);
      }
    }
  }
  size+=watchedScripts.size();
  return size;
}

Fixed version (ground truth):
/** 
 * Returns the number of distinct data items (note: NOT keys) that will be inserted into a bloom filter, when it is constructed.
 */
@Override public int getBloomFilterElementCount(){
  lock.lock();
  try {
    int size=keychain.getBloomFilterElementCount();
    for (    Transaction tx : getTransactions(false)) {
      for (      TransactionOutput out : tx.getOutputs()) {
        try {
          if (isTxOutputBloomFilterable(out))           size++;
        }
 catch (        ScriptException e) {
          throw new RuntimeException(e);
        }
      }
    }
    size+=watchedScripts.size();
    return size;
  }
  finally {
    lock.unlock();
  }
}
Program: 85687
Project: 85687
Buggy source:
@Override public int numKeys(){
  return basicKeyChain.numKeys();
}

Fixed version (ground truth):
@Override public int numKeys(){
  lock.lock();
  try {
    maybeLookAhead();
    return basicKeyChain.numKeys();
  }
  finally {
    lock.unlock();
  }
}
Program: 85688
Project: 85688
Buggy source:
/** 
 * Pre-generate enough keys to reach the lookahead size, but only if there are more than the lookaheadThreshold to be generated, so that the Bloom filter does not have to be regenerated that often. The returned mutable list of keys must be inserted into the basic key chain.
 */
private List<DeterministicKey> maybeLookAhead(DeterministicKey parent,int issued){
  checkState(lock.isHeldByCurrentThread());
  final int numChildren=hierarchy.getNumChildren(parent.getPath());
  final int lookaheadSize=getLookaheadSize();
  final int lookaheadThreshold=getLookaheadThreshold();
  final int needed=issued + lookaheadSize + lookaheadThreshold - numChildren;
  log.info("String_Node_Str",needed,issued,lookaheadSize,lookaheadThreshold,numChildren);
  if (needed <= lookaheadThreshold)   return new ArrayList<DeterministicKey>();
  List<DeterministicKey> result=new ArrayList<DeterministicKey>(needed);
  long now=System.currentTimeMillis();
  log.info("String_Node_Str",needed,parent.getPathAsString());
  int nextChild=numChildren;
  for (int i=0; i < needed; i++) {
    DeterministicKey key=HDKeyDerivation.deriveThisOrNextChildKey(parent,nextChild);
    key=key.getPubOnly();
    hierarchy.putKey(key);
    result.add(key);
    nextChild=key.getChildNumber().num() + 1;
  }
  log.info("String_Node_Str",System.currentTimeMillis() - now);
  return result;
}

Fixed version (ground truth):
/** 
 * Pre-generate enough keys to reach the lookahead size, but only if there are more than the lookaheadThreshold to be generated, so that the Bloom filter does not have to be regenerated that often. The returned mutable list of keys must be inserted into the basic key chain.
 */
private List<DeterministicKey> maybeLookAhead(DeterministicKey parent,int issued){
  checkState(lock.isHeldByCurrentThread());
  final int numChildren=hierarchy.getNumChildren(parent.getPath());
  final int lookaheadSize=getLookaheadSize();
  final int lookaheadThreshold=getLookaheadThreshold();
  final int needed=issued + lookaheadSize + lookaheadThreshold - numChildren;
  if (needed <= lookaheadThreshold)   return new ArrayList<DeterministicKey>();
  log.info("String_Node_Str",needed,parent.getPathAsString(),issued,lookaheadSize,lookaheadThreshold,numChildren);
  List<DeterministicKey> result=new ArrayList<DeterministicKey>(needed);
  long now=System.currentTimeMillis();
  int nextChild=numChildren;
  for (int i=0; i < needed; i++) {
    DeterministicKey key=HDKeyDerivation.deriveThisOrNextChildKey(parent,nextChild);
    key=key.getPubOnly();
    hierarchy.putKey(key);
    result.add(key);
    nextChild=key.getChildNumber().num() + 1;
  }
  log.info("String_Node_Str",System.currentTimeMillis() - now);
  return result;
}
Program: 85689
Project: 85689
Buggy source:
@Override public BloomFilter getFilter(int size,double falsePositiveRate,long tweak){
  checkArgument(size >= numBloomFilterEntries());
  return basicKeyChain.getFilter(size,falsePositiveRate,tweak);
}

Fixed version (ground truth):
@Override public BloomFilter getFilter(int size,double falsePositiveRate,long tweak){
  lock.lock();
  try {
    checkArgument(size >= numBloomFilterEntries());
    maybeLookAhead();
    return basicKeyChain.getFilter(size,falsePositiveRate,tweak);
  }
  finally {
    lock.unlock();
  }
}
Program: 85690
Project: 85690
Buggy source:
@Test public void testBloomResendOnNewKey() throws Exception {
  wallet.setKeychainLookaheadSize(20);
  peerGroup.startAsync();
  peerGroup.awaitRunning();
  InboundMessageQueuer p1=connectPeer(1);
  InboundMessageQueuer p2=connectPeer(2);
  peerGroup.waitForJobQueue();
  BloomFilter f1=p1.lastReceivedFilter;
  int threshold=wallet.getKeychainLookaheadThreshold();
  wallet.freshReceiveKey();
  peerGroup.waitForJobQueue();
  assertEquals(BloomFilter.class,outbound(p1).getClass());
  assertEquals(MemoryPoolMessage.class,outbound(p1).getClass());
  ECKey key=null;
  for (int i=0; i < threshold + 2; i++) {
    key=wallet.freshReceiveKey();
  }
  peerGroup.waitForJobQueue();
  BloomFilter f3=(BloomFilter)outbound(p1);
  assertNotNull(f3);
  assertEquals(MemoryPoolMessage.class,outbound(p1).getClass());
  assertNull(outbound(p1));
  assertNotEquals(f1,f3);
  assertTrue(f3.contains(key.getPubKey()));
  assertTrue(f3.contains(key.getPubKeyHash()));
  assertFalse(f1.contains(key.getPubKey()));
  assertFalse(f1.contains(key.getPubKeyHash()));
}

Fixed version (ground truth):
@Test public void testBloomResendOnNewKey() throws Exception {
  wallet.setKeychainLookaheadSize(5);
  wallet.setKeychainLookaheadThreshold(4);
  peerGroup.startAsync();
  peerGroup.awaitRunning();
  InboundMessageQueuer p1=connectPeer(1);
  InboundMessageQueuer p2=connectPeer(2);
  peerGroup.waitForJobQueue();
  BloomFilter f1=p1.lastReceivedFilter;
  ECKey key=null;
  for (int i=0; i < wallet.getKeychainLookaheadSize() + wallet.getKeychainLookaheadThreshold() + 1; i++) {
    key=wallet.freshReceiveKey();
  }
  peerGroup.waitForJobQueue();
  BloomFilter bf, f2=null;
  while ((bf=(BloomFilter)outbound(p1)) != null) {
    assertEquals(MemoryPoolMessage.class,outbound(p1).getClass());
    f2=bf;
  }
  assertNotNull(key);
  assertNotNull(f2);
  assertNull(outbound(p1));
  assertNotEquals(f1,f2);
  assertTrue(f2.contains(key.getPubKey()));
  assertTrue(f2.contains(key.getPubKeyHash()));
  assertFalse(f1.contains(key.getPubKey()));
  assertFalse(f1.contains(key.getPubKeyHash()));
}
Program: 85691
Project: 85691
Buggy source:
@Test public void freshAddress() throws Exception {
  group=createMarriedKeyChainGroup();
  Address a1=group.freshAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS);
  Address a2=group.freshAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS);
  assertTrue(a1.isP2SHAddress());
  assertNotEquals(a1,a2);
  assertEquals(INITIAL_KEYS + 1 + group.getLookaheadSize()+ group.getLookaheadThreshold(),group.numKeys());
  Address a3=group.currentAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS);
  assertEquals(a2,a3);
}

Fixed version (ground truth):
@Test public void freshAddress() throws Exception {
  group=createMarriedKeyChainGroup();
  Address a1=group.freshAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS);
  Address a2=group.freshAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS);
  assertTrue(a1.isP2SHAddress());
  assertNotEquals(a1,a2);
  assertEquals(((group.getLookaheadSize() + group.getLookaheadThreshold()) * 2) + 2 + 3,group.numKeys());
  Address a3=group.currentAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS);
  assertEquals(a2,a3);
}
Program: 85692
Project: 85692
Buggy source:
@Test public void currentP2SHAddress() throws Exception {
  group=createMarriedKeyChainGroup();
  assertEquals(INITIAL_KEYS,group.numKeys());
  Address a1=group.currentAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS);
  assertEquals(INITIAL_KEYS + 1 + LOOKAHEAD_SIZE+ group.getLookaheadThreshold(),group.numKeys());
  assertTrue(a1.isP2SHAddress());
  Address a2=group.currentAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS);
  assertEquals(a1,a2);
  assertEquals(INITIAL_KEYS + 1 + LOOKAHEAD_SIZE+ group.getLookaheadThreshold(),group.numKeys());
  Address a3=group.currentAddress(KeyChain.KeyPurpose.CHANGE);
  assertNotEquals(a2,a3);
}

Fixed version (ground truth):
@Test public void currentP2SHAddress() throws Exception {
  group=createMarriedKeyChainGroup();
  Address a1=group.currentAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS);
  assertTrue(a1.isP2SHAddress());
  Address a2=group.currentAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS);
  assertEquals(a1,a2);
  Address a3=group.currentAddress(KeyChain.KeyPurpose.CHANGE);
  assertNotEquals(a2,a3);
}
Program: 85693
Project: 85693
Buggy source:
@Test public void bloom() throws Exception {
  assertEquals(INITIAL_KEYS * 2,group.getBloomFilterElementCount());
  ECKey key1=group.freshKey(KeyChain.KeyPurpose.RECEIVE_FUNDS);
  ECKey key2=new ECKey();
  final int size=(INITIAL_KEYS + LOOKAHEAD_SIZE + group.getLookaheadThreshold()+ 1) * 2;
  assertEquals(size,group.getBloomFilterElementCount());
  BloomFilter filter=group.getBloomFilter(size,0.001,(long)(Math.random() * Long.MAX_VALUE));
  assertTrue(filter.contains(key1.getPubKeyHash()));
  assertTrue(filter.contains(key1.getPubKey()));
  assertFalse(filter.contains(key2.getPubKey()));
  for (int i=0; i < LOOKAHEAD_SIZE + group.getLookaheadThreshold(); i++) {
    ECKey k=group.freshKey(KeyChain.KeyPurpose.RECEIVE_FUNDS);
    assertTrue(filter.contains(k.getPubKeyHash()));
  }
  assertFalse(filter.contains(group.freshKey(KeyChain.KeyPurpose.RECEIVE_FUNDS).getPubKey()));
  group.importKeys(key2);
  filter=group.getBloomFilter(group.getBloomFilterElementCount(),0.001,(long)(Math.random() * Long.MAX_VALUE));
  assertTrue(filter.contains(key1.getPubKeyHash()));
  assertTrue(filter.contains(key1.getPubKey()));
  assertTrue(filter.contains(key2.getPubKey()));
}

Fixed version (ground truth):
@Test public void bloom() throws Exception {
  ECKey key1=group.freshKey(KeyChain.KeyPurpose.RECEIVE_FUNDS);
  ECKey key2=new ECKey();
  BloomFilter filter=group.getBloomFilter(group.getBloomFilterElementCount(),0.001,(long)(Math.random() * Long.MAX_VALUE));
  assertTrue(filter.contains(key1.getPubKeyHash()));
  assertTrue(filter.contains(key1.getPubKey()));
  assertFalse(filter.contains(key2.getPubKey()));
  for (int i=0; i < LOOKAHEAD_SIZE + group.getLookaheadThreshold(); i++) {
    ECKey k=group.freshKey(KeyChain.KeyPurpose.RECEIVE_FUNDS);
    assertTrue(filter.contains(k.getPubKeyHash()));
  }
  assertFalse(filter.contains(group.freshKey(KeyChain.KeyPurpose.RECEIVE_FUNDS).getPubKey()));
  group.importKeys(key2);
  filter=group.getBloomFilter(group.getBloomFilterElementCount(),0.001,(long)(Math.random() * Long.MAX_VALUE));
  assertTrue(filter.contains(key1.getPubKeyHash()));
  assertTrue(filter.contains(key1.getPubKey()));
  assertTrue(filter.contains(key2.getPubKey()));
}
Program: 85694
Project: 85694
Buggy source:
@Test public void imports() throws Exception {
  ECKey key1=new ECKey();
  assertFalse(group.removeImportedKey(key1));
  assertEquals(1,group.importKeys(ImmutableList.of(key1)));
  assertEquals(INITIAL_KEYS + 1,group.numKeys());
  group.removeImportedKey(key1);
  assertEquals(INITIAL_KEYS,group.numKeys());
}

Fixed version (ground truth):
@Test public void imports() throws Exception {
  ECKey key1=new ECKey();
  int numKeys=group.numKeys();
  assertFalse(group.removeImportedKey(key1));
  assertEquals(1,group.importKeys(ImmutableList.of(key1)));
  assertEquals(numKeys + 1,group.numKeys());
  group.removeImportedKey(key1);
  assertEquals(numKeys,group.numKeys());
}
Program: 85695
Project: 85695
Buggy source:
@Test public void freshCurrentKeys() throws Exception {
  assertEquals(INITIAL_KEYS,group.numKeys());
  assertEquals(2 * INITIAL_KEYS,group.getBloomFilterElementCount());
  ECKey r1=group.currentKey(KeyChain.KeyPurpose.RECEIVE_FUNDS);
  final int keys=INITIAL_KEYS + LOOKAHEAD_SIZE + group.getLookaheadThreshold()+ 1;
  assertEquals(keys,group.numKeys());
  assertEquals(2 * keys,group.getBloomFilterElementCount());
  ECKey i1=new ECKey();
  group.importKeys(i1);
  assertEquals(keys + 1,group.numKeys());
  assertEquals(2 * (keys + 1),group.getBloomFilterElementCount());
  ECKey r2=group.currentKey(KeyChain.KeyPurpose.RECEIVE_FUNDS);
  assertEquals(r1,r2);
  ECKey c1=group.currentKey(KeyChain.KeyPurpose.CHANGE);
  assertNotEquals(r1,c1);
  ECKey r3=group.freshKey(KeyChain.KeyPurpose.RECEIVE_FUNDS);
  assertNotEquals(r1,r3);
  ECKey c2=group.freshKey(KeyChain.KeyPurpose.CHANGE);
  assertNotEquals(r3,c2);
  ECKey r4=group.currentKey(KeyChain.KeyPurpose.RECEIVE_FUNDS);
  assertEquals(r2,r4);
  ECKey c3=group.currentKey(KeyChain.KeyPurpose.CHANGE);
  assertEquals(c1,c3);
  group.markPubKeyAsUsed(r4.getPubKey());
  ECKey r5=group.currentKey(KeyChain.KeyPurpose.RECEIVE_FUNDS);
  assertNotEquals(r4,r5);
}

Fixed version (ground truth):
@Test public void freshCurrentKeys() throws Exception {
  int numKeys=((group.getLookaheadSize() + group.getLookaheadThreshold()) * 2) + 1 + 3;
  assertEquals(numKeys,group.numKeys());
  assertEquals(2 * numKeys,group.getBloomFilterElementCount());
  ECKey r1=group.currentKey(KeyChain.KeyPurpose.RECEIVE_FUNDS);
  assertEquals(numKeys,group.numKeys());
  assertEquals(2 * numKeys,group.getBloomFilterElementCount());
  ECKey i1=new ECKey();
  group.importKeys(i1);
  numKeys++;
  assertEquals(numKeys,group.numKeys());
  assertEquals(2 * numKeys,group.getBloomFilterElementCount());
  ECKey r2=group.currentKey(KeyChain.KeyPurpose.RECEIVE_FUNDS);
  assertEquals(r1,r2);
  ECKey c1=group.currentKey(KeyChain.KeyPurpose.CHANGE);
  assertNotEquals(r1,c1);
  ECKey r3=group.freshKey(KeyChain.KeyPurpose.RECEIVE_FUNDS);
  assertNotEquals(r1,r3);
  ECKey c2=group.freshKey(KeyChain.KeyPurpose.CHANGE);
  assertNotEquals(r3,c2);
  ECKey r4=group.currentKey(KeyChain.KeyPurpose.RECEIVE_FUNDS);
  assertEquals(r2,r4);
  ECKey c3=group.currentKey(KeyChain.KeyPurpose.CHANGE);
  assertEquals(c1,c3);
  group.markPubKeyAsUsed(r4.getPubKey());
  ECKey r5=group.currentKey(KeyChain.KeyPurpose.RECEIVE_FUNDS);
  assertNotEquals(r4,r5);
}
Program: 85696
Project: 85696
Buggy source:
@Test public void encryptionWhilstEmpty() throws Exception {
  group=new KeyChainGroup(params);
  group.setLookaheadSize(5);
  KeyCrypterScrypt scrypt=new KeyCrypterScrypt(2);
  final KeyParameter aesKey=scrypt.deriveKey("String_Node_Str");
  group.encrypt(scrypt,aesKey);
  assertEquals(4,group.numKeys());
  assertTrue(group.freshKey(KeyChain.KeyPurpose.RECEIVE_FUNDS).isEncrypted());
  final ECKey key=group.currentKey(KeyChain.KeyPurpose.RECEIVE_FUNDS);
  group.decrypt(aesKey);
  assertFalse(checkNotNull(group.findKeyFromPubKey(key.getPubKey())).isEncrypted());
}

Fixed version (ground truth):
@Test public void encryptionWhilstEmpty() throws Exception {
  group=new KeyChainGroup(params);
  group.setLookaheadSize(5);
  KeyCrypterScrypt scrypt=new KeyCrypterScrypt(2);
  final KeyParameter aesKey=scrypt.deriveKey("String_Node_Str");
  group.encrypt(scrypt,aesKey);
  assertTrue(group.freshKey(KeyChain.KeyPurpose.RECEIVE_FUNDS).isEncrypted());
  final ECKey key=group.currentKey(KeyChain.KeyPurpose.RECEIVE_FUNDS);
  group.decrypt(aesKey);
  assertFalse(checkNotNull(group.findKeyFromPubKey(key.getPubKey())).isEncrypted());
}
Program: 85697
Project: 85697
Buggy source:
public int getOptimalEncodingMessageSize(){
  if (optimalEncodingMessageSize != 0)   return optimalEncodingMessageSize;
  maybeParseTransactions();
  if (optimalEncodingMessageSize != 0)   return optimalEncodingMessageSize;
  optimalEncodingMessageSize=getMessageSize();
  return optimalEncodingMessageSize;
}

Fixed version (ground truth):
public int getOptimalEncodingMessageSize(){
  if (optimalEncodingMessageSize != 0)   return optimalEncodingMessageSize;
  maybeParseTransactions();
  if (optimalEncodingMessageSize != 0)   return optimalEncodingMessageSize;
  optimalEncodingMessageSize=bitcoinSerialize().length;
  return optimalEncodingMessageSize;
}
Program: 85698
Project: 85698
Buggy source:
private KeyChainGroup(NetworkParameters params,@Nullable BasicKeyChain basicKeyChain,List<DeterministicKeyChain> chains,@Nullable EnumMap<KeyChain.KeyPurpose,DeterministicKey> currentKeys,Multimap<DeterministicKey,DeterministicKeyChain> followingKeychains,@Nullable KeyCrypter crypter){
  this.params=params;
  this.basic=basicKeyChain == null ? new BasicKeyChain() : basicKeyChain;
  this.chains=new ArrayList<DeterministicKeyChain>(checkNotNull(chains));
  this.keyCrypter=crypter;
  this.currentKeys=currentKeys == null ? new EnumMap<KeyChain.KeyPurpose,DeterministicKey>(KeyChain.KeyPurpose.class) : currentKeys;
  this.currentAddresses=new EnumMap<KeyChain.KeyPurpose,Address>(KeyChain.KeyPurpose.class);
  this.followingKeychains=HashMultimap.create();
  if (followingKeychains != null) {
    this.followingKeychains.putAll(followingKeychains);
  }
  marriedKeysScripts=new LinkedHashMap<ByteString,Script>();
  maybeLookaheadScripts();
  if (!this.currentKeys.isEmpty()) {
    DeterministicKey followedWatchKey=getActiveKeyChain().getWatchingKey();
    for (    Map.Entry<KeyChain.KeyPurpose,DeterministicKey> entry : this.currentKeys.entrySet()) {
      Address address=makeP2SHOutputScript(entry.getValue(),followedWatchKey).getToAddress(params);
      currentAddresses.put(entry.getKey(),address);
    }
  }
}

Fixed version (ground truth):
private KeyChainGroup(NetworkParameters params,@Nullable BasicKeyChain basicKeyChain,List<DeterministicKeyChain> chains,@Nullable EnumMap<KeyChain.KeyPurpose,DeterministicKey> currentKeys,Multimap<DeterministicKey,DeterministicKeyChain> followingKeychains,@Nullable KeyCrypter crypter){
  this.params=params;
  this.basic=basicKeyChain == null ? new BasicKeyChain() : basicKeyChain;
  this.chains=new ArrayList<DeterministicKeyChain>(checkNotNull(chains));
  this.keyCrypter=crypter;
  this.currentKeys=currentKeys == null ? new EnumMap<KeyChain.KeyPurpose,DeterministicKey>(KeyChain.KeyPurpose.class) : currentKeys;
  this.currentAddresses=new EnumMap<KeyChain.KeyPurpose,Address>(KeyChain.KeyPurpose.class);
  this.followingKeychains=HashMultimap.create();
  if (followingKeychains != null) {
    this.followingKeychains.putAll(followingKeychains);
  }
  marriedKeysScripts=new LinkedHashMap<ByteString,Script>();
  maybeLookaheadScripts();
  if (!this.followingKeychains.isEmpty()) {
    DeterministicKey followedWatchKey=getActiveKeyChain().getWatchingKey();
    for (    Map.Entry<KeyChain.KeyPurpose,DeterministicKey> entry : this.currentKeys.entrySet()) {
      Address address=makeP2SHOutputScript(entry.getValue(),followedWatchKey).getToAddress(params);
      currentAddresses.put(entry.getKey(),address);
    }
  }
}
Program: 85699
Project: 85699
Buggy source:
public void setPasswordClicked(ActionEvent event){
  if (!pass1.getText().equals(pass2.getText())) {
    informationalAlert("String_Node_Str","String_Node_Str");
    return;
  }
  String password=pass1.getText();
  if (password.length() < 4) {
    informationalAlert("String_Node_Str","String_Node_Str");
    return;
  }
  fadeIn(progressMeter);
  fadeIn(padlockImage);
  fadeOut(widgetGrid);
  fadeOut(explanationLabel);
  fadeOut(closeButton);
  IdealPasswordParameters params=new IdealPasswordParameters(password);
  KeyCrypterScrypt scrypt=new KeyCrypterScrypt(params.realIterations);
  WalletPasswordController.setTargetTime(params.realTargetTime);
  KeyDerivationTasks tasks=new KeyDerivationTasks(scrypt,password,params.realTargetTime){
    @Override protected void onFinish(    KeyParameter aesKey){
      Main.bitcoin.wallet().encrypt(scrypt,aesKey);
      fadeIn(explanationLabel);
      fadeIn(widgetGrid);
      fadeIn(closeButton);
      fadeOut(progressMeter);
      fadeOut(padlockImage);
    }
  }
;
  progressMeter.progressProperty().bind(tasks.progress);
  tasks.start();
}

Fixed version (ground truth):
public void setPasswordClicked(ActionEvent event){
  if (!pass1.getText().equals(pass2.getText())) {
    informationalAlert("String_Node_Str","String_Node_Str");
    return;
  }
  String password=pass1.getText();
  if (password.length() < 4) {
    informationalAlert("String_Node_Str","String_Node_Str");
    return;
  }
  fadeIn(progressMeter);
  fadeIn(padlockImage);
  fadeOut(widgetGrid);
  fadeOut(explanationLabel);
  fadeOut(closeButton);
  IdealPasswordParameters params=new IdealPasswordParameters(password);
  KeyCrypterScrypt scrypt=new KeyCrypterScrypt(params.realIterations);
  WalletPasswordController.setTargetTime(params.realTargetTime);
  KeyDerivationTasks tasks=new KeyDerivationTasks(scrypt,password,params.realTargetTime){
    @Override protected void onFinish(    KeyParameter aesKey){
      Main.bitcoin.wallet().encrypt(scrypt,aesKey);
      informationalAlert("String_Node_Str","String_Node_Str");
      overlayUI.done();
    }
  }
;
  progressMeter.progressProperty().bind(tasks.progress);
  tasks.start();
}
Program: 85700
Project: 85700
Buggy source:
@Override protected void onFinish(KeyParameter aesKey){
  Main.bitcoin.wallet().encrypt(scrypt,aesKey);
  fadeIn(explanationLabel);
  fadeIn(widgetGrid);
  fadeIn(closeButton);
  fadeOut(progressMeter);
  fadeOut(padlockImage);
}

Fixed version (ground truth):
@Override protected void onFinish(KeyParameter aesKey){
  Main.bitcoin.wallet().encrypt(scrypt,aesKey);
  informationalAlert("String_Node_Str","String_Node_Str");
  overlayUI.done();
}
Program: 85701
Project: 85701
Buggy source:
public void passwordButtonClicked(ActionEvent event){
  if (aesKey == null) {
    Main.instance.overlayUI("String_Node_Str");
  }
 else {
    Main.bitcoin.wallet().decrypt(aesKey);
    informationalAlert("String_Node_Str","String_Node_Str");
    passwordButton.setText("String_Node_Str");
  }
}

Fixed version (ground truth):
public void passwordButtonClicked(ActionEvent event){
  if (aesKey == null) {
    Main.instance.overlayUI("String_Node_Str");
  }
 else {
    Main.bitcoin.wallet().decrypt(aesKey);
    informationalAlert("String_Node_Str","String_Node_Str");
    passwordButton.setText("String_Node_Str");
    aesKey=null;
  }
}
Program: 85702
Project: 85702
Buggy source:
public static void initCheckpoints(Map<Integer,Sha256Hash> checkpoints){
  checkpoints.put(1500,new Sha256Hash("String_Node_Str"));
  checkpoints.put(4991,new Sha256Hash("String_Node_Str"));
  checkpoints.put(9918,new Sha256Hash("String_Node_Str"));
  checkpoints.put(16912,new Sha256Hash("String_Node_Str"));
  checkpoints.put(23912,new Sha256Hash("String_Node_Str"));
  checkpoints.put(35457,new Sha256Hash("String_Node_Str"));
  checkpoints.put(45479,new Sha256Hash("String_Node_Str"));
  checkpoints.put(55895,new Sha256Hash("String_Node_Str"));
  checkpoints.put(68899,new Sha256Hash("String_Node_Str"));
  checkpoints.put(74619,new Sha256Hash("String_Node_Str"));
  checkpoints.put(75095,new Sha256Hash("String_Node_Str"));
  checkpoints.put(88805,new Sha256Hash("String_Node_Str"));
}

Fixed version (ground truth):
public static void initCheckpoints(Map<Integer,Sha256Hash> checkpoints){
  checkpoints.put(1500,new Sha256Hash("String_Node_Str"));
  checkpoints.put(4991,new Sha256Hash("String_Node_Str"));
  checkpoints.put(9918,new Sha256Hash("String_Node_Str"));
  checkpoints.put(16912,new Sha256Hash("String_Node_Str"));
  checkpoints.put(23912,new Sha256Hash("String_Node_Str"));
  checkpoints.put(35457,new Sha256Hash("String_Node_Str"));
  checkpoints.put(45479,new Sha256Hash("String_Node_Str"));
  checkpoints.put(55895,new Sha256Hash("String_Node_Str"));
  checkpoints.put(68899,new Sha256Hash("String_Node_Str"));
  checkpoints.put(74619,new Sha256Hash("String_Node_Str"));
  checkpoints.put(75095,new Sha256Hash("String_Node_Str"));
  checkpoints.put(88805,new Sha256Hash("String_Node_Str"));
  checkpoints.put(90544,new Sha256Hash("String_Node_Str"));
}
Program: 85703
Project: 85703
Buggy source:
@Override void parse() throws ProtocolException {
  long numHeaders=readVarInt();
  if (numHeaders > MAX_HEADERS)   throw new ProtocolException("String_Node_Str" + numHeaders + "String_Node_Str"+ MAX_HEADERS);
  blockHeaders=new ArrayList<Block>();
  for (int i=0; i < numHeaders; ++i) {
    byte[] blockHeader=readBytes(81);
    if (blockHeader[80] != 0)     throw new ProtocolException("String_Node_Str");
    Block newBlockHeader=new Block(this.params,blockHeader,true,true,81);
    if (newBlockHeader.shouldHaveMasterNodeVotes()) {
      byte[] mnv=readBytes(1);
      if (mnv[0] != 0)       throw new ProtocolException("String_Node_Str");
    }
    blockHeaders.add(newBlockHeader);
  }
  if (log.isDebugEnabled()) {
    for (int i=0; i < numHeaders; ++i) {
      log.debug(this.blockHeaders.get(i).toString());
    }
  }
}

Fixed version (ground truth):
@Override void parse() throws ProtocolException {
  long numHeaders=readVarInt();
  if (numHeaders > MAX_HEADERS)   throw new ProtocolException("String_Node_Str" + numHeaders + "String_Node_Str"+ MAX_HEADERS);
  blockHeaders=new ArrayList<Block>();
  for (int i=0; i < numHeaders; ++i) {
    byte[] blockHeader=readBytes(81);
    if (blockHeader[80] != 0)     throw new ProtocolException("String_Node_Str");
    Block newBlockHeader=new Block(this.params,blockHeader,true,true,81);
    blockHeaders.add(newBlockHeader);
  }
  if (log.isDebugEnabled()) {
    for (int i=0; i < numHeaders; ++i) {
      log.debug(this.blockHeaders.get(i).toString());
    }
  }
}
Program: 85704
Project: 85704
Buggy source:
public byte[] encode(){
  if (isLessThanUnsigned(value,253)) {
    return new byte[]{(byte)value};
  }
 else   if (isLessThanUnsigned(value,65536)) {
    return new byte[]{(byte)253,(byte)(value),(byte)(value >> 8)};
  }
 else   if (isLessThanUnsigned(value,UnsignedInteger.MAX_VALUE.longValue())) {
    byte[] bytes=new byte[5];
    bytes[0]=(byte)254;
    Utils.uint32ToByteArrayLE(value,bytes,1);
    return bytes;
  }
 else {
    byte[] bytes=new byte[9];
    bytes[0]=(byte)255;
    Utils.uint32ToByteArrayLE(value,bytes,1);
    Utils.uint32ToByteArrayLE(value >>> 32,bytes,5);
    return bytes;
  }
}

Fixed version (ground truth):
public byte[] encode(){
  if (isLessThanUnsigned(value,253)) {
    return new byte[]{(byte)value};
  }
 else   if (isLessThanOrEqualToUnsigned(value,0xFFFFL)) {
    return new byte[]{(byte)253,(byte)(value),(byte)(value >> 8)};
  }
 else   if (isLessThanOrEqualToUnsigned(value,0xFFFFFFFFL)) {
    byte[] bytes=new byte[5];
    bytes[0]=(byte)254;
    Utils.uint32ToByteArrayLE(value,bytes,1);
    return bytes;
  }
 else {
    byte[] bytes=new byte[9];
    bytes[0]=(byte)255;
    Utils.uint32ToByteArrayLE(value,bytes,1);
    Utils.uint32ToByteArrayLE(value >>> 32,bytes,5);
    return bytes;
  }
}
Program: 85705
Project: 85705
Buggy source:
/** 
 * Gets the minimum encoded size of the given value.
 */
public static int sizeOf(long value){
  if (isLessThanUnsigned(value,253))   return 1;
 else   if (isLessThanUnsigned(value,65536))   return 3;
 else   if (isLessThanUnsigned(value,UnsignedInteger.MAX_VALUE.longValue()))   return 5;
 else   return 9;
}

Fixed version (ground truth):
/** 
 * Gets the minimum encoded size of the given value.
 */
public static int sizeOf(long value){
  if (isLessThanUnsigned(value,253))   return 1;
 else   if (isLessThanOrEqualToUnsigned(value,0xFFFFL))   return 3;
 else   if (isLessThanOrEqualToUnsigned(value,0xFFFFFFFFL))   return 5;
 else   return 9;
}
Program: 85709
Project: 85709
Buggy source:
/** 
 * See   {@link com.google.bitcoin.wallet.DeterministicKeyChain#setLookaheadThreshold(int)} for more info on this. 
 */
public int getKeychainLookaheadThreshold(){
  int threshold=0;
  lock.lock();
  try {
    threshold=keychain.getLookaheadThreshold();
  }
  finally {
    lock.unlock();
  }
  return threshold;
}

Fixed version (ground truth):
/** 
 * See   {@link com.google.bitcoin.wallet.DeterministicKeyChain#setLookaheadThreshold(int)} for more info on this. 
 */
public int getKeychainLookaheadThreshold(){
  lock.lock();
  try {
    return keychain.getLookaheadThreshold();
  }
  finally {
    lock.unlock();
  }
}
Program: 85710
Project: 85710
Buggy source:
/** 
 * Mark the DeterministicKey as used. Also correct the issued{Internal|External}Keys counter, because all lower children seem to be requested already. If the counter was updated, we also might want to update the lookahead keys.
 */
public DeterministicKey markKeyAsUsed(DeterministicKey k){
  int numchilds=k.getChildNumber().i() + 1;
  if (k.getParent() == internalKey) {
    if (issuedInternalKeys < numchilds) {
      issuedInternalKeys=numchilds;
      maybeLookAhead();
    }
  }
 else   if (k.getParent() == externalKey) {
    if (issuedExternalKeys < numchilds) {
      issuedExternalKeys=numchilds;
      maybeLookAhead();
    }
  }
  return k;
}

Fixed version (ground truth):
/** 
 * Mark the DeterministicKey as used. Also correct the issued{Internal|External}Keys counter, because all lower children seem to be requested already. If the counter was updated, we also might trigger lookahead.
 */
public DeterministicKey markKeyAsUsed(DeterministicKey k){
  int numChildren=k.getChildNumber().i() + 1;
  if (k.getParent() == internalKey) {
    if (issuedInternalKeys < numChildren) {
      issuedInternalKeys=numChildren;
      maybeLookAhead();
    }
  }
 else   if (k.getParent() == externalKey) {
    if (issuedExternalKeys < numChildren) {
      issuedExternalKeys=numChildren;
      maybeLookAhead();
    }
  }
  return k;
}
Program: 85711
Project: 85711
Buggy source:
/** 
 * Pre-generate enough keys to reach the lookahead size, but only if there are more than the lookaheadThreshold to be generated, so that the Bloom filter does not have to be regenerated that often. Returned keys must be inserted into the basic key chain.
 */
private List<DeterministicKey> maybeLookAhead(DeterministicKey parent,int issued){
  checkState(lock.isHeldByCurrentThread());
  final int numChildren=hierarchy.getNumChildren(parent.getPath());
  final int needed=issued + getLookaheadSize() - numChildren;
  log.info("String_Node_Str",parent.getPathAsString(),getLookaheadSize(),numChildren,issued,needed,getLookaheadThreshold());
  if (needed <= getLookaheadThreshold())   return Collections.emptyList();
  List<DeterministicKey> result=new ArrayList<DeterministicKey>(needed);
  long now=System.currentTimeMillis();
  log.info("String_Node_Str",needed,parent.getPathAsString());
  for (int i=0; i < needed; i++) {
    DeterministicKey key=HDKeyDerivation.deriveChildKey(parent,numChildren + i);
    key=key.getPubOnly();
    hierarchy.putKey(key);
    result.add(key);
  }
  log.info("String_Node_Str",System.currentTimeMillis() - now);
  return result;
}

Fixed version (ground truth):
/** 
 * Pre-generate enough keys to reach the lookahead size, but only if there are more than the lookaheadThreshold to be generated, so that the Bloom filter does not have to be regenerated that often. The return mutable list of keys must be inserted into the basic key chain.
 */
private List<DeterministicKey> maybeLookAhead(DeterministicKey parent,int issued){
  checkState(lock.isHeldByCurrentThread());
  final int numChildren=hierarchy.getNumChildren(parent.getPath());
  final int needed=issued + getLookaheadSize() - numChildren;
  log.info("String_Node_Str",parent.getPathAsString(),getLookaheadSize(),numChildren,issued,needed,getLookaheadThreshold());
  if (needed <= getLookaheadThreshold())   return new ArrayList<DeterministicKey>();
  List<DeterministicKey> result=new ArrayList<DeterministicKey>(needed);
  long now=System.currentTimeMillis();
  log.info("String_Node_Str",needed,parent.getPathAsString());
  for (int i=0; i < needed; i++) {
    DeterministicKey key=HDKeyDerivation.deriveChildKey(parent,numChildren + i);
    key=key.getPubOnly();
    hierarchy.putKey(key);
    result.add(key);
  }
  log.info("String_Node_Str",System.currentTimeMillis() - now);
  return result;
}
Program: 85712
Project: 85712
Buggy source:
/** 
 * Sets the threshold for the key pre-generation. If a key is used in a transaction, the keychain would pre-generate a new key, for every issued key, even if it is only one. If the blockchain is replayed, every key would trigger a regeneration of the bloom filter sent to the peers as a consequence. To prevent this, new keys are only generated, if more than the threshold value are needed.
 */
public void setLookaheadThreshold(int num){
  lock.lock();
  if (num >= lookaheadSize)   throw new IllegalArgumentException("String_Node_Str");
  try {
    this.lookaheadThreshold=num;
  }
  finally {
    lock.unlock();
  }
}

Fixed version (ground truth):
/** 
 * Sets the threshold for the key pre-generation. If a key is used in a transaction, the keychain would pre-generate a new key, for every issued key, even if it is only one. If the blockchain is replayed, every key would trigger a regeneration of the bloom filter sent to the peers as a consequence. To prevent this, new keys are only generated, if more than the threshold value are needed.
 */
public void setLookaheadThreshold(int num){
  lock.lock();
  try {
    if (num >= lookaheadSize)     throw new IllegalArgumentException("String_Node_Str");
    this.lookaheadThreshold=num;
  }
  finally {
    lock.unlock();
  }
}
Program: 85713
Project: 85713
Buggy source:
private void informListenersForNewBlock(final Block block,final NewBlockType newBlockType,@Nullable final List<Sha256Hash> filteredTxHashList,@Nullable final Map<Sha256Hash,Transaction> filteredTxn,final StoredBlock newStoredBlock) throws VerificationException {
  boolean first=true;
  Set<Transaction> falsePositives=Sets.newHashSet();
  if (filteredTxn != null)   falsePositives.addAll(filteredTxn.values());
  for (  final ListenerRegistration<BlockChainListener> registration : listeners) {
    if (registration.executor == Threading.SAME_THREAD) {
      informListenerForNewTransactions(block,newBlockType,filteredTxHashList,filteredTxn,newStoredBlock,first,registration.listener,falsePositives);
      if (newBlockType == NewBlockType.BEST_CHAIN)       registration.listener.notifyNewBestBlock(newStoredBlock);
    }
 else {
      final boolean notFirst=!first;
      registration.executor.execute(new Runnable(){
        @Override public void run(){
          try {
            Set<Transaction> ignoredFalsePositives=Sets.newHashSet();
            informListenerForNewTransactions(block,newBlockType,filteredTxHashList,filteredTxn,newStoredBlock,notFirst,registration.listener,ignoredFalsePositives);
            if (newBlockType == NewBlockType.BEST_CHAIN)             registration.listener.notifyNewBestBlock(newStoredBlock);
          }
 catch (          VerificationException e) {
            log.error("String_Node_Str",e);
          }
        }
      }
);
    }
    first=false;
  }
  trackFalsePositives(falsePositives.size());
}

Fixed version (ground truth):
private void informListenersForNewBlock(final Block block,final NewBlockType newBlockType,@Nullable final List<Sha256Hash> filteredTxHashList,@Nullable final Map<Sha256Hash,Transaction> filteredTxn,final StoredBlock newStoredBlock) throws VerificationException {
  boolean first=true;
  Set<Sha256Hash> falsePositives=Sets.newHashSet();
  if (filteredTxHashList != null)   falsePositives.addAll(filteredTxHashList);
  for (  final ListenerRegistration<BlockChainListener> registration : listeners) {
    if (registration.executor == Threading.SAME_THREAD) {
      informListenerForNewTransactions(block,newBlockType,filteredTxHashList,filteredTxn,newStoredBlock,first,registration.listener,falsePositives);
      if (newBlockType == NewBlockType.BEST_CHAIN)       registration.listener.notifyNewBestBlock(newStoredBlock);
    }
 else {
      final boolean notFirst=!first;
      registration.executor.execute(new Runnable(){
        @Override public void run(){
          try {
            Set<Sha256Hash> ignoredFalsePositives=Sets.newHashSet();
            informListenerForNewTransactions(block,newBlockType,filteredTxHashList,filteredTxn,newStoredBlock,notFirst,registration.listener,ignoredFalsePositives);
            if (newBlockType == NewBlockType.BEST_CHAIN)             registration.listener.notifyNewBestBlock(newStoredBlock);
          }
 catch (          VerificationException e) {
            log.error("String_Node_Str",e);
          }
        }
      }
);
    }
    first=false;
  }
  trackFalsePositives(falsePositives.size());
}
Program: 85714
Project: 85714
Buggy source:
private static void sendTransactionsToListener(StoredBlock block,NewBlockType blockType,BlockChainListener listener,int relativityOffset,List<Transaction> transactions,boolean clone,Set<Transaction> falsePositives) throws VerificationException {
  for (  Transaction tx : transactions) {
    try {
      if (listener.isTransactionRelevant(tx)) {
        falsePositives.remove(tx);
        if (clone)         tx=new Transaction(tx.params,tx.bitcoinSerialize());
        listener.receiveFromBlock(tx,block,blockType,relativityOffset++);
      }
    }
 catch (    ScriptException e) {
      log.warn("String_Node_Str" + e.toString());
    }
catch (    ProtocolException e) {
      throw new RuntimeException(e);
    }
  }
}

Fixed version (ground truth):
private static void sendTransactionsToListener(StoredBlock block,NewBlockType blockType,BlockChainListener listener,int relativityOffset,List<Transaction> transactions,boolean clone,Set<Sha256Hash> falsePositives) throws VerificationException {
  for (  Transaction tx : transactions) {
    try {
      if (listener.isTransactionRelevant(tx)) {
        falsePositives.remove(tx.getHash());
        if (clone)         tx=new Transaction(tx.params,tx.bitcoinSerialize());
        listener.receiveFromBlock(tx,block,blockType,relativityOffset++);
      }
    }
 catch (    ScriptException e) {
      log.warn("String_Node_Str" + e.toString());
    }
catch (    ProtocolException e) {
      throw new RuntimeException(e);
    }
  }
}