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 committed 2023-01-16 07:31:09 -08:00
1 parent 383cb40f8d
commit 5ff5225245
26 files changed
+2839 -2253

No files matched your search

+2 -2
View File
@@ -980,7 +980,7 @@ func newMockRegistry(minDelta uint32) *mockInvoiceRegistry {
}
func (i *mockInvoiceRegistry) LookupInvoice(rHash lntypes.Hash) (
channeldb.Invoice, error) {
invoices.Invoice, error) {
return i.registry.LookupInvoice(rHash)
}
@@ -1014,7 +1014,7 @@ func (i *mockInvoiceRegistry) CancelInvoice(payHash lntypes.Hash) error {
return i.registry.CancelInvoice(payHash)
}
func (i *mockInvoiceRegistry) AddInvoice(invoice channeldb.Invoice,
func (i *mockInvoiceRegistry) AddInvoice(invoice invoices.Invoice,
paymentHash lntypes.Hash) error {
_, err := i.registry.AddInvoice(&invoice, paymentHash)