@@ -69,7 +69,6 @@ import (
69
69
"google.golang.org/grpc/test/bufconn"
70
70
"google.golang.org/protobuf/encoding/protojson"
71
71
"gopkg.in/macaroon-bakery.v2/bakery"
72
- "gopkg.in/macaroon.v2"
73
72
)
74
73
75
74
const (
@@ -433,7 +432,7 @@ func (g *LightningTerminal) start(ctx context.Context) error {
433
432
superMacBaker := func (ctx context.Context , rootKeyID uint64 ,
434
433
recipe * session.MacaroonRecipe ) (string , error ) {
435
434
436
- return BakeSuperMacaroon (
435
+ return litmac . BakeSuperMacaroon (
437
436
ctx , g .basicClient , rootKeyID ,
438
437
recipe .Permissions , recipe .Caveats ,
439
438
)
@@ -665,7 +664,7 @@ func (g *LightningTerminal) start(ctx context.Context) error {
665
664
666
665
rootKeyID := litmac .NewSuperMacaroonRootKeyID (suffixBytes )
667
666
668
- return BakeSuperMacaroon (
667
+ return litmac . BakeSuperMacaroon (
669
668
ctx , g .basicClient , rootKeyID ,
670
669
g .permsMgr .ActivePermissions (readOnly ), nil ,
671
670
)
@@ -953,7 +952,7 @@ func (g *LightningTerminal) setUpLNDClients(ctx context.Context,
953
952
// Create a super macaroon that can be used to control lnd,
954
953
// faraday, loop, and pool, all at the same time.
955
954
log .Infof ("Baking internal super macaroon" )
956
- superMacaroon , err := BakeSuperMacaroon (
955
+ superMacaroon , err := litmac . BakeSuperMacaroon (
957
956
ctx , g .basicClient , litmac .NewSuperMacaroonRootKeyID (
958
957
[4 ]byte {},
959
958
),
@@ -1845,54 +1844,6 @@ func (g *LightningTerminal) initSubServers() error {
1845
1844
return nil
1846
1845
}
1847
1846
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
-
1896
1847
// allowCORS wraps the given http.Handler with a function that adds the
1897
1848
// Access-Control-Allow-Origin header to the response.
1898
1849
func allowCORS (handler http.Handler , origins []string ) http.Handler {
0 commit comments