@@ -69,7 +69,6 @@ import (
6969 "google.golang.org/grpc/test/bufconn"
7070 "google.golang.org/protobuf/encoding/protojson"
7171 "gopkg.in/macaroon-bakery.v2/bakery"
72- "gopkg.in/macaroon.v2"
7372)
7473
7574const (
@@ -433,7 +432,7 @@ func (g *LightningTerminal) start(ctx context.Context) error {
433432 superMacBaker := func (ctx context.Context , rootKeyID uint64 ,
434433 recipe * session.MacaroonRecipe ) (string , error ) {
435434
436- return BakeSuperMacaroon (
435+ return litmac . BakeSuperMacaroon (
437436 ctx , g .basicClient , rootKeyID ,
438437 recipe .Permissions , recipe .Caveats ,
439438 )
@@ -665,7 +664,7 @@ func (g *LightningTerminal) start(ctx context.Context) error {
665664
666665 rootKeyID := litmac .NewSuperMacaroonRootKeyID (suffixBytes )
667666
668- return BakeSuperMacaroon (
667+ return litmac . BakeSuperMacaroon (
669668 ctx , g .basicClient , rootKeyID ,
670669 g .permsMgr .ActivePermissions (readOnly ), nil ,
671670 )
@@ -953,7 +952,7 @@ func (g *LightningTerminal) setUpLNDClients(ctx context.Context,
953952 // Create a super macaroon that can be used to control lnd,
954953 // faraday, loop, and pool, all at the same time.
955954 log .Infof ("Baking internal super macaroon" )
956- superMacaroon , err := BakeSuperMacaroon (
955+ superMacaroon , err := litmac . BakeSuperMacaroon (
957956 ctx , g .basicClient , litmac .NewSuperMacaroonRootKeyID (
958957 [4 ]byte {},
959958 ),
@@ -1845,54 +1844,6 @@ func (g *LightningTerminal) initSubServers() error {
18451844 return nil
18461845}
18471846
1848- // BakeSuperMacaroon uses the lnd client to bake a macaroon that can include
1849- // permissions for multiple daemons.
1850- func BakeSuperMacaroon (ctx context.Context , lnd lnrpc.LightningClient ,
1851- rootKeyID uint64 , perms []bakery.Op , caveats []macaroon.Caveat ) (string ,
1852- error ) {
1853-
1854- if lnd == nil {
1855- return "" , errors .New ("lnd not yet connected" )
1856- }
1857-
1858- req := & lnrpc.BakeMacaroonRequest {
1859- Permissions : make (
1860- []* lnrpc.MacaroonPermission , len (perms ),
1861- ),
1862- AllowExternalPermissions : true ,
1863- RootKeyId : rootKeyID ,
1864- }
1865- for idx , perm := range perms {
1866- req .Permissions [idx ] = & lnrpc.MacaroonPermission {
1867- Entity : perm .Entity ,
1868- Action : perm .Action ,
1869- }
1870- }
1871-
1872- res , err := lnd .BakeMacaroon (ctx , req )
1873- if err != nil {
1874- return "" , err
1875- }
1876-
1877- mac , err := litmac .ParseMacaroon (res .Macaroon )
1878- if err != nil {
1879- return "" , err
1880- }
1881-
1882- for _ , caveat := range caveats {
1883- if err := mac .AddFirstPartyCaveat (caveat .Id ); err != nil {
1884- return "" , err
1885- }
1886- }
1887-
1888- macBytes , err := mac .MarshalBinary ()
1889- if err != nil {
1890- return "" , err
1891- }
1892-
1893- return hex .EncodeToString (macBytes ), err
1894- }
1895-
18961847// allowCORS wraps the given http.Handler with a function that adds the
18971848// Access-Control-Allow-Origin header to the response.
18981849func allowCORS (handler http.Handler , origins []string ) http.Handler {
0 commit comments