mirror of
https://github.com/lightninglabs/aperture.git
synced 2025-12-17 00:54:20 +01:00
The new package contains a new interface (`Challenger`) that any new challenger must implement. Because aperture uses the new interface instead of using directly the `LndChallenger` struct I added the `Stop()` method to the `mint.Challenger`. Instead of also adding the `Start()` method the constructor returns a Challenger already "started".
39 lines
1.3 KiB
Go
39 lines
1.3 KiB
Go
package challenger
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/lightninglabs/aperture/auth"
|
|
"github.com/lightninglabs/aperture/mint"
|
|
"github.com/lightningnetwork/lnd/lnrpc"
|
|
"google.golang.org/grpc"
|
|
)
|
|
|
|
// InvoiceRequestGenerator is a function type that returns a new request for the
|
|
// lnrpc.AddInvoice call.
|
|
type InvoiceRequestGenerator func(price int64) (*lnrpc.Invoice, error)
|
|
|
|
// InvoiceClient is an interface that only implements part of a full lnd client,
|
|
// namely the part around the invoices we need for the challenger to work.
|
|
type InvoiceClient interface {
|
|
// ListInvoices returns a paginated list of all invoices known to lnd.
|
|
ListInvoices(ctx context.Context, in *lnrpc.ListInvoiceRequest,
|
|
opts ...grpc.CallOption) (*lnrpc.ListInvoiceResponse, error)
|
|
|
|
// SubscribeInvoices subscribes to updates on invoices.
|
|
SubscribeInvoices(ctx context.Context, in *lnrpc.InvoiceSubscription,
|
|
opts ...grpc.CallOption) (
|
|
lnrpc.Lightning_SubscribeInvoicesClient, error)
|
|
|
|
// AddInvoice adds a new invoice to lnd.
|
|
AddInvoice(ctx context.Context, in *lnrpc.Invoice,
|
|
opts ...grpc.CallOption) (*lnrpc.AddInvoiceResponse, error)
|
|
}
|
|
|
|
// Challenger is an interface that combines the mint.Challenger and the
|
|
// auth.InvoiceChecker interfaces.
|
|
type Challenger interface {
|
|
mint.Challenger
|
|
auth.InvoiceChecker
|
|
}
|