test: extract the identity pubkey of running lnd nodes into the lightningNode struct

This commit is contained in:
Olaoluwa Osuntokun 2016-09-26 10:29:18 -07:00
parent 301a9fea38
commit d9c0e6653f
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2
2 changed files with 34 additions and 3 deletions

View File

@ -84,6 +84,12 @@ type lightningNode struct {
// started via the start() method. // started via the start() method.
LightningID [32]byte LightningID [32]byte
// PubKey is the serialized compressed identity public key of the node.
// This field will only be populated once the node itself has been
// started via the start() method.
PubKey [33]byte
PubKeyStr string
cmd *exec.Cmd cmd *exec.Cmd
pidFile string pidFile string
@ -192,12 +198,21 @@ func (l *lightningNode) start() error {
if err != nil { if err != nil {
return nil return nil
} }
lnID, err := hex.DecodeString(info.LightningId) lnID, err := hex.DecodeString(info.LightningId)
if err != nil { if err != nil {
return err return err
} }
copy(l.LightningID[:], lnID) copy(l.LightningID[:], lnID)
l.PubKeyStr = info.IdentityPubkey
pubkey, err := hex.DecodeString(info.IdentityPubkey)
if err != nil {
return err
}
copy(l.PubKey[:], pubkey)
return nil return nil
} }

View File

@ -32,6 +32,7 @@ var (
) )
// rpcServer is a gRPC, RPC front end to the lnd daemon. // rpcServer is a gRPC, RPC front end to the lnd daemon.
// TODO(roasbeef): pagination support for the list-style calls
type rpcServer struct { type rpcServer struct {
started int32 // To be used atomically. started int32 // To be used atomically.
shutdown int32 // To be used atomically. shutdown int32 // To be used atomically.
@ -600,18 +601,21 @@ func generateSphinxPacket(vertexes []graph.ID) ([]byte, error) {
// us to perform privacy preserving source routing // us to perform privacy preserving source routing
// across the network. // across the network.
var onionBlob bytes.Buffer var onionBlob bytes.Buffer
mixHeader, err := sphinx.NewOnionPacket(route, dest, sphinxPacket, err := sphinx.NewOnionPacket(route, dest,
e2eMessage) e2eMessage)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if err := mixHeader.Encode(&onionBlob); err != nil { if err := sphinxPacket.Encode(&onionBlob); err != nil {
return nil, err return nil, err
} }
rpcsLog.Tracef("[sendpayment] generated sphinx packet: %v", rpcsLog.Tracef("[sendpayment] generated sphinx packet: %v",
newLogClosure(func() string { newLogClosure(func() string {
return spew.Sdump(mixHeader) // We unset the internal curve here in order to keep
// the logs from getting noisy.
sphinxPacket.Header.EphemeralKey.Curve = nil
return spew.Sdump(sphinxPacket)
})) }))
return onionBlob.Bytes(), nil return onionBlob.Bytes(), nil
@ -649,6 +653,11 @@ func (r *rpcServer) AddInvoice(ctx context.Context,
} }
copy(i.Terms.PaymentPreimage[:], preImage) copy(i.Terms.PaymentPreimage[:], preImage)
rpcsLog.Tracef("[addinvoice] adding new invoice %v",
newLogClosure(func() string {
return spew.Sdump(i)
}))
if err := r.server.invoices.AddInvoice(i); err != nil { if err := r.server.invoices.AddInvoice(i); err != nil {
return nil, err return nil, err
} }
@ -673,11 +682,18 @@ func (r *rpcServer) LookupInvoice(ctx context.Context,
var payHash [32]byte var payHash [32]byte
copy(payHash[:], req.RHash) copy(payHash[:], req.RHash)
rpcsLog.Tracef("[lookupinvoice] searching for invoice %x", payHash[:])
invoice, err := r.server.invoices.LookupInvoice(payHash) invoice, err := r.server.invoices.LookupInvoice(payHash)
if err != nil { if err != nil {
return nil, err return nil, err
} }
rpcsLog.Tracef("[lookupinvoice] located invoice %v",
newLogClosure(func() string {
return spew.Sdump(invoice)
}))
return &lnrpc.Invoice{ return &lnrpc.Invoice{
Memo: string(invoice.Memo[:]), Memo: string(invoice.Memo[:]),
Receipt: invoice.Receipt[:], Receipt: invoice.Receipt[:],