Program: 85708
Project: 85708
Buggy source:
/** 
 * <p>Closes this channel and broadcasts the highest value payment transaction on the network.</p> <p>This will set the state to   {@link State#CLOSED} if the transaction is successfully broadcast on the network.If we fail to broadcast for some reason, the state is set to  {@link State#ERROR}.</p> <p>If the current state is before   {@link State#READY} (ie we have not finished initializing the channel), wesimply set the state to  {@link State#CLOSED} and let the client handle getting its refund transaction confirmed.</p>
 * @return a future which completes when the provided multisig contract successfully broadcasts, or throws if thebroadcast fails for some reason. Note that if the network simply rejects the transaction, this future will never complete, a timeout should be used.
 * @throws InsufficientMoneyException If the payment tx would have cost more in fees to spend than it is worth.
 */
public synchronized ListenableFuture<Transaction> close() throws InsufficientMoneyException {
  if (storedServerChannel != null) {
    StoredServerChannel temp=storedServerChannel;
    storedServerChannel=null;
    StoredPaymentChannelServerStates channels=(StoredPaymentChannelServerStates)wallet.getExtensions().get(StoredPaymentChannelServerStates.EXTENSION_ID);
    channels.closeChannel(temp);
    if (state.compareTo(State.CLOSING) >= 0)     return closedFuture;
  }
  if (state.ordinal() < State.READY.ordinal()) {
    log.error("String_Node_Str" + state);
    state=State.CLOSED;
    closedFuture.set(null);
    return closedFuture;
  }
  if (state != State.READY) {
    log.warn("String_Node_Str" + state);
    return closedFuture;
  }
  Transaction tx=null;
  try {
    Wallet.SendRequest req=makeUnsignedChannelContract(bestValueToMe);
    tx=req.tx;
    signMultisigInput(tx,Transaction.SigHash.NONE,true);
    req.shuffleOutputs=false;
    wallet.completeTx(req);
    feePaidForPayment=req.fee;
    log.info("String_Node_Str",feePaidForPayment);
    if (feePaidForPayment.compareTo(bestValueToMe) >= 0) {
      final String msg=String.format("String_Node_Str",feePaidForPayment,bestValueToMe);
      throw new InsufficientMoneyException(feePaidForPayment.subtract(bestValueToMe),msg);
    }
    signMultisigInput(tx,Transaction.SigHash.ALL,false);
    tx.verify();
    for (    TransactionInput input : tx.getInputs())     input.verify();
  }
 catch (  InsufficientMoneyException e) {
    throw e;
  }
catch (  Exception e) {
    log.error("String_Node_Str",multisigContract,tx != null ? tx : "String_Node_Str");
    throw new RuntimeException(e);
  }
  state=State.CLOSING;
  log.info("String_Node_Str",tx);
  ListenableFuture<Transaction> future=broadcaster.broadcastTransaction(tx);
  Futures.addCallback(future,new FutureCallback<Transaction>(){
    @Override public void onSuccess(    Transaction transaction){
      log.info("String_Node_Str",transaction.getHash());
      state=State.CLOSED;
      closedFuture.set(transaction);
    }
    @Override public void onFailure(    Throwable throwable){
      log.error("String_Node_Str",throwable.toString());
      throwable.printStackTrace();
      state=State.ERROR;
      closedFuture.setException(throwable);
    }
  }
);
  return closedFuture;
}

Fixed version (ground truth):
/** 
 * <p>Closes this channel and broadcasts the highest value payment transaction on the network.</p> <p>This will set the state to   {@link State#CLOSED} if the transaction is successfully broadcast on the network.If we fail to broadcast for some reason, the state is set to  {@link State#ERROR}.</p> <p>If the current state is before   {@link State#READY} (ie we have not finished initializing the channel), wesimply set the state to  {@link State#CLOSED} and let the client handle getting its refund transaction confirmed.</p>
 * @return a future which completes when the provided multisig contract successfully broadcasts, or throws if thebroadcast fails for some reason. Note that if the network simply rejects the transaction, this future will never complete, a timeout should be used.
 * @throws InsufficientMoneyException If the payment tx would have cost more in fees to spend than it is worth.
 */
public synchronized ListenableFuture<Transaction> close() throws InsufficientMoneyException {
  if (storedServerChannel != null) {
    StoredServerChannel temp=storedServerChannel;
    storedServerChannel=null;
    StoredPaymentChannelServerStates channels=(StoredPaymentChannelServerStates)wallet.getExtensions().get(StoredPaymentChannelServerStates.EXTENSION_ID);
    channels.closeChannel(temp);
    if (state.compareTo(State.CLOSING) >= 0)     return closedFuture;
  }
  if (state.ordinal() < State.READY.ordinal()) {
    log.error("String_Node_Str" + state);
    state=State.CLOSED;
    closedFuture.set(null);
    return closedFuture;
  }
  if (state != State.READY) {
    log.warn("String_Node_Str" + state);
    return closedFuture;
  }
  Transaction tx=null;
  try {
    Wallet.SendRequest req=makeUnsignedChannelContract(bestValueToMe);
    tx=req.tx;
    signMultisigInput(tx,Transaction.SigHash.NONE,true);
    req.shuffleOutputs=false;
    wallet.completeTx(req);
    feePaidForPayment=req.tx.getFee();
    log.info("String_Node_Str",feePaidForPayment);
    if (feePaidForPayment.compareTo(bestValueToMe) >= 0) {
      final String msg=String.format("String_Node_Str",feePaidForPayment,bestValueToMe);
      throw new InsufficientMoneyException(feePaidForPayment.subtract(bestValueToMe),msg);
    }
    signMultisigInput(tx,Transaction.SigHash.ALL,false);
    tx.verify();
    for (    TransactionInput input : tx.getInputs())     input.verify();
  }
 catch (  InsufficientMoneyException e) {
    throw e;
  }
catch (  Exception e) {
    log.error("String_Node_Str",multisigContract,tx != null ? tx : "String_Node_Str");
    throw new RuntimeException(e);
  }
  state=State.CLOSING;
  log.info("String_Node_Str",tx);
  ListenableFuture<Transaction> future=broadcaster.broadcastTransaction(tx);
  Futures.addCallback(future,new FutureCallback<Transaction>(){
    @Override public void onSuccess(    Transaction transaction){
      log.info("String_Node_Str",transaction.getHash());
      state=State.CLOSED;
      closedFuture.set(transaction);
    }
    @Override public void onFailure(    Throwable throwable){
      log.error("String_Node_Str",throwable.toString());
      throwable.printStackTrace();
      state=State.ERROR;
      closedFuture.setException(throwable);
    }
  }
);
  return closedFuture;
}