@@ -111,6 +111,11 @@ type LightningClient interface {
111111 // LookupInvoice looks up an invoice by hash.
112112 LookupInvoice (ctx context.Context , hash lntypes.Hash ) (* Invoice , error )
113113
114+ // DeleteCanceledInvoice deletes a canceled invoice identified by its
115+ // payment hash. Only invoices in the canceled state can be deleted;
116+ // attempting to delete an invoice in any other state returns an error.
117+ DeleteCanceledInvoice (ctx context.Context , hash lntypes.Hash ) error
118+
114119 // ListTransactions returns all known transactions of the backing lnd
115120 // node. It takes a start and end block height which can be used to
116121 // limit the block range that we query over. These values can be left
@@ -1855,6 +1860,24 @@ func (s *lightningClient) LookupInvoice(ctx context.Context,
18551860 return invoice , nil
18561861}
18571862
1863+ // DeleteCanceledInvoice deletes a canceled invoice from lnd's database. Only
1864+ // invoices in the canceled state can be deleted; attempting to delete an
1865+ // invoice in any other state returns an error from lnd.
1866+ func (s * lightningClient ) DeleteCanceledInvoice (ctx context.Context ,
1867+ hash lntypes.Hash ) error {
1868+
1869+ rpcCtx , cancel := context .WithTimeout (ctx , s .timeout )
1870+ defer cancel ()
1871+
1872+ rpcCtx = s .adminMac .WithMacaroonAuth (rpcCtx )
1873+ _ , err := s .client .DeleteCanceledInvoice (
1874+ rpcCtx , & lnrpc.DelCanceledInvoiceReq {
1875+ InvoiceHash : hash .String (),
1876+ },
1877+ )
1878+ return err
1879+ }
1880+
18581881// unmarshalInvoice creates an invoice from the rpc response provided.
18591882func unmarshalInvoice (resp * lnrpc.Invoice ) (* Invoice , error ) {
18601883 hash , err := lntypes .MakeHash (resp .RHash )
0 commit comments