@@ -18,23 +18,12 @@ import (
18
18
"github.com/btcsuite/btcd/btcec/v2"
19
19
"github.com/golang/protobuf/proto"
20
20
"github.com/jessevdk/go-flags"
21
- "github.com/lightninglabs/faraday/frdrpc"
22
- "github.com/lightninglabs/lightning-node-connect/core"
23
21
"github.com/lightninglabs/lightning-node-connect/mailbox"
24
- "github.com/lightninglabs/loop/looprpc "
25
- "github.com/lightninglabs/pool/poolrpc "
22
+ "github.com/lightninglabs/lightning-terminal/litclient "
23
+ "github.com/lightninglabs/lightning-terminal/perms "
26
24
"github.com/lightningnetwork/lnd/build"
27
25
"github.com/lightningnetwork/lnd/keychain"
28
26
"github.com/lightningnetwork/lnd/lnrpc"
29
- "github.com/lightningnetwork/lnd/lnrpc/autopilotrpc"
30
- "github.com/lightningnetwork/lnd/lnrpc/chainrpc"
31
- "github.com/lightningnetwork/lnd/lnrpc/invoicesrpc"
32
- "github.com/lightningnetwork/lnd/lnrpc/routerrpc"
33
- "github.com/lightningnetwork/lnd/lnrpc/signrpc"
34
- "github.com/lightningnetwork/lnd/lnrpc/verrpc"
35
- "github.com/lightningnetwork/lnd/lnrpc/walletrpc"
36
- "github.com/lightningnetwork/lnd/lnrpc/watchtowerrpc"
37
- "github.com/lightningnetwork/lnd/lnrpc/wtclientrpc"
38
27
"github.com/lightningnetwork/lnd/macaroons"
39
28
"github.com/lightningnetwork/lnd/signal"
40
29
"google.golang.org/grpc"
@@ -43,28 +32,8 @@ import (
43
32
"gopkg.in/macaroon.v2"
44
33
)
45
34
46
- type stubPackageRegistration func (map [string ]func (context.Context ,
47
- * grpc.ClientConn , string , func (string , error )))
48
-
49
35
var (
50
- registrations = []stubPackageRegistration {
51
- lnrpc .RegisterLightningJSONCallbacks ,
52
- lnrpc .RegisterStateJSONCallbacks ,
53
- autopilotrpc .RegisterAutopilotJSONCallbacks ,
54
- chainrpc .RegisterChainNotifierJSONCallbacks ,
55
- invoicesrpc .RegisterInvoicesJSONCallbacks ,
56
- routerrpc .RegisterRouterJSONCallbacks ,
57
- signrpc .RegisterSignerJSONCallbacks ,
58
- verrpc .RegisterVersionerJSONCallbacks ,
59
- walletrpc .RegisterWalletKitJSONCallbacks ,
60
- watchtowerrpc .RegisterWatchtowerJSONCallbacks ,
61
- wtclientrpc .RegisterWatchtowerClientJSONCallbacks ,
62
- looprpc .RegisterSwapClientJSONCallbacks ,
63
- poolrpc .RegisterTraderJSONCallbacks ,
64
- frdrpc .RegisterFaradayServerJSONCallbacks ,
65
- }
66
-
67
- perms = core .GetAllMethodPermissions ()
36
+ permsMgr * perms.Manager
68
37
69
38
jsonCBRegex = regexp .MustCompile ("(\\ w+)\\ .(\\ w+)\\ .(\\ w+)" )
70
39
)
@@ -123,7 +92,7 @@ func main() {
123
92
callbacks .Set ("wasmClientIsCustom" , js .FuncOf (wc .IsCustom ))
124
93
js .Global ().Set (cfg .NameSpace , callbacks )
125
94
126
- for _ , registration := range registrations {
95
+ for _ , registration := range litclient . Registrations {
127
96
registration (wc .registry )
128
97
}
129
98
@@ -399,7 +368,7 @@ func (w *wasmClient) HasPermissions(_ js.Value, args []js.Value) interface{} {
399
368
// first `/` back to a `.` and then we prepend the result with a `/`.
400
369
uri := jsonCBRegex .ReplaceAllString (args [0 ].String (), "/$1.$2/$3" )
401
370
402
- ops , ok := perms [ uri ]
371
+ ops , ok := permsMgr . URIPermissions ( uri )
403
372
if ! ok {
404
373
log .Errorf ("uri %s not found in known permissions list" , uri )
405
374
return js .ValueOf (false )
@@ -596,3 +565,11 @@ func exit(err error) {
596
565
fmt .Printf ("Error running wasm client: %v\n " , err )
597
566
os .Exit (1 )
598
567
}
568
+
569
+ func init () {
570
+ var err error
571
+ permsMgr , err = perms .NewManager (true )
572
+ if err != nil {
573
+ exit (err )
574
+ }
575
+ }
0 commit comments