@@ -157,6 +157,8 @@ type rpcProxy struct {
157
157
permsMgr * perms.Manager
158
158
subServerMgr * subservers.Manager
159
159
160
+ bakeSuperMac bakeSuperMac
161
+
160
162
macValidator macaroons.MacaroonValidator
161
163
superMacValidator session.SuperMacaroonValidator
162
164
@@ -168,9 +170,15 @@ type rpcProxy struct {
168
170
grpcWebProxy * grpcweb.WrappedGrpcServer
169
171
}
170
172
173
+ // bakeSuperMac can be used to bake a new super macaroon.
174
+ type bakeSuperMac func (ctx context.Context , rootKeyID uint32 ) (string , error )
175
+
171
176
// Start creates initial connection to lnd.
172
- func (p * rpcProxy ) Start (lndConn * grpc.ClientConn ) error {
177
+ func (p * rpcProxy ) Start (lndConn * grpc.ClientConn ,
178
+ bakeSuperMac bakeSuperMac ) error {
179
+
173
180
p .lndConn = lndConn
181
+ p .bakeSuperMac = bakeSuperMac
174
182
175
183
atomic .CompareAndSwapInt32 (& p .started , 0 , 1 )
176
184
@@ -215,6 +223,28 @@ func (p *rpcProxy) GetInfo(_ context.Context, _ *litrpc.GetInfoRequest) (
215
223
}, nil
216
224
}
217
225
226
+ // BakeSuperMacaroon bakes a new macaroon that includes permissions for
227
+ // all the active daemons that LiT is connected to.
228
+ //
229
+ // NOTE: this is part of the litrpc.ProxyServiceServer interface.
230
+ func (p * rpcProxy ) BakeSuperMacaroon (ctx context.Context ,
231
+ req * litrpc.BakeSuperMacaroonRequest ) (
232
+ * litrpc.BakeSuperMacaroonResponse , error ) {
233
+
234
+ if ! p .hasStarted () {
235
+ return nil , ErrWaitingToStart
236
+ }
237
+
238
+ superMac , err := p .bakeSuperMac (ctx , req .RootKeyIdSuffix )
239
+ if err != nil {
240
+ return nil , err
241
+ }
242
+
243
+ return & litrpc.BakeSuperMacaroonResponse {
244
+ Macaroon : superMac ,
245
+ }, nil
246
+ }
247
+
218
248
// isHandling checks if the specified request is something to be handled by lnd
219
249
// or any of the attached sub daemons. If true is returned, the call was handled
220
250
// by the RPC proxy and the caller MUST NOT handle it again. If false is
0 commit comments