8
8
"google.golang.org/grpc"
9
9
)
10
10
11
- // Implementation of the watchtower client interface
11
+ // WatchtowerClientClient implements the watchtower client interface
12
12
// https://lightning.engineering/api-docs/category/watchtowerclient-service/
13
13
type WatchtowerClientClient interface {
14
14
ServiceClient [wtclientrpc.WatchtowerClientClient ]
@@ -25,20 +25,21 @@ type WatchtowerClientClient interface {
25
25
DeactivateTower (ctx context.Context , pubkey []byte ) (string , error )
26
26
27
27
// GetTowerInfo gets information about a watchtower that corresponds to the
28
- // given pubkey. The `includeSessions` flag controls whether session information is
29
- // included. The `excludeExhaustedSessions` controls whether exhausted sessions
30
- // are included in the response.
28
+ // given pubkey. The `includeSessions` flag controls whether session
29
+ // information is included. The `excludeExhaustedSessions` controls whether
30
+ // exhausted sessions are included in the response.
31
31
GetTowerInfo (ctx context.Context , pubkey []byte , includeSessions ,
32
32
excludeExhaustedSessions bool ) (* wtclientrpc.Tower , error )
33
33
34
34
// ListTowers gets information about all registered watchtowers. The
35
- // `includeSessions` and `excludeExhaustedSessions` flags serve the same function as
36
- // in the `GetTowerInfo` method.
35
+ // `includeSessions` and `excludeExhaustedSessions` flags serve the same
36
+ // function as in the `GetTowerInfo` method.
37
37
ListTowers (ctx context.Context , includeSessions ,
38
38
excludeExhaustedSessions bool ) ([]* wtclientrpc.Tower , error )
39
39
40
40
// Policy returns the active watchtower client policy configuration.
41
- Policy (ctx context.Context , policyType wtclientrpc.PolicyType ) (* PolicyResponse , error )
41
+ Policy (ctx context.Context , policyType wtclientrpc.PolicyType ) (
42
+ * PolicyResponse , error )
42
43
43
44
// RemoveTower removes a watchtower from being considered for future session
44
45
// negotiations and from being used for any subsequent backups until it's added
@@ -54,14 +55,16 @@ type WatchtowerClientClient interface {
54
55
TerminateSession (ctx context.Context , sessionId []byte ) (string , error )
55
56
}
56
57
57
- // Response returned by `Policy`
58
+ // PolicyResponse returned by `Policy`
59
+ // nolint:lll
58
60
// https://lightning.engineering/api-docs/api/lnd/watchtower-client/policy/#wtclientrpcpolicyresponse
59
61
type PolicyResponse struct {
60
62
maxUpdates uint32
61
63
sweepSatPerVbyte uint32
62
64
}
63
65
64
- // Response returned by `Stats`
66
+ // StatsResponse returned by `Stats`
67
+ // nolint:lll
65
68
// https://lightning.engineering/api-docs/api/lnd/watchtower-client/stats/#wtclientrpcstatsresponse
66
69
type StatsResponse struct {
67
70
numBackups uint32
@@ -105,7 +108,9 @@ func (m *wtClientClient) RawClientWithMacAuth(
105
108
// considers it for new sessions. If the watchtower already exists, then
106
109
// any new addresses included will be considered when dialing it for
107
110
// session negotiations and backups.
108
- func (m * wtClientClient ) AddTower (ctx context.Context , pubkey []byte , address string ) error {
111
+ func (m * wtClientClient ) AddTower (ctx context.Context , pubkey []byte ,
112
+ address string ) error {
113
+
109
114
rpcCtx , cancel := context .WithTimeout (ctx , m .timeout )
110
115
defer cancel ()
111
116
@@ -126,14 +131,18 @@ func (m *wtClientClient) AddTower(ctx context.Context, pubkey []byte, address st
126
131
// DeactivateTower sets the given tower's status to inactive so that it
127
132
// is not considered for session negotiation. Its sessions will also not
128
133
// be used while the tower is inactive.
129
- func (m * wtClientClient ) DeactivateTower (ctx context.Context , pubkey []byte ) (string , error ) {
134
+ func (m * wtClientClient ) DeactivateTower (ctx context.Context , pubkey []byte ) (
135
+ string , error ) {
136
+
130
137
rpcCtx , cancel := context .WithTimeout (ctx , m .timeout )
131
138
defer cancel ()
132
139
133
140
rpcCtx = m .wtClientMac .WithMacaroonAuth (rpcCtx )
134
- resp , err := m .client .DeactivateTower (rpcCtx , & wtclientrpc.DeactivateTowerRequest {
135
- Pubkey : pubkey ,
136
- })
141
+ resp , err := m .client .DeactivateTower (rpcCtx ,
142
+ & wtclientrpc.DeactivateTowerRequest {
143
+ Pubkey : pubkey ,
144
+ },
145
+ )
137
146
if err != nil {
138
147
return "" , err
139
148
}
@@ -142,11 +151,11 @@ func (m *wtClientClient) DeactivateTower(ctx context.Context, pubkey []byte) (st
142
151
}
143
152
144
153
// GetTowerInfo gets information about a watchtower that corresponds to the
145
- // given pubkey. The `includeSessions` flag controls whether session information is
146
- // included. The `excludeExhaustedSessions` controls whether exhausted sessions
147
- // are included in the response.
148
- func (m * wtClientClient ) GetTowerInfo (ctx context.Context , pubkey []byte , includeSessions ,
149
- excludeExhaustedSessions bool ) (* wtclientrpc.Tower , error ) {
154
+ // given pubkey. The `includeSessions` flag controls whether session information
155
+ // is included. The `excludeExhaustedSessions` controls whether exhausted
156
+ // sessions are included in the response.
157
+ func (m * wtClientClient ) GetTowerInfo (ctx context.Context , pubkey []byte ,
158
+ includeSessions , excludeExhaustedSessions bool ) (* wtclientrpc.Tower , error ) {
150
159
151
160
rpcCtx , cancel := context .WithTimeout (ctx , m .timeout )
152
161
defer cancel ()
@@ -165,8 +174,8 @@ func (m *wtClientClient) GetTowerInfo(ctx context.Context, pubkey []byte, includ
165
174
}
166
175
167
176
// ListTowers gets information about all registered watchtowers. The
168
- // `includeSessions` and `excludeExhaustedSessions` flags serve the same function as
169
- // in the `GetTowerInfo` method.
177
+ // `includeSessions` and `excludeExhaustedSessions` flags serve the same
178
+ // function as in the `GetTowerInfo` method.
170
179
func (m * wtClientClient ) ListTowers (ctx context.Context , includeSessions ,
171
180
excludeExhaustedSessions bool ) ([]* wtclientrpc.Tower , error ) {
172
181
@@ -186,7 +195,9 @@ func (m *wtClientClient) ListTowers(ctx context.Context, includeSessions,
186
195
}
187
196
188
197
// Policy returns the active watchtower client policy configuration.
189
- func (m * wtClientClient ) Policy (ctx context.Context , policyType wtclientrpc.PolicyType ) (* PolicyResponse , error ) {
198
+ func (m * wtClientClient ) Policy (ctx context.Context ,
199
+ policyType wtclientrpc.PolicyType ) (* PolicyResponse , error ) {
200
+
190
201
rpcCtx , cancel := context .WithTimeout (ctx , m .timeout )
191
202
defer cancel ()
192
203
@@ -208,7 +219,9 @@ func (m *wtClientClient) Policy(ctx context.Context, policyType wtclientrpc.Poli
208
219
// negotiations and from being used for any subsequent backups until it's added
209
220
// again. If an address is provided, then this RPC only serves as a way of
210
221
// removing the address from the watchtower instead.
211
- func (m * wtClientClient ) RemoveTower (ctx context.Context , pubkey []byte , address string ) error {
222
+ func (m * wtClientClient ) RemoveTower (ctx context.Context , pubkey []byte ,
223
+ address string ) error {
224
+
212
225
rpcCtx , cancel := context .WithTimeout (ctx , m .timeout )
213
226
defer cancel ()
214
227
@@ -246,14 +259,18 @@ func (m *wtClientClient) Stats(ctx context.Context) (*StatsResponse, error) {
246
259
247
260
// Terminates the given session and marks it to not be used for backups
248
261
// anymore. Returns a human readable status string.
249
- func (m * wtClientClient ) TerminateSession (ctx context.Context , sessionId []byte ) (string , error ) {
262
+ func (m * wtClientClient ) TerminateSession (ctx context.Context ,
263
+ sessionId []byte ) (string , error ) {
264
+
250
265
rpcCtx , cancel := context .WithTimeout (ctx , m .timeout )
251
266
defer cancel ()
252
267
253
268
rpcCtx = m .wtClientMac .WithMacaroonAuth (rpcCtx )
254
- resp , err := m .client .TerminateSession (rpcCtx , & wtclientrpc.TerminateSessionRequest {
255
- SessionId : sessionId ,
256
- })
269
+ resp , err := m .client .TerminateSession (rpcCtx ,
270
+ & wtclientrpc.TerminateSessionRequest {
271
+ SessionId : sessionId ,
272
+ },
273
+ )
257
274
if err != nil {
258
275
return "" , err
259
276
}
0 commit comments