@@ -12,6 +12,7 @@ import (
12
12
"github.com/lightninglabs/lightning-terminal/accounts"
13
13
"github.com/lightninglabs/lightning-terminal/db"
14
14
"github.com/lightninglabs/lightning-terminal/db/sqlc"
15
+ "github.com/lightninglabs/lightning-terminal/db/sqlcmig6"
15
16
"github.com/lightningnetwork/lnd/clock"
16
17
"github.com/lightningnetwork/lnd/fn"
17
18
"github.com/lightningnetwork/lnd/sqldb/v2"
@@ -52,6 +53,39 @@ type SQLQueries interface {
52
53
GetAccount (ctx context.Context , id int64 ) (sqlc.Account , error )
53
54
}
54
55
56
+ // SQLMig6Queries is a subset of the sqlcmig6.Queries interface that can be used to
57
+ // interact with session related tables.
58
+ type SQLMig6Queries interface {
59
+ sqldb.BaseQuerier
60
+
61
+ GetAliasBySessionID (ctx context.Context , id int64 ) ([]byte , error )
62
+ GetSessionByID (ctx context.Context , id int64 ) (sqlcmig6.Session , error )
63
+ GetSessionsInGroup (ctx context.Context , groupID sql.NullInt64 ) ([]sqlcmig6.Session , error )
64
+ GetSessionAliasesInGroup (ctx context.Context , groupID sql.NullInt64 ) ([][]byte , error )
65
+ GetSessionByAlias (ctx context.Context , legacyID []byte ) (sqlcmig6.Session , error )
66
+ GetSessionByLocalPublicKey (ctx context.Context , localPublicKey []byte ) (sqlcmig6.Session , error )
67
+ GetSessionFeatureConfigs (ctx context.Context , sessionID int64 ) ([]sqlcmig6.SessionFeatureConfig , error )
68
+ GetSessionMacaroonCaveats (ctx context.Context , sessionID int64 ) ([]sqlcmig6.SessionMacaroonCaveat , error )
69
+ GetSessionIDByAlias (ctx context.Context , legacyID []byte ) (int64 , error )
70
+ GetSessionMacaroonPermissions (ctx context.Context , sessionID int64 ) ([]sqlcmig6.SessionMacaroonPermission , error )
71
+ GetSessionPrivacyFlags (ctx context.Context , sessionID int64 ) ([]sqlcmig6.SessionPrivacyFlag , error )
72
+ InsertSessionFeatureConfig (ctx context.Context , arg sqlcmig6.InsertSessionFeatureConfigParams ) error
73
+ SetSessionRevokedAt (ctx context.Context , arg sqlcmig6.SetSessionRevokedAtParams ) error
74
+ InsertSessionMacaroonCaveat (ctx context.Context , arg sqlcmig6.InsertSessionMacaroonCaveatParams ) error
75
+ InsertSessionMacaroonPermission (ctx context.Context , arg sqlcmig6.InsertSessionMacaroonPermissionParams ) error
76
+ InsertSessionPrivacyFlag (ctx context.Context , arg sqlcmig6.InsertSessionPrivacyFlagParams ) error
77
+ InsertSession (ctx context.Context , arg sqlcmig6.InsertSessionParams ) (int64 , error )
78
+ ListSessions (ctx context.Context ) ([]sqlcmig6.Session , error )
79
+ ListSessionsByType (ctx context.Context , sessionType int16 ) ([]sqlcmig6.Session , error )
80
+ ListSessionsByState (ctx context.Context , state int16 ) ([]sqlcmig6.Session , error )
81
+ SetSessionRemotePublicKey (ctx context.Context , arg sqlcmig6.SetSessionRemotePublicKeyParams ) error
82
+ SetSessionGroupID (ctx context.Context , arg sqlcmig6.SetSessionGroupIDParams ) error
83
+ UpdateSessionState (ctx context.Context , arg sqlcmig6.UpdateSessionStateParams ) error
84
+ DeleteSessionsWithState (ctx context.Context , state int16 ) error
85
+ GetAccountIDByAlias (ctx context.Context , alias int64 ) (int64 , error )
86
+ GetAccount (ctx context.Context , id int64 ) (sqlcmig6.Account , error )
87
+ }
88
+
55
89
var _ Store = (* SQLStore )(nil )
56
90
57
91
// BatchedSQLQueries combines the SQLQueries interface with the BatchedTx
@@ -95,6 +129,26 @@ func NewSQLQueriesExecutor(baseDB *sqldb.BaseDB,
95
129
}
96
130
}
97
131
132
+ type SQLMig6QueriesExecutor [T sqldb.BaseQuerier ] struct {
133
+ * sqldb.TransactionExecutor [T ]
134
+
135
+ SQLMig6Queries
136
+ }
137
+
138
+ func NewSQLMig6QueriesExecutor (baseDB * sqldb.BaseDB ,
139
+ queries * sqlcmig6.Queries ) * SQLMig6QueriesExecutor [SQLMig6Queries ] {
140
+
141
+ executor := sqldb .NewTransactionExecutor (
142
+ baseDB , func (tx * sql.Tx ) SQLMig6Queries {
143
+ return queries .WithTx (tx )
144
+ },
145
+ )
146
+ return & SQLMig6QueriesExecutor [SQLMig6Queries ]{
147
+ TransactionExecutor : executor ,
148
+ SQLMig6Queries : queries ,
149
+ }
150
+ }
151
+
98
152
// NewSQLStore creates a new SQLStore instance given an open BatchedSQLQueries
99
153
// storage backend.
100
154
func NewSQLStore (sqlDB * sqldb.BaseDB , queries * sqlc.Queries ,
0 commit comments