/**
  * Checks if the channel is expired, setting state to {@link State#EXPIRED}, removing this channel
  * from wallet storage and throwing an {@link IllegalStateException} if it is.
  */
 public synchronized void checkNotExpired() {
   if (Utils.currentTimeSeconds() > expiryTime) {
     state = State.EXPIRED;
     disconnectFromChannel();
     throw new IllegalStateException("Channel expired");
   }
 }
 @Override
 protected void bitcoinSerializeToStream(OutputStream stream) throws IOException {
   checkNotNull(scriptBytes);
   maybeParse();
   Utils.int64ToByteStreamLE(value, stream);
   // TODO: Move script serialization into the Script class, where it belongs.
   stream.write(new VarInt(scriptBytes.length).encode());
   stream.write(scriptBytes);
 }