code: public synchronized void storeChannelInWallet(@Nullable PaymentChannelServer connectedHandler) {
          stateMachine.checkState(State.READY);
          if (storedServerChannel != null)
              return;
  
          log.info("Storing state with contract hash {}.", getContract().getTxId());
          StoredPaymentChannelServerStates channels = (StoredPaymentChannelServerStates)
                  wallet.addOrGetExistingExtension(new StoredPaymentChannelServerStates(wallet, broadcaster));
          storedServerChannel = new StoredServerChannel(this, getMajorVersion(), getContract(), getClientOutput(), getExpiryTime(), serverKey, getClientKey(), bestValueToMe, bestValueSignature);
          if (connectedHandler != null)
              checkState(storedServerChannel.setConnectedHandler(connectedHandler, false) == connectedHandler);
          channels.putChannel(storedServerChannel);
      }
docs: Stores this channel's state in the wallet as a part of a {@link StoredPaymentChannelServerStates} wallet
  extension and keeps it up-to-date each time payment is incremented. This will be automatically removed when
  a call to {@link PaymentChannelV1ServerState#close()} completes successfully. A channel may only be stored after it
  has fully opened (ie state == State.READY).
  
  @param connectedHandler Optional {@link PaymentChannelServer} object that manages this object. This will
  set the appropriate pointer in the newly created {@link StoredServerChannel} before it is
  committed to wallet. If set, closing the state object will propagate the close to the
  handler which can then do a TCP disconnect.