Skip to content

Commit e7929d8

Browse files
committed
cmd/wasm-client: move shared code to core package
1 parent 8afcf3f commit e7929d8

File tree

7 files changed

+226
-84
lines changed

7 files changed

+226
-84
lines changed

cmd/wasm-client/go.mod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
module github.com/lightninglabs/lightning-node-connect/cmd/wasm-client
22

33
require (
4-
github.com/btcsuite/btcd/btcec/v2 v2.2.0
4+
github.com/btcsuite/btcd/btcec/v2 v2.2.1
55
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f
66
github.com/golang/protobuf v1.5.2
77
github.com/jessevdk/go-flags v1.4.0
8-
github.com/lightninglabs/faraday v0.2.7-alpha.0.20220614135954-0f761430806c
8+
github.com/lightninglabs/faraday v0.2.8-alpha.0.20220909105059-fea194ffb084
99
github.com/lightninglabs/lightning-node-connect v0.1.9-alpha.0.20220602120524-e9964c685b18
10-
github.com/lightninglabs/loop v0.19.1-beta.0.20220614171321-490fb352ffe9
11-
github.com/lightninglabs/pool v0.5.6-alpha.0.20220615075127-160ae4594f4a
12-
github.com/lightningnetwork/lnd v0.15.0-beta.rc4
10+
github.com/lightninglabs/loop v0.20.1-beta.0.20220916122221-9c3010150016
11+
github.com/lightninglabs/pool v0.5.8-alpha
12+
github.com/lightningnetwork/lnd v0.15.0-beta.rc6.0.20221005111311-2efc70a5c492
1313
google.golang.org/grpc v1.39.0
1414
gopkg.in/macaroon-bakery.v2 v2.0.1
1515
gopkg.in/macaroon.v2 v2.1.0

cmd/wasm-client/go.sum

Lines changed: 93 additions & 35 deletions
Large diffs are not rendered by default.

cmd/wasm-client/main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"github.com/golang/protobuf/proto"
2121
"github.com/jessevdk/go-flags"
2222
"github.com/lightninglabs/faraday/frdrpc"
23+
"github.com/lightninglabs/lightning-node-connect/core"
2324
"github.com/lightninglabs/lightning-node-connect/mailbox"
2425
"github.com/lightninglabs/loop/looprpc"
2526
"github.com/lightninglabs/pool/poolrpc"
@@ -63,7 +64,7 @@ var (
6364
frdrpc.RegisterFaradayServerJSONCallbacks,
6465
}
6566

66-
perms = getAllMethodPermissions()
67+
perms = core.GetAllMethodPermissions()
6768

6869
jsonCBRegex = regexp.MustCompile("(\\w+)\\.(\\w+)\\.(\\w+)")
6970
)
@@ -209,7 +210,7 @@ func (w *wasmClient) ConnectServer(_ js.Value, args []js.Value) interface{} {
209210
// in another goroutine here. See https://pkg.go.dev/syscall/js#FuncOf.
210211
go func() {
211212
var err error
212-
statusChecker, lndConnect, err := mailboxRPCConnection(
213+
statusChecker, lndConnect, err := core.MailboxRPCConnection(
213214
mailboxServer, pairingPhrase, localPriv, remotePub,
214215
func(key *btcec.PublicKey) error {
215216
return callJsCallback(

cmd/wasm-client/lnd_conn.go renamed to core/lnd_conn.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
//go:build js
2-
// +build js
3-
4-
package main
1+
package core
52

63
import (
74
"context"
@@ -13,7 +10,9 @@ import (
1310
"google.golang.org/grpc"
1411
)
1512

16-
func mailboxRPCConnection(mailboxServer, pairingPhrase string,
13+
// MailboxRPCConnection returns a merged map of all litd's method
14+
// permissions.
15+
func MailboxRPCConnection(mailboxServer, pairingPhrase string,
1716
localStatic keychain.SingleKeyECDH, remoteStatic *btcec.PublicKey,
1817
onRemoteStatic func(key *btcec.PublicKey) error,
1918
onAuthData func(data []byte) error) (func() mailbox.ClientStatus,

cmd/wasm-client/permissions.go renamed to core/permissions.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package core
22

33
import (
44
"net"
@@ -43,9 +43,9 @@ var (
4343
}
4444
)
4545

46-
// getAllMethodPermissions returns a merged map of all litd's method
47-
// permissions.
48-
func getAllMethodPermissions() map[string][]bakery.Op {
46+
// GetAllMethodPermissions returns a mailbox client status and
47+
// a function to create an lnd client connection
48+
func GetAllMethodPermissions() map[string][]bakery.Op {
4949
allPerms := make(map[string][]bakery.Op)
5050

5151
lndMainPerms := lnd.MainRPCServerPermissions()

go.mod

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
module github.com/lightninglabs/lightning-node-connect
22

33
require (
4-
github.com/btcsuite/btcd/btcec/v2 v2.2.0
4+
github.com/btcsuite/btcd/btcec/v2 v2.2.1
55
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f
66
github.com/go-errors/errors v1.0.1
7+
github.com/golang/protobuf v1.5.2
78
github.com/grpc-ecosystem/grpc-gateway/v2 v2.5.0
89
github.com/kkdai/bstream v1.0.0
9-
github.com/lightninglabs/aperture v0.1.18-beta
10+
github.com/lightninglabs/aperture v0.1.18-beta.0.20221005153455-1f35f48b1734
11+
github.com/lightninglabs/faraday v0.2.8-alpha.0.20220909105059-fea194ffb084
1012
github.com/lightninglabs/lightning-node-connect/hashmailrpc v1.0.2
11-
github.com/lightningnetwork/lnd v0.15.0-beta.rc3
13+
github.com/lightninglabs/loop v0.20.1-beta.0.20220916122221-9c3010150016
14+
github.com/lightninglabs/pool v0.5.8-alpha
15+
github.com/lightningnetwork/lnd v0.15.0-beta.rc6.0.20221005111311-2efc70a5c492
1216
github.com/lightningnetwork/lnd/ticker v1.1.0
13-
github.com/lightningnetwork/lnd/tor v1.0.0
17+
github.com/lightningnetwork/lnd/tor v1.1.0
1418
github.com/stretchr/testify v1.7.1
15-
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
19+
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3
1620
google.golang.org/grpc v1.39.0
1721
google.golang.org/protobuf v1.27.1
22+
gopkg.in/macaroon-bakery.v2 v2.0.1
23+
gopkg.in/macaroon.v2 v2.1.0
1824
nhooyr.io/websocket v1.8.7
1925
)
2026

0 commit comments

Comments
 (0)