test: extract the identity pubkey of running lnd nodes into the lightningNode struct
This commit is contained in:
parent
301a9fea38
commit
d9c0e6653f
@ -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
|
||||
}
|
||||
|
||||
|
22
rpcserver.go
22
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[:],
|
||||
|
Loading…
Reference in New Issue
Block a user