|
1 |
| -package core |
| 1 | +package mailbox |
2 | 2 |
|
3 | 3 | import (
|
4 | 4 | "context"
|
5 | 5 | "strings"
|
6 | 6 |
|
7 | 7 | "github.com/btcsuite/btcd/btcec/v2"
|
8 |
| - "github.com/lightninglabs/lightning-node-connect/mailbox" |
9 | 8 | "github.com/lightningnetwork/lnd/keychain"
|
10 | 9 | "google.golang.org/grpc"
|
11 | 10 | )
|
12 | 11 |
|
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, |
16 | 15 | localStatic keychain.SingleKeyECDH, remoteStatic *btcec.PublicKey,
|
17 | 16 | onRemoteStatic func(key *btcec.PublicKey) error,
|
18 |
| - onAuthData func(data []byte) error) (func() mailbox.ClientStatus, |
| 17 | + onAuthData func(data []byte) error) (func() ClientStatus, |
19 | 18 | func() (*grpc.ClientConn, error), error) {
|
20 | 19 |
|
21 | 20 | words := strings.Split(pairingPhrase, " ")
|
22 |
| - var mnemonicWords [mailbox.NumPassphraseWords]string |
| 21 | + |
| 22 | + var mnemonicWords [NumPassphraseWords]string |
23 | 23 | copy(mnemonicWords[:], words)
|
24 |
| - entropy := mailbox.PassphraseMnemonicToEntropy(mnemonicWords) |
| 24 | + entropy := PassphraseMnemonicToEntropy(mnemonicWords) |
25 | 25 |
|
26 |
| - connData := mailbox.NewConnData( |
| 26 | + connData := NewConnData( |
27 | 27 | localStatic, remoteStatic, entropy[:], nil, onRemoteStatic,
|
28 | 28 | onAuthData,
|
29 | 29 | )
|
30 | 30 |
|
31 | 31 | ctx := context.Background()
|
32 |
| - transportConn, err := mailbox.NewWebsocketsClient( |
| 32 | + transportConn, err := NewWebsocketsClient( |
33 | 33 | ctx, mailboxServer, connData,
|
34 | 34 | )
|
35 | 35 | if err != nil {
|
36 | 36 | return nil, nil, err
|
37 | 37 | }
|
38 | 38 |
|
39 |
| - noiseConn := mailbox.NewNoiseGrpcConn(connData) |
| 39 | + noiseConn := NewNoiseGrpcConn(connData) |
40 | 40 |
|
41 | 41 | dialOpts := []grpc.DialOption{
|
42 | 42 | grpc.WithContextDialer(transportConn.Dial),
|
|
0 commit comments