Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions lightning_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ type LightningClient interface {
// LookupInvoice looks up an invoice by hash.
LookupInvoice(ctx context.Context, hash lntypes.Hash) (*Invoice, error)

// DeleteCanceledInvoice deletes a canceled invoice identified by its
// payment hash. Only invoices in the canceled state can be deleted;
// attempting to delete an invoice in any other state returns an error.
DeleteCanceledInvoice(ctx context.Context, hash lntypes.Hash) error

// ListTransactions returns all known transactions of the backing lnd
// node. It takes a start and end block height which can be used to
// limit the block range that we query over. These values can be left
Expand Down Expand Up @@ -1855,6 +1860,24 @@ func (s *lightningClient) LookupInvoice(ctx context.Context,
return invoice, nil
}

// DeleteCanceledInvoice deletes a canceled invoice from lnd's database. Only
// invoices in the canceled state can be deleted; attempting to delete an
// invoice in any other state returns an error from lnd.
func (s *lightningClient) DeleteCanceledInvoice(ctx context.Context,
hash lntypes.Hash) error {

rpcCtx, cancel := context.WithTimeout(ctx, s.timeout)
defer cancel()

rpcCtx = s.adminMac.WithMacaroonAuth(rpcCtx)
_, err := s.client.DeleteCanceledInvoice(
rpcCtx, &lnrpc.DelCanceledInvoiceReq{
InvoiceHash: hash.String(),
},
)
return err
}

// unmarshalInvoice creates an invoice from the rpc response provided.
func unmarshalInvoice(resp *lnrpc.Invoice) (*Invoice, error) {
hash, err := lntypes.MakeHash(resp.RHash)
Expand Down
8 changes: 8 additions & 0 deletions testdata/permissions.json
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,14 @@
}
]
},
"/lnrpc.Lightning/DeleteCanceledInvoice": {
"permissions": [
{
"entity": "invoices",
"action": "write"
}
]
},
"/lnrpc.Lightning/NewAddress": {
"permissions": [
{
Expand Down
Loading