lndclient: return node URIs from GetInfo call

pull/123/head
Oliver Gugger 4 years ago
parent bc07050da2
commit 162b2589e0
No known key found for this signature in database
GPG Key ID: 8E4256593F177720

@ -44,6 +44,7 @@ type Info struct {
IdentityPubkey [33]byte IdentityPubkey [33]byte
Alias string Alias string
Network string Network string
Uris []string
} }
var ( var (
@ -145,6 +146,7 @@ func (s *lightningClient) GetInfo(ctx context.Context) (*Info, error) {
IdentityPubkey: pubKeyArray, IdentityPubkey: pubKeyArray,
Alias: resp.Alias, Alias: resp.Alias,
Network: resp.Chains[0].Network, Network: resp.Chains[0].Network,
Uris: resp.Uris,
}, nil }, nil
} }

@ -2,6 +2,7 @@ package test
import ( import (
"crypto/rand" "crypto/rand"
"encoding/hex"
"fmt" "fmt"
"sync" "sync"
"time" "time"
@ -48,10 +49,16 @@ func (h *mockLightningClient) ConfirmedWalletBalance(ctx context.Context) (
func (h *mockLightningClient) GetInfo(ctx context.Context) (*lndclient.Info, func (h *mockLightningClient) GetInfo(ctx context.Context) (*lndclient.Info,
error) { error) {
pubKeyBytes, err := hex.DecodeString(h.lnd.NodePubkey)
if err != nil {
return nil, err
}
var pubKey [33]byte var pubKey [33]byte
copy(pubKey[:], pubKeyBytes)
return &lndclient.Info{ return &lndclient.Info{
BlockHeight: 600, BlockHeight: 600,
IdentityPubkey: pubKey, IdentityPubkey: pubKey,
Uris: []string{h.lnd.NodePubkey + "@127.0.0.1:9735"},
}, nil }, nil
} }

@ -14,7 +14,11 @@ import (
"github.com/lightningnetwork/lnd/zpay32" "github.com/lightningnetwork/lnd/zpay32"
) )
var testStartingHeight = int32(600) var (
testStartingHeight = int32(600)
testNodePubkey = "03f5374b16f0b1f1b49101de1b9d89e0b460bc57ce9c2f9" +
"132b73dfc76d3704daa"
)
// NewMockLnd returns a new instance of LndMockServices that can be used in unit // NewMockLnd returns a new instance of LndMockServices that can be used in unit
// tests. // tests.
@ -54,6 +58,7 @@ func NewMockLnd() *LndMockServices {
FailInvoiceChannel: make(chan lntypes.Hash, 2), FailInvoiceChannel: make(chan lntypes.Hash, 2),
epochChannel: make(chan int32), epochChannel: make(chan int32),
Height: testStartingHeight, Height: testStartingHeight,
NodePubkey: testNodePubkey,
} }
lightningClient.lnd = &lnd lightningClient.lnd = &lnd
@ -120,7 +125,8 @@ type LndMockServices struct {
RouterSendPaymentChannel chan RouterPaymentChannelMessage RouterSendPaymentChannel chan RouterPaymentChannelMessage
TrackPaymentChannel chan TrackPaymentMessage TrackPaymentChannel chan TrackPaymentMessage
Height int32 Height int32
NodePubkey string
WaitForFinished func() WaitForFinished func()

Loading…
Cancel
Save