Skip to content

Commit 1a94dbf

Browse files
committed
Add a few comments and fix lints
1 parent d4abbe5 commit 1a94dbf

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

lnd_services.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ type LndServices struct {
180180
Router RouterClient
181181
Versioner VersionerClient
182182
State StateClient
183-
WtClient wtClientClient
183+
WtClient WatchtowerClientClient
184184

185185
ChainParams *chaincfg.Params
186186
NodeAlias string
@@ -386,6 +386,9 @@ func NewLndServices(cfg *LndServicesConfig) (*GrpcLndServices, error) {
386386
routerClient := newRouterClient(
387387
conn, macaroons[RouterServiceMac], timeout,
388388
)
389+
wtClientClient := newWtClientClient(
390+
conn, macaroons[WalletKitServiceMac], timeout,
391+
)
389392

390393
cleanup := func() {
391394
log.Debugf("Closing lnd connection")
@@ -417,6 +420,7 @@ func NewLndServices(cfg *LndServicesConfig) (*GrpcLndServices, error) {
417420
Router: routerClient,
418421
Versioner: versionerClient,
419422
State: stateClient,
423+
WtClient: wtClientClient,
420424
ChainParams: chainParams,
421425
NodeAlias: nodeAlias,
422426
NodePubkey: route.Vertex(nodeKey),

macaroon_recipes.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ var (
5555
}
5656
)
5757

58-
func replaceRight(s, old, new string) string {
59-
i := strings.LastIndex(s, old)
58+
func replaceRight(s, oldString, newString string) string {
59+
i := strings.LastIndex(s, oldString)
6060
if i == -1 {
6161
return s
6262
}
6363

64-
return s[:i] + new + s[i+len(old):]
64+
return s[:i] + newString + s[i+len(oldString):]
6565
}
6666

6767
// MacaroonRecipe returns a list of macaroon permissions that is required to use

wtclient_client.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,15 @@ import (
88
"google.golang.org/grpc"
99
)
1010

11+
// Implementation of the watchtower client interface
12+
// https://lightning.engineering/api-docs/category/watchtowerclient-service/
1113
type WatchtowerClientClient interface {
1214
ServiceClient[wtclientrpc.WatchtowerClientClient]
1315

1416
AddTower(ctx context.Context, pubkey []byte, address string) error
1517

18+
// Sets the given tower's status to inactive so that it's not considered
19+
// for session negotiation. Returns a human readable status string.
1620
DeactivateTower(ctx context.Context, pubkey []byte) (string, error)
1721

1822
GetTowerInfo(ctx context.Context, pubkey []byte, includeSessions,
@@ -27,14 +31,20 @@ type WatchtowerClientClient interface {
2731

2832
Stats(ctx context.Context) (*StatsResponse, error)
2933

34+
// Terminates the given session and marks it to not be used for backups
35+
// anymore. Returns a human readable status string.
3036
TerminateSession(ctx context.Context, sessionId []byte) (string, error)
3137
}
3238

39+
// Response returned by `Policy`
40+
// https://lightning.engineering/api-docs/api/lnd/watchtower-client/policy/#wtclientrpcpolicyresponse
3341
type PolicyResponse struct {
3442
maxUpdates uint32
3543
sweepSatPerVbyte uint32
3644
}
3745

46+
// Response returned by `Stats`
47+
// https://lightning.engineering/api-docs/api/lnd/watchtower-client/stats/#wtclientrpcstatsresponse
3848
type StatsResponse struct {
3949
numBackups uint32
4050
numPendingBackups uint32
@@ -107,6 +117,7 @@ func (m *wtClientClient) DeactivateTower(ctx context.Context, pubkey []byte) (st
107117

108118
func (m *wtClientClient) GetTowerInfo(ctx context.Context, pubkey []byte, includeSessions,
109119
excludeExhaustedSessions bool) (*wtclientrpc.Tower, error) {
120+
110121
rpcCtx, cancel := context.WithTimeout(ctx, m.timeout)
111122
defer cancel()
112123

@@ -125,6 +136,7 @@ func (m *wtClientClient) GetTowerInfo(ctx context.Context, pubkey []byte, includ
125136

126137
func (m *wtClientClient) ListTowers(ctx context.Context, includeSessions,
127138
excludeExhaustedSessions bool) ([]*wtclientrpc.Tower, error) {
139+
128140
rpcCtx, cancel := context.WithTimeout(ctx, m.timeout)
129141
defer cancel()
130142

@@ -157,6 +169,7 @@ func (m *wtClientClient) Policy(ctx context.Context, policyType wtclientrpc.Poli
157169
sweepSatPerVbyte: resp.SweepSatPerVbyte,
158170
}, nil
159171
}
172+
160173
func (m *wtClientClient) RemoveTower(ctx context.Context, pubkey []byte, address string) error {
161174
rpcCtx, cancel := context.WithTimeout(ctx, m.timeout)
162175
defer cancel()

0 commit comments

Comments
 (0)