Program: 85630
Project: 85630
Buggy source:
/** 
 * <p>Given a transaction, sends it un-announced to one peer and then waits for it to be received back from other peers. Once all connected peers have announced the transaction, the future available via the  {@link org.bitcoinj.core.TransactionBroadcast#future()} method will be completed. If anything goeswrong the exception will be thrown when get() is called, or you can receive it via a callback on the {@link ListenableFuture}. This method returns immediately, so if you want it to block just call get() on the result.</p> <p>Note that if the PeerGroup is limited to only one connection (discovery is not activated) then the future will complete as soon as the transaction was successfully written to that peer.</p> <p>The transaction won't be sent until there are at least minConnections active connections available. A good choice for proportion would be between 0.5 and 0.8 but if you want faster transmission during initial bringup of the peer group you can lower it.</p> <p>The returned   {@link org.bitcoinj.core.TransactionBroadcast} object can be used to get progress feedback,which is calculated by watching the transaction propagate across the network and be announced by peers.</p>
 */
public TransactionBroadcast broadcastTransaction(final Transaction tx,final int minConnections){
  final TransactionBroadcast broadcast=new TransactionBroadcast(this,tx);
  broadcast.setMinConnections(minConnections);
  Futures.addCallback(broadcast.future(),new FutureCallback<Transaction>(){
    @Override public void onSuccess(    Transaction transaction){
      runningBroadcasts.remove(broadcast);
      for (      Wallet wallet : wallets) {
        try {
          wallet.receivePending(transaction,null);
        }
 catch (        VerificationException e) {
          throw new RuntimeException(e);
        }
      }
    }
    @Override public void onFailure(    Throwable throwable){
      runningBroadcasts.remove(broadcast);
    }
  }
);
  runningBroadcasts.add(broadcast);
  broadcast.broadcast();
  return broadcast;
}

Fixed version (ground truth):
/** 
 * <p>Given a transaction, sends it un-announced to one peer and then waits for it to be received back from other peers. Once all connected peers have announced the transaction, the future available via the  {@link org.bitcoinj.core.TransactionBroadcast#future()} method will be completed. If anything goeswrong the exception will be thrown when get() is called, or you can receive it via a callback on the {@link ListenableFuture}. This method returns immediately, so if you want it to block just call get() on the result.</p> <p>Note that if the PeerGroup is limited to only one connection (discovery is not activated) then the future will complete as soon as the transaction was successfully written to that peer.</p> <p>The transaction won't be sent until there are at least minConnections active connections available. A good choice for proportion would be between 0.5 and 0.8 but if you want faster transmission during initial bringup of the peer group you can lower it.</p> <p>The returned   {@link org.bitcoinj.core.TransactionBroadcast} object can be used to get progress feedback,which is calculated by watching the transaction propagate across the network and be announced by peers.</p>
 */
public TransactionBroadcast broadcastTransaction(final Transaction tx,final int minConnections){
  if (tx.getConfidence().getSource().equals(TransactionConfidence.Source.UNKNOWN)) {
    tx.getConfidence().setSource(TransactionConfidence.Source.SELF);
  }
  final TransactionBroadcast broadcast=new TransactionBroadcast(this,tx);
  broadcast.setMinConnections(minConnections);
  Futures.addCallback(broadcast.future(),new FutureCallback<Transaction>(){
    @Override public void onSuccess(    Transaction transaction){
      runningBroadcasts.remove(broadcast);
      for (      Wallet wallet : wallets) {
        try {
          wallet.receivePending(transaction,null);
        }
 catch (        VerificationException e) {
          throw new RuntimeException(e);
        }
      }
    }
    @Override public void onFailure(    Throwable throwable){
      runningBroadcasts.remove(broadcast);
    }
  }
);
  runningBroadcasts.add(broadcast);
  broadcast.broadcast();
  return broadcast;
}