@@ -18,23 +18,12 @@ import (
1818 "github.com/btcsuite/btcd/btcec/v2"
1919 "github.com/golang/protobuf/proto"
2020 "github.com/jessevdk/go-flags"
21- "github.com/lightninglabs/faraday/frdrpc"
22- "github.com/lightninglabs/lightning-node-connect/core"
2321 "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 "
2624 "github.com/lightningnetwork/lnd/build"
2725 "github.com/lightningnetwork/lnd/keychain"
2826 "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"
3827 "github.com/lightningnetwork/lnd/macaroons"
3928 "github.com/lightningnetwork/lnd/signal"
4029 "google.golang.org/grpc"
@@ -43,28 +32,8 @@ import (
4332 "gopkg.in/macaroon.v2"
4433)
4534
46- type stubPackageRegistration func (map [string ]func (context.Context ,
47- * grpc.ClientConn , string , func (string , error )))
48-
4935var (
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
6837
6938 jsonCBRegex = regexp .MustCompile ("(\\ w+)\\ .(\\ w+)\\ .(\\ w+)" )
7039)
@@ -123,7 +92,7 @@ func main() {
12392 callbacks .Set ("wasmClientIsCustom" , js .FuncOf (wc .IsCustom ))
12493 js .Global ().Set (cfg .NameSpace , callbacks )
12594
126- for _ , registration := range registrations {
95+ for _ , registration := range litclient . Registrations {
12796 registration (wc .registry )
12897 }
12998
@@ -399,7 +368,7 @@ func (w *wasmClient) HasPermissions(_ js.Value, args []js.Value) interface{} {
399368 // first `/` back to a `.` and then we prepend the result with a `/`.
400369 uri := jsonCBRegex .ReplaceAllString (args [0 ].String (), "/$1.$2/$3" )
401370
402- ops , ok := perms [ uri ]
371+ ops , ok := permsMgr . URIPermissions ( uri )
403372 if ! ok {
404373 log .Errorf ("uri %s not found in known permissions list" , uri )
405374 return js .ValueOf (false )
@@ -596,3 +565,11 @@ func exit(err error) {
596565 fmt .Printf ("Error running wasm client: %v\n " , err )
597566 os .Exit (1 )
598567}
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