Skip to content

Commit 0238047

Browse files
committed
challenger: change NewLndChallenger client parameter
- Alters NewLndChallenger so that it takes challenger.InvoiceClient in as a parameter. (This is useful in the case of using NewLndChallenger in the lnd watchtower project, to avoid having to import lndclient, which leads to an import cycle.) - Also deletes the AuthConfig parameter. Since we now pass the LND client directly into the function, the AuthConfig parameter is no longer needed.
1 parent 0deba12 commit 0238047

File tree

2 files changed

+12
-18
lines changed

2 files changed

+12
-18
lines changed

aperture.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"github.com/lightninglabs/aperture/proxy"
2424
"github.com/lightninglabs/aperture/secrets"
2525
"github.com/lightninglabs/lightning-node-connect/hashmailrpc"
26+
"github.com/lightninglabs/lndclient"
2627
"github.com/lightningnetwork/lnd"
2728
"github.com/lightningnetwork/lnd/build"
2829
"github.com/lightningnetwork/lnd/cert"
@@ -223,15 +224,17 @@ func (a *Aperture) Start(errChan chan error) error {
223224
}
224225

225226
if !a.cfg.Authenticator.Disable {
226-
challengerAuth := &challenger.AuthConfig{
227-
LndHost: a.cfg.Authenticator.LndHost,
228-
TLSPath: a.cfg.Authenticator.TLSPath,
229-
MacDir: a.cfg.Authenticator.MacDir,
230-
Network: a.cfg.Authenticator.Network,
231-
Disable: a.cfg.Authenticator.Disable,
227+
client, err := lndclient.NewBasicClient(
228+
a.cfg.Authenticator.LndHost, a.cfg.Authenticator.TLSPath,
229+
a.cfg.Authenticator.MacDir, a.cfg.Authenticator.Network,
230+
lndclient.MacFilename(challenger.InvoiceMacaroonName),
231+
)
232+
if err != nil {
233+
return err
232234
}
235+
233236
a.challenger, err = challenger.NewLndChallenger(
234-
challengerAuth, genInvoiceReq, errChan,
237+
genInvoiceReq, client, errChan,
235238
)
236239
if err != nil {
237240
return err

challenger/challenger.go

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111

1212
"github.com/lightninglabs/aperture/auth"
1313
"github.com/lightninglabs/aperture/mint"
14-
"github.com/lightninglabs/lndclient"
1514
"github.com/lightningnetwork/lnd/lnrpc"
1615
"github.com/lightningnetwork/lnd/lntypes"
1716
"google.golang.org/grpc"
@@ -81,21 +80,13 @@ const (
8180

8281
// NewLndChallenger creates a new challenger that uses the given connection
8382
// details to connect to an lnd backend to create payment challenges.
84-
func NewLndChallenger(cfg *AuthConfig, genInvoiceReq InvoiceRequestGenerator,
85-
errChan chan<- error) (*LndChallenger, error) {
83+
func NewLndChallenger(genInvoiceReq InvoiceRequestGenerator,
84+
client InvoiceClient, errChan chan<- error) (*LndChallenger, error) {
8685

8786
if genInvoiceReq == nil {
8887
return nil, fmt.Errorf("genInvoiceReq cannot be nil")
8988
}
9089

91-
client, err := lndclient.NewBasicClient(
92-
cfg.LndHost, cfg.TLSPath, cfg.MacDir, cfg.Network,
93-
lndclient.MacFilename(InvoiceMacaroonName),
94-
)
95-
if err != nil {
96-
return nil, err
97-
}
98-
9990
invoicesMtx := &sync.Mutex{}
10091
return &LndChallenger{
10192
client: client,

0 commit comments

Comments
 (0)