From d9c0e6653f377241179de766552b9e712a3c05e7 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Mon, 26 Sep 2016 10:29:18 -0700 Subject: [PATCH] test: extract the identity pubkey of running lnd nodes into the lightningNode struct --- networktest.go | 15 +++++++++++++++ rpcserver.go | 22 +++++++++++++++++++--- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/networktest.go b/networktest.go index acf60e66..206e495e 100644 --- a/networktest.go +++ b/networktest.go @@ -84,6 +84,12 @@ type lightningNode struct { // started via the start() method. 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 pidFile string @@ -192,12 +198,21 @@ func (l *lightningNode) start() error { if err != nil { return nil } + lnID, err := hex.DecodeString(info.LightningId) if err != nil { return err } 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 } diff --git a/rpcserver.go b/rpcserver.go index ad8dc939..89b83601 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -32,6 +32,7 @@ var ( ) // rpcServer is a gRPC, RPC front end to the lnd daemon. +// TODO(roasbeef): pagination support for the list-style calls type rpcServer struct { started 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 // across the network. var onionBlob bytes.Buffer - mixHeader, err := sphinx.NewOnionPacket(route, dest, + sphinxPacket, err := sphinx.NewOnionPacket(route, dest, e2eMessage) if err != nil { return nil, err } - if err := mixHeader.Encode(&onionBlob); err != nil { + if err := sphinxPacket.Encode(&onionBlob); err != nil { return nil, err } rpcsLog.Tracef("[sendpayment] generated sphinx packet: %v", 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 @@ -649,6 +653,11 @@ func (r *rpcServer) AddInvoice(ctx context.Context, } 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 { return nil, err } @@ -673,11 +682,18 @@ func (r *rpcServer) LookupInvoice(ctx context.Context, var payHash [32]byte copy(payHash[:], req.RHash) + rpcsLog.Tracef("[lookupinvoice] searching for invoice %x", payHash[:]) + invoice, err := r.server.invoices.LookupInvoice(payHash) if err != nil { return nil, err } + rpcsLog.Tracef("[lookupinvoice] located invoice %v", + newLogClosure(func() string { + return spew.Sdump(invoice) + })) + return &lnrpc.Invoice{ Memo: string(invoice.Memo[:]), Receipt: invoice.Receipt[:],