Skip to content

Commit 6ee8ade

Browse files
committed
multi: move client conn creation func to mailbox
In this commit, the MailboxRPCConnection function is renamed and moved out of the core package and into the mailbox package.
1 parent fedd257 commit 6ee8ade

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

cmd/wasm-client/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ func (w *wasmClient) ConnectServer(_ js.Value, args []js.Value) interface{} {
212212
// in another goroutine here. See https://pkg.go.dev/syscall/js#FuncOf.
213213
go func() {
214214
var err error
215-
statusChecker, lndConnect, err := core.MailboxRPCConnection(
215+
statusChecker, lndConnect, err := mailbox.NewClientWebsocketConn(
216216
mailboxServer, pairingPhrase, localPriv, remotePub,
217217
func(key *btcec.PublicKey) error {
218218
return callJsCallback(

core/lnd_conn.go renamed to mailbox/create_conn.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,41 @@
1-
package core
1+
package mailbox
22

33
import (
44
"context"
55
"strings"
66

77
"github.com/btcsuite/btcd/btcec/v2"
8-
"github.com/lightninglabs/lightning-node-connect/mailbox"
98
"github.com/lightningnetwork/lnd/keychain"
109
"google.golang.org/grpc"
1110
)
1211

13-
// MailboxRPCConnection returns a merged map of all litd's method
14-
// permissions.
15-
func MailboxRPCConnection(mailboxServer, pairingPhrase string,
12+
// NewClientWebsocketConn attempts to create websocket LNC client connection to
13+
// a server connection listening at the given mailbox server.
14+
func NewClientWebsocketConn(mailboxServer, pairingPhrase string,
1615
localStatic keychain.SingleKeyECDH, remoteStatic *btcec.PublicKey,
1716
onRemoteStatic func(key *btcec.PublicKey) error,
18-
onAuthData func(data []byte) error) (func() mailbox.ClientStatus,
17+
onAuthData func(data []byte) error) (func() ClientStatus,
1918
func() (*grpc.ClientConn, error), error) {
2019

2120
words := strings.Split(pairingPhrase, " ")
22-
var mnemonicWords [mailbox.NumPassphraseWords]string
21+
var mnemonicWords [NumPassphraseWords]string
2322
copy(mnemonicWords[:], words)
24-
entropy := mailbox.PassphraseMnemonicToEntropy(mnemonicWords)
23+
entropy := PassphraseMnemonicToEntropy(mnemonicWords)
2524

26-
connData := mailbox.NewConnData(
25+
connData := NewConnData(
2726
localStatic, remoteStatic, entropy[:], nil, onRemoteStatic,
2827
onAuthData,
2928
)
3029

3130
ctx := context.Background()
32-
transportConn, err := mailbox.NewWebsocketsClient(
31+
transportConn, err := NewWebsocketsClient(
3332
ctx, mailboxServer, connData,
3433
)
3534
if err != nil {
3635
return nil, nil, err
3736
}
3837

39-
noiseConn := mailbox.NewNoiseGrpcConn(connData)
38+
noiseConn := NewNoiseGrpcConn(connData)
4039

4140
dialOpts := []grpc.DialOption{
4241
grpc.WithContextDialer(transportConn.Dial),

mobile/mobile.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ func ConnectServer(nameSpace string, mailboxServer string, isDevServer bool,
198198
return
199199
}
200200

201-
statusChecker, lndConnect, err := core.MailboxRPCConnection(
201+
statusChecker, lndConnect, err := mailbox.NewClientWebsocketConn(
202202
mailboxServer, pairingPhrase, localPriv, remotePub,
203203
func(key *btcec.PublicKey) error {
204204
mc.mutex.Lock()

0 commit comments

Comments
 (0)