/**
  * Closes the connection, notifying the server it should settle the channel by broadcasting the
  * most recent payment transaction.
  */
 public void settle() {
   // Shutdown is a little complicated.
   //
   // This call will cause the CLOSE message to be written to the wire, and then the
   // destroyConnection() method that
   // we defined above will be called, which in turn will call wireParser.closeConnection(), which
   // in turn will invoke
   // NioClient.closeConnection(), which will then close the socket triggering interruption of the
   // network
   // thread it had created. That causes the background thread to die, which on its way out calls
   // ProtobufParser.connectionClosed which invokes the connectionClosed method we defined above
   // which in turn
   // then configures the open-future correctly and closes the state object. Phew!
   try {
     channelClient.settle();
   } catch (IllegalStateException e) {
     // Already closed...oh well
   }
 }
 /**
  * Gets the {@link PaymentChannelClientState} object which stores the current state of the
  * connection with the server.
  *
  * <p>Note that if you call any methods which update state directly the server will not be
  * notified and channel initialization logic in the connection may fail unexpectedly.
  */
 public PaymentChannelClientState state() {
   return channelClient.state();
 }
 /**
  * Increments the total value which we pay the server.
  *
  * @param size How many satoshis to increment the payment by (note: not the new total).
  * @throws ValueOutOfRangeException If the size is negative or would pay more than this channel's
  *     total value ({@link PaymentChannelClientConnection#state()}.getTotalValue())
  * @throws IllegalStateException If the channel has been closed or is not yet open (see {@link
  *     PaymentChannelClientConnection#getChannelOpenFuture()} for the second)
  */
 public ListenableFuture<BigInteger> incrementPayment(BigInteger size)
     throws ValueOutOfRangeException, IllegalStateException {
   return channelClient.incrementPayment(size);
 }