Skip to content

Commit b4f8224

Browse files
committed
multi: use ReadOnly param of BakeSuperMacaroon
1 parent a59bf27 commit b4f8224

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

cmd/litcli/proxy.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ var litCommands = []cli.Command{
3232
"specified as a hex string using a " +
3333
"maximum of 8 characters.",
3434
},
35+
cli.BoolFlag{
36+
Name: "read_only",
37+
Usage: "Whether the macaroon should " +
38+
"only contain read permissions.",
39+
},
3540
cli.StringFlag{
3641
Name: "save_to",
3742
Usage: "Save returned admin macaroon to " +
@@ -125,6 +130,7 @@ func bakeSuperMacaroon(ctx *cli.Context) error {
125130
resp, err := client.BakeSuperMacaroon(
126131
ctxb, &litrpc.BakeSuperMacaroonRequest{
127132
RootKeyIdSuffix: suffix,
133+
ReadOnly: ctx.Bool("read_only"),
128134
},
129135
)
130136
if err != nil {

rpc_proxy.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ type rpcProxy struct {
187187
}
188188

189189
// bakeSuperMac can be used to bake a new super macaroon.
190-
type bakeSuperMac func(ctx context.Context, rootKeyID uint32) (string, error)
190+
type bakeSuperMac func(ctx context.Context, rootKeyID uint32,
191+
readOnly bool) (string, error)
191192

192193
// lndBasicClientFn can be used to obtain access to an lnrpc.LightningClient if
193194
// it is available.
@@ -255,7 +256,7 @@ func (p *rpcProxy) BakeSuperMacaroon(ctx context.Context,
255256
return nil, ErrWaitingToStart
256257
}
257258

258-
superMac, err := p.bakeSuperMac(ctx, req.RootKeyIdSuffix)
259+
superMac, err := p.bakeSuperMac(ctx, req.RootKeyIdSuffix, req.ReadOnly)
259260
if err != nil {
260261
return nil, err
261262
}

terminal.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -584,8 +584,8 @@ func (g *LightningTerminal) start() error {
584584

585585
// bakeSuperMac is a closure that can be used to bake a new super
586586
// macaroon that contains all active permissions.
587-
bakeSuperMac := func(ctx context.Context, rootKeyIDSuffix uint32) (
588-
string, error) {
587+
bakeSuperMac := func(ctx context.Context, rootKeyIDSuffix uint32,
588+
readOnly bool) (string, error) {
589589

590590
var suffixBytes [4]byte
591591
binary.BigEndian.PutUint32(suffixBytes[:], rootKeyIDSuffix)
@@ -594,7 +594,7 @@ func (g *LightningTerminal) start() error {
594594

595595
return BakeSuperMacaroon(
596596
ctx, g.basicClient, rootKeyID,
597-
g.permsMgr.ActivePermissions(false), nil,
597+
g.permsMgr.ActivePermissions(readOnly), nil,
598598
)
599599
}
600600

0 commit comments

Comments
 (0)