Skip to content

Commit 162b258

Browse files
committed
lndclient: return node URIs from GetInfo call
1 parent bc07050 commit 162b258

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

lndclient/lightning_client.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ type Info struct {
4444
IdentityPubkey [33]byte
4545
Alias string
4646
Network string
47+
Uris []string
4748
}
4849

4950
var (
@@ -145,6 +146,7 @@ func (s *lightningClient) GetInfo(ctx context.Context) (*Info, error) {
145146
IdentityPubkey: pubKeyArray,
146147
Alias: resp.Alias,
147148
Network: resp.Chains[0].Network,
149+
Uris: resp.Uris,
148150
}, nil
149151
}
150152

test/lightning_client_mock.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package test
22

33
import (
44
"crypto/rand"
5+
"encoding/hex"
56
"fmt"
67
"sync"
78
"time"
@@ -48,10 +49,16 @@ func (h *mockLightningClient) ConfirmedWalletBalance(ctx context.Context) (
4849
func (h *mockLightningClient) GetInfo(ctx context.Context) (*lndclient.Info,
4950
error) {
5051

52+
pubKeyBytes, err := hex.DecodeString(h.lnd.NodePubkey)
53+
if err != nil {
54+
return nil, err
55+
}
5156
var pubKey [33]byte
57+
copy(pubKey[:], pubKeyBytes)
5258
return &lndclient.Info{
5359
BlockHeight: 600,
5460
IdentityPubkey: pubKey,
61+
Uris: []string{h.lnd.NodePubkey + "@127.0.0.1:9735"},
5562
}, nil
5663
}
5764

test/lnd_services_mock.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ import (
1414
"github.com/lightningnetwork/lnd/zpay32"
1515
)
1616

17-
var testStartingHeight = int32(600)
17+
var (
18+
testStartingHeight = int32(600)
19+
testNodePubkey = "03f5374b16f0b1f1b49101de1b9d89e0b460bc57ce9c2f9" +
20+
"132b73dfc76d3704daa"
21+
)
1822

1923
// NewMockLnd returns a new instance of LndMockServices that can be used in unit
2024
// tests.
@@ -54,6 +58,7 @@ func NewMockLnd() *LndMockServices {
5458
FailInvoiceChannel: make(chan lntypes.Hash, 2),
5559
epochChannel: make(chan int32),
5660
Height: testStartingHeight,
61+
NodePubkey: testNodePubkey,
5762
}
5863

5964
lightningClient.lnd = &lnd
@@ -120,7 +125,8 @@ type LndMockServices struct {
120125
RouterSendPaymentChannel chan RouterPaymentChannelMessage
121126
TrackPaymentChannel chan TrackPaymentMessage
122127

123-
Height int32
128+
Height int32
129+
NodePubkey string
124130

125131
WaitForFinished func()
126132

0 commit comments

Comments
 (0)