@Nullable public ECKey findKeyFromPubHash(byte[] pubkeyHash){
  lock.lock();
  try {
    for (    ECKey key : keychain) {
      if (Arrays.equals(key.getPubKeyHash(),pubkeyHash))       return key;
    }
    return null;
  }
  finally {
    lock.unlock();
  }
}

@ Nullable public ECKey findKeyFromPubHash ( byte [ ] pubkeyHash ) { lock . lock ( ) ; try { for ( ECKey key : keychain ) { if ( Arrays . equals ( key . getPubKeyHash ( ) , pubkeyHash ) ) return key ; } return null ; } finally { lock . unlock ( ) ; } }
locates a keypair from the keychain given the hash of the public key . this is needed when finding out which key we need to use to redeem a transaction output .
