N.Y. LIE. LAW § 21 : NY Code - Section 21: Discharge of lien for public improvement

A lien against the
  amount due or to become due a contractor from  the  state  or  a  public
  corporation  for  the construction or demolition of a public improvement
  may be discharged as follows:
    1. By filing a certificate of the lienor or his successor in interest,
  duly acknowledged and approved, stating that the lien is discharged.
    2. By lapse of time as follows:
    (a) When one year has elapsed since the filing of the notice  of  lien
  or  an  extension thereof, unless, before the expiration thereof, either
  an extension or an order continuing said lien  has  been  filed  in  the
  office  where  the  notices are filed, or a notice of the pendency of an
  action to enforce said lien  has  been  filed  as  provided  in  section
  eighteen of this article.
    (b)  When  the period of time for which the lien has been continued by
  order has expired, unless, before  the  expiration  thereof,  either  an
  order  continuing  said lien for a further period of time has been filed
  in the offices where the notices are filed, or a notice of the  pendency
  of  an action to enforce said lien has been filed as provided in section
  eighteen of this article.
    3. By satisfaction of a judgment rendered in an action to enforce  the
  lien.
    3-a.  Under  the provisions of subdivisions four, five and six of this
  section  a  discharge  of  lien  shall  only  operate  to  relieve   the
  comptroller  of  the  state  or  the  financial  officer  of  the public
  corporation or the officer or person with whom the lien is filed of  any
  and  all  liability imposed upon such officer by reason of the filing of
  the lien. Such lien shall be a valid and subsisting lien for  all  other
  purposes  until  discharged as prescribed by the provisions of the other
  subdivisions of this section.
    4. By the contractor applying without notice to the supreme  court  of
  this  state  or  to  any  justice  thereof or to the county judge of any
  county for an order  discharging  such  lien  and  depositing  with  the
  comptroller  of  the  state  or  the  financial  officer  of  the public
  corporation, or the officer or person with whom the notice  of  lien  is
  filed, such a sum of money as is directed by a judge or a justice of the
  court,  which  shall  not be less than the amount claimed by the lienor,
  with interest thereon for the term of one year from the time  of  making
  such  deposit,  and such additional amount as the judge or justice deems
  sufficient to cover all costs and  expenses.  The  amount  so  deposited
  shall  remain  with  the  comptroller or such financial officer or other
  officer or person until the lien is otherwise discharged  as  prescribed
  in this section.
    (5)  Either before or after the beginning of an action by a contractor
  or subcontractor executing a bond or undertaking in an amount  equal  to
  one  hundred ten percent of such lien conditioned for the payment of any
  judgement which may be recovered in an action to enforce the lien:
    a. The execution of any such bond or undertaking by  any  fidelity  or
  surety  company  authorized  by  the  laws  of  this  state  to transact
  business, shall be sufficient; and where a certificate of  qualification
  has  been issued by the superintendent of insurance under the provisions
  of section one thousand one hundred eleven of the insurance law, and has
  not been revoked, no justification or notice thereof shall be necessary.
  Any such company may execute any such bond or undertaking as  surety  by
  the  hand  of  its  officers,  or  attorney,  duly authorized thereto by
  resolution of  its  board  of  directors,  a  certified  copy  of  which
  resolution, under seal of said company, shall be filed with each bond or
  undertaking.  Any such bond or undertaking shall be filed with the state
  or the public corporation with which the notice of lien is filed  and  a

  copy  shall  be  served  upon  the  adverse  party.  The  undertaking is
  effective when so served and filed. If a  certificate  of  qualification
  issued  pursuant to subsections (b), (c) and (d) of section one thousand
  one  hundred  eleven  of  the  insurance  law  is  not  filed  with  the
  undertaking, a party may except, to the sufficiency of a surety and by a
  written notice of exception served upon the  adverse  party  within  ten
  days  after receipt, a copy of the undertaking. Exceptions deemed by the
  court to have been taken unnecessarily, or for vexation or  delay,  may,
  upon notice, be set aside, with costs. Where no exception to sureties is
  taken  within  ten  days  or  where  exceptions  taken are set aside the
  undertaking shall be allowed.
    b. In the case of bonds  or  undertakings  not  executed  pursuant  to
  paragraph  a  of this subdivision, the owner or contractor shall execute
  an undertaking with two or more sufficient sureties, who shall  be  free
  holders,  to  the  state  or public corporation with which the notice of
  lien is filed. The sureties must together justify in at least double the
  sum named in the undertaking. A copy of  the  undertaking,  with  notice
  that  the  sureties will justify before the court, or a judge or justice
  thereof, at the time and place therein mentioned, must  be  served  upon
  the  lienor  or  his attorney, not less than five days before such time.
  Upon the approval of the undertaking by the court, judge or  justice  an
  order  shall  be  made  by such court, judge or justice discharging such
  lien.
    c. If the lienor cannot be found, or does not appear by attorney, then
  service under this subsection may be made as prescribed in  paragraph  c
  of  subdivision four of section nineteen of this article for the service
  of  an  undertaking  with   notice   of   justification   of   sureties.
  Notwithstanding  the  other  provisions  of this subdivision relating to
  service of notice, in any case where the mailing address of  the  lienor
  is outside the state such service may be made by registered or certified
  mail,  return  receipt  requested, to such lienor at the mailing address
  contained in the notice of lien.
    d. Except as otherwise provided in this subdivision, the provisions of
  article twenty-five of the  civil  practice  law  and  rules  regulating
  undertakings  is  applicable  to  a  bond  or  undertaking given for the
  discharge of a lien on account of public improvements.
    6. Where a contractor has to his credit  with  the  state  or  with  a
  public  corporation,  a  sum  of  money by reason of an estimate due and
  payable to him, and where payment of such estimate is withheld because a
  notice of lien has been filed against his interest in  said  money,  and
  where  said  money  is  in excess of the amount claimed in the notice of
  lien, the contractor may apply without notice to the  supreme  court  of
  this  state  or  to  any  justice  thereof or to the county judge of any
  county, for an order discharging such lien and directing the comptroller
  of the state or the financial officer or person with whom  the  lien  is
  filed,  to  retain from such estimate a sum of money, which shall not be
  less than the amount claimed by the lienor, with  interest  thereon  for
  one  year  and  such  additional  amount  as  the judge or justice deems
  sufficient to cover all costs and expenses and to immediately  pay  over
  the  balance  of such estimate to the contractor. The amount so retained
  shall be held by the comptroller or  such  financial  officer  or  other
  officer  or person until the lien is otherwise discharged as provided in
  this section. The  application  for  the  order  may  be  made  upon  an
  affidavit of the contractor or his attorney and where there is of record
  an assignment of all moneys the written consent of such assignee must be
  presented to the court showing a proper case therefor.
    6-a.  Where  a  contractor has to his credit with the state, or with a
  public corporation, a sum of money by reason  of  an  estimate  due  and

  payable to him, and where payment of such estimate is withheld because a
  notice  of  lien  has been filed against his interest in said money, and
  where the amount due and payable under said estimate is at least one and
  one-half  times  in excess of the amount stated to be due in said notice
  of lien, the comptroller of the state or the financial officer or person
  with whom the notice of lien is filed,  may  pay  said  estimate,  after
  deducting  therefrom  a  sum  which  shall be one and one-half times the
  amount stated to be due in said notice of lien, and said sum so deducted
  shall be withheld until said lien is otherwise discharged,  as  provided
  in this section.
    7.  Where  it  appears  from  the  face of the notice of lien that the
  claimant has no valid lien by reason of the character of  the  labor  or
  materials furnished and for which a lien is claimed, or where the notice
  of lien is invalid by reason of failure to comply with the provisions of
  section  twelve  of  this  article,  or where it appears from the public
  records that such notice has not  been  filed  in  accordance  with  the
  provisions  of  section  twelve  of  this article, the contractor or any
  other party in interest, may apply to the supreme court of  this  state,
  or to any justice thereof, or to the county judge of the county in which
  the  notice  of  lien  is  filed,  for an order summarily discharging of
  record the alleged lien. A copy of the  papers  upon  which  application
  will  be  made  together  with  a  notice setting forth the court or the
  justice thereof or the judge to whom the application will be made  at  a
  time and place therein mentioned must be served upon the lienor not less
  than  five  days  before such time. If the lienor can not be found, such
  service may be made as the court,  justice  or  judge  may  direct.  The
  application  must  be made upon a verified petition accompanied by other
  written proof showing a proper case therefor, and upon the  approval  of
  the  application  by the court, justice or judge, an order shall be made
  discharging the alleged lien of record.
    8. By order of the court vacating or canceling such  lien  of  record,
  for  neglect  of  the  lienor to prosecute the same, granted pursuant to
  section twenty-one-a of this article.