Documentation ¶
Index ¶
Constants ¶
const Subsystem = "CHLL"
Subsystem defines the sub system name of this package.
Variables ¶
var ( N_SEC_KEY = os.Getenv("N_SEC_KEY") N_PUB_KEY = os.Getenv("N_PUB_KEY") MockNostrClient = &NostrClient{} )
Functions ¶
Types ¶
type Challenger ¶
type Challenger interface { mint.Challenger auth.InvoiceChecker }
Challenger is an interface that combines the mint.Challenger and the auth.InvoiceChecker interfaces.
type InvoiceClient ¶
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) }
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 InvoiceRequestGenerator ¶
InvoiceRequestGenerator is a function type that returns a new request for the lnrpc.AddInvoice call.
type LNCChallenger ¶
type LNCChallenger struct {
// contains filtered or unexported fields
}
LNCChallenger is a challenger that uses LNC to connect to an lnd backend to create new LSAT payment challenges.
func NewLNCChallenger ¶
func NewLNCChallenger(session *lnc.Session, lncStore lnc.Store, genInvoiceReq InvoiceRequestGenerator, nclient NostrClient, errChan chan<- error) (*LNCChallenger, error)
NewLNCChallenger creates a new challenger that uses the given LNC session to connect to an lnd backend to create payment challenges.
func (*LNCChallenger) NewChallenge ¶
NewChallenge creates a new LSAT payment challenge, returning a payment request (invoice) and the corresponding payment hash.
NOTE: This is part of the mint.Challenger interface.
func (*LNCChallenger) VerifyInvoiceStatus ¶
func (l *LNCChallenger) VerifyInvoiceStatus(hash lntypes.Hash, state lnrpc.Invoice_InvoiceState, timeout time.Duration) error
VerifyInvoiceStatus checks that an invoice identified by a payment hash has the desired status. To make sure we don't fail while the invoice update is still on its way, we try several times until either the desired status is set or the given timeout is reached.
NOTE: This is part of the auth.InvoiceChecker interface.
type LndChallenger ¶
type LndChallenger struct {
// contains filtered or unexported fields
}
LndChallenger is a challenger that uses an lnd backend to create new LSAT payment challenges.
func NewLndChallenger ¶
func NewLndChallenger(client InvoiceClient, genInvoiceReq InvoiceRequestGenerator, nclient NostrClient, ctxFunc func() context.Context, errChan chan<- error) (*LndChallenger, error)
NewLndChallenger creates a new challenger that uses the given connection to an lnd backend to create payment challenges.
func (*LndChallenger) NewChallenge ¶
NewChallenge creates a new LSAT payment challenge, returning a payment request (invoice) and the corresponding payment hash.
NOTE: This is part of the mint.Challenger interface.
func (*LndChallenger) Start ¶
func (l *LndChallenger) Start() error
Start starts the challenger's main work which is to keep track of all invoices and their states. For that the backing lnd node is queried for all invoices on startup and the a subscription to all subsequent invoice updates is created.
func (*LndChallenger) VerifyInvoiceStatus ¶
func (l *LndChallenger) VerifyInvoiceStatus(hash lntypes.Hash, state lnrpc.Invoice_InvoiceState, timeout time.Duration) error
VerifyInvoiceStatus checks that an invoice identified by a payment hash has the desired status. To make sure we don't fail while the invoice update is still on its way, we try several times until either the desired status is set or the given timeout is reached.
NOTE: This is part of the auth.InvoiceChecker interface.
type NostrClient ¶ added in v0.0.2
type NostrClient struct {
// contains filtered or unexported fields
}