multi: break invoice depenency on channeldb

Now that we have the new package `lnd/channeldb/models` we can invert the
depenency between `channeldb` and `invoices`.

- Move all the invoice related types and errors to the
`invoices` package.

- Ensure that all the packages dealing with invoices use the types and
  interfaces defined in the `invoices` package.

- Implement the InvoiceDB interface (defined in `lnd/invoices`) in
  channeldb.

- Add new mock for InterfaceDB.

- `InvoiceRegistery` tests are now in its own subpacakge (they need to
  import both invoices & channeldb). This is temporary until we can
  decouple them.
This commit is contained in:
positiveblue
2022-11-30 03:00:37 -08:00
parent 383cb40f8d
commit 5ff5225245
26 changed files with 2839 additions and 2253 deletions

View File

@ -5507,7 +5507,7 @@ func (r *rpcServer) LookupInvoice(ctx context.Context,
invoice, err := r.server.invoices.LookupInvoice(payHash)
switch {
case err == channeldb.ErrInvoiceNotFound:
case errors.Is(err, invoices.ErrInvoiceNotFound):
return nil, status.Error(codes.NotFound, err.Error())
case err != nil:
return nil, err
@ -5551,7 +5551,7 @@ func (r *rpcServer) ListInvoices(ctx context.Context,
// Next, we'll map the proto request into a format that is understood by
// the database.
q := channeldb.InvoiceQuery{
q := invoices.InvoiceQuery{
IndexOffset: req.IndexOffset,
NumMaxInvoices: req.NumMaxInvoices,
PendingOnly: req.PendingOnly,