|
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 | + var mnemonicWords [NumPassphraseWords]string |
23 | 22 | copy(mnemonicWords[:], words) |
24 | | - entropy := mailbox.PassphraseMnemonicToEntropy(mnemonicWords) |
| 23 | + entropy := PassphraseMnemonicToEntropy(mnemonicWords) |
25 | 24 |
|
26 | | - connData := mailbox.NewConnData( |
| 25 | + connData := NewConnData( |
27 | 26 | localStatic, remoteStatic, entropy[:], nil, onRemoteStatic, |
28 | 27 | onAuthData, |
29 | 28 | ) |
30 | 29 |
|
31 | 30 | ctx := context.Background() |
32 | | - transportConn, err := mailbox.NewWebsocketsClient( |
| 31 | + transportConn, err := NewWebsocketsClient( |
33 | 32 | ctx, mailboxServer, connData, |
34 | 33 | ) |
35 | 34 | if err != nil { |
36 | 35 | return nil, nil, err |
37 | 36 | } |
38 | 37 |
|
39 | | - noiseConn := mailbox.NewNoiseGrpcConn(connData) |
| 38 | + noiseConn := NewNoiseGrpcConn(connData) |
40 | 39 |
|
41 | 40 | dialOpts := []grpc.DialOption{ |
42 | 41 | grpc.WithContextDialer(transportConn.Dial), |
|
0 commit comments