/** Finds an inactive channel with the given id and returns it, or returns null. */
 @Nullable
 StoredClientChannel getUsableChannelForServerID(Sha256Hash id) {
   lock.lock();
   try {
     Set<StoredClientChannel> setChannels = mapChannels.get(id);
     for (StoredClientChannel channel : setChannels) {
       synchronized (channel) {
         // Check if the channel is usable (has money, inactive) and if so, activate it.
         log.info(
             "Considering channel {} contract {}", channel.hashCode(), channel.contract.getHash());
         if (channel.close != null || channel.valueToMe.equals(Coin.ZERO)) {
           log.info("  ... but is closed or empty");
           continue;
         }
         if (!channel.active) {
           log.info("  ... activating");
           channel.active = true;
           return channel;
         }
         log.info("  ... but is already active");
       }
     }
   } finally {
     lock.unlock();
   }
   return null;
 }