Documentation
¶
Index ¶
- Constants
- func UseLogger(logger btclog.Logger)
- type ApertureConfig
- type Challenger
- type InvoiceClient
- type InvoiceRequestGenerator
- type LnproxyChallenger
- func (l *LnproxyChallenger) NewChallenge(recipientLud16 string, price int64) (string, lntypes.Hash, error)
- func (l *LnproxyChallenger) Start() error
- func (l *LnproxyChallenger) Stop()
- func (l *LnproxyChallenger) VerifyInvoiceStatus(hash lntypes.Hash, state lnrpc.Invoice_InvoiceState, timeout time.Duration) error
- func (l *LnproxyChallenger) VerifyRightsWithinExpiry(paymentHash lntypes.Hash, duration time.Duration) error
- type LnproxySpecErrorResponse
- type LnproxySpecSuccessResponse
- type ProxyParameters
Constants ¶
const Subsystem = "CHLL"
Subsystem defines the sub system name of this package.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ApertureConfig ¶
type ApertureConfig struct {
LnproxyUrl string `env:"LNPROXY_URL"`
}
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 LnproxyChallenger ¶
type LnproxyChallenger struct {
// contains filtered or unexported fields
}
LnproxyChallenger is a challenger that uses an lnproxy backend to create new L402 payment challenges.
func NewLnproxyChallenger ¶
func NewLnproxyChallenger(client InvoiceClient, genInvoiceReq InvoiceRequestGenerator, store mint.SecretStore, ctxFunc func() context.Context, errChan chan<- error) (*LnproxyChallenger, error)
NewLnproxyChallenger creates a new challenger that uses the given connection to an lnd backend to create payment challenges.
func (*LnproxyChallenger) NewChallenge ¶
func (l *LnproxyChallenger) NewChallenge(recipientLud16 string, price int64) (string, lntypes.Hash, error)
NewChallenge creates a new L402 payment challenge, returning a payment request (invoice) and the corresponding payment hash. The price is given in satoshis.
NOTE: This is part of the mint.Challenger interface.
func (*LnproxyChallenger) Start ¶
func (l *LnproxyChallenger) 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 (*LnproxyChallenger) VerifyInvoiceStatus ¶
func (l *LnproxyChallenger) 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.
func (*LnproxyChallenger) VerifyRightsWithinExpiry ¶
func (l *LnproxyChallenger) VerifyRightsWithinExpiry(paymentHash lntypes.Hash, duration time.Duration) error
VerifyRightsWithinExpiry checks that the rights for a given hash are still valid and within the given expiry duration.
type LnproxySpecSuccessResponse ¶
type LnproxySpecSuccessResponse struct {
WrappedInvoice string `json:"proxy_invoice"`
}