2
0
mirror of https://github.com/lightninglabs/loop synced 2024-11-11 13:11:12 +00:00

lndclient: return node URIs from GetInfo call

This commit is contained in:
Oliver Gugger 2019-12-09 16:33:33 +01:00
parent bc07050da2
commit 162b2589e0
No known key found for this signature in database
GPG Key ID: 8E4256593F177720
3 changed files with 17 additions and 2 deletions

View File

@ -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
} }

View File

@ -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
} }

View File

@ -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
@ -121,6 +126,7 @@ type LndMockServices struct {
TrackPaymentChannel chan TrackPaymentMessage TrackPaymentChannel chan TrackPaymentMessage
Height int32 Height int32
NodePubkey string
WaitForFinished func() WaitForFinished func()