77 "time"
88
99 "github.com/lightninglabs/lightning-terminal/accounts"
10+ litmac "github.com/lightninglabs/lightning-terminal/macaroons"
1011 "github.com/lightninglabs/lightning-terminal/session"
1112 "github.com/lightningnetwork/lnd/clock"
1213 "github.com/lightningnetwork/lnd/fn"
@@ -60,10 +61,12 @@ func TestActionStorage(t *testing.T) {
6061 acct1 , err := accountsDB .NewAccount (ctx , 0 , time.Time {}, "foo" )
6162 require .NoError (t , err )
6263
64+ sess1RootKeyID := litmac .NewSuperMacaroonRootKeyID (sess1 .ID )
65+
6366 action1Req := & AddActionReq {
6467 SessionID : fn .Some (sess1 .ID ),
6568 AccountID : fn .Some (acct1 .ID ),
66- MacaroonIdentifier : fn .Some ([ 4 ] byte ( sess1 . ID ) ),
69+ MacaroonRootKeyID : fn .Some (sess1RootKeyID ),
6770 ActorName : "Autopilot" ,
6871 FeatureName : "auto-fees" ,
6972 Trigger : "fee too low" ,
@@ -79,15 +82,17 @@ func TestActionStorage(t *testing.T) {
7982 State : ActionStateDone ,
8083 }
8184
85+ sess2RootKeyID := litmac .NewSuperMacaroonRootKeyID (sess2 .ID )
86+
8287 action2Req := & AddActionReq {
83- SessionID : fn .Some (sess2 .ID ),
84- MacaroonIdentifier : fn .Some ([ 4 ] byte ( sess2 . ID ) ),
85- ActorName : "Autopilot" ,
86- FeatureName : "rebalancer" ,
87- Trigger : "channels not balanced" ,
88- Intent : "balance" ,
89- RPCMethod : "SendToRoute" ,
90- RPCParamsJson : []byte ("hops, amount" ),
88+ SessionID : fn .Some (sess2 .ID ),
89+ MacaroonRootKeyID : fn .Some (sess2RootKeyID ),
90+ ActorName : "Autopilot" ,
91+ FeatureName : "rebalancer" ,
92+ Trigger : "channels not balanced" ,
93+ Intent : "balance" ,
94+ RPCMethod : "SendToRoute" ,
95+ RPCParamsJson : []byte ("hops, amount" ),
9196 }
9297
9398 action2 := & Action {
@@ -213,8 +218,10 @@ func TestListActions(t *testing.T) {
213218 addAction := func (sessionID [4 ]byte ) {
214219 actionIds ++
215220
221+ sessRootKeyID := litmac .NewSuperMacaroonRootKeyID (sessionID )
222+
216223 actionReq := & AddActionReq {
217- MacaroonIdentifier : fn .Some (sessionID ),
224+ MacaroonRootKeyID : fn .Some (sessRootKeyID ),
218225 ActorName : "Autopilot" ,
219226 FeatureName : fmt .Sprintf ("%d" , actionIds ),
220227 Trigger : "fee too low" ,
@@ -236,11 +243,9 @@ func TestListActions(t *testing.T) {
236243 assertActions := func (dbActions []* Action , al []* action ) {
237244 require .Len (t , dbActions , len (al ))
238245 for i , a := range al {
239- mID , err := dbActions [ i ]. MacaroonIdentifier . UnwrapOrErr (
240- fmt . Errorf ( "macaroon identifier is none" ),
246+ require . EqualValues (
247+ t , a . sessionID , dbActions [ i ]. MacaroonId ( ),
241248 )
242- require .NoError (t , err )
243- require .EqualValues (t , a .sessionID , mID )
244249 require .Equal (t , a .actionID , dbActions [i ].FeatureName )
245250 }
246251 }
@@ -424,9 +429,11 @@ func TestListGroupActions(t *testing.T) {
424429 )
425430 require .NoError (t , err )
426431
432+ sess1RootKeyID := litmac .NewSuperMacaroonRootKeyID (sess1 .ID )
433+
427434 action1Req := & AddActionReq {
428435 SessionID : fn .Some (sess1 .ID ),
429- MacaroonIdentifier : fn .Some ([ 4 ] byte ( sess1 . ID ) ),
436+ MacaroonRootKeyID : fn .Some (sess1RootKeyID ),
430437 ActorName : "Autopilot" ,
431438 FeatureName : "auto-fees" ,
432439 Trigger : "fee too low" ,
@@ -442,15 +449,17 @@ func TestListGroupActions(t *testing.T) {
442449 State : ActionStateDone ,
443450 }
444451
452+ sess2RootKeyID := litmac .NewSuperMacaroonRootKeyID (sess2 .ID )
453+
445454 action2Req := & AddActionReq {
446- SessionID : fn .Some (sess2 .ID ),
447- MacaroonIdentifier : fn .Some ([ 4 ] byte ( sess2 . ID ) ),
448- ActorName : "Autopilot" ,
449- FeatureName : "rebalancer" ,
450- Trigger : "channels not balanced" ,
451- Intent : "balance" ,
452- RPCMethod : "SendToRoute" ,
453- RPCParamsJson : []byte ("hops, amount" ),
455+ SessionID : fn .Some (sess2 .ID ),
456+ MacaroonRootKeyID : fn .Some (sess2RootKeyID ),
457+ ActorName : "Autopilot" ,
458+ FeatureName : "rebalancer" ,
459+ Trigger : "channels not balanced" ,
460+ Intent : "balance" ,
461+ RPCMethod : "SendToRoute" ,
462+ RPCParamsJson : []byte ("hops, amount" ),
454463 }
455464
456465 action2 := & Action {
0 commit comments