Merge pull request #3195 from halseth/routeing-nil-copy-pubkey
routing+zpay32: copy pubkeys before nilling Curve and spewing
This commit is contained in:
commit
5f4accd39f
@ -1505,9 +1505,11 @@ func generateSphinxPacket(rt *route.Route, paymentHash []byte,
|
|||||||
|
|
||||||
log.Tracef("Constructed per-hop payloads for payment_hash=%x: %v",
|
log.Tracef("Constructed per-hop payloads for payment_hash=%x: %v",
|
||||||
paymentHash[:], newLogClosure(func() string {
|
paymentHash[:], newLogClosure(func() string {
|
||||||
path := sphinxPath[:sphinxPath.TrueRouteLength()]
|
path := make([]sphinx.OnionHop, sphinxPath.TrueRouteLength())
|
||||||
for i := range path {
|
for i := range path {
|
||||||
path[i].NodePub.Curve = nil
|
hopCopy := sphinxPath[i]
|
||||||
|
hopCopy.NodePub.Curve = nil
|
||||||
|
path[i] = hopCopy
|
||||||
}
|
}
|
||||||
return spew.Sdump(path)
|
return spew.Sdump(path)
|
||||||
}),
|
}),
|
||||||
@ -1531,10 +1533,14 @@ func generateSphinxPacket(rt *route.Route, paymentHash []byte,
|
|||||||
|
|
||||||
log.Tracef("Generated sphinx packet: %v",
|
log.Tracef("Generated sphinx packet: %v",
|
||||||
newLogClosure(func() string {
|
newLogClosure(func() string {
|
||||||
// We unset the internal curve here in order to keep
|
// We make a copy of the ephemeral key and unset the
|
||||||
// the logs from getting noisy.
|
// internal curve here in order to keep the logs from
|
||||||
sphinxPacket.EphemeralKey.Curve = nil
|
// getting noisy.
|
||||||
return spew.Sdump(sphinxPacket)
|
key := *sphinxPacket.EphemeralKey
|
||||||
|
key.Curve = nil
|
||||||
|
packetCopy := *sphinxPacket
|
||||||
|
packetCopy.EphemeralKey = &key
|
||||||
|
return spew.Sdump(packetCopy)
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -1759,12 +1765,21 @@ func (r *ChannelRouter) sendPayment(
|
|||||||
|
|
||||||
log.Tracef("Dispatching route for lightning payment: %v",
|
log.Tracef("Dispatching route for lightning payment: %v",
|
||||||
newLogClosure(func() string {
|
newLogClosure(func() string {
|
||||||
|
// Make a copy of the payment with a nilled Curve
|
||||||
|
// before spewing.
|
||||||
|
var routeHints [][]zpay32.HopHint
|
||||||
for _, routeHint := range payment.RouteHints {
|
for _, routeHint := range payment.RouteHints {
|
||||||
|
var hopHints []zpay32.HopHint
|
||||||
for _, hopHint := range routeHint {
|
for _, hopHint := range routeHint {
|
||||||
hopHint.NodeID.Curve = nil
|
h := hopHint.Copy()
|
||||||
|
h.NodeID.Curve = nil
|
||||||
|
hopHints = append(hopHints, h)
|
||||||
}
|
}
|
||||||
|
routeHints = append(routeHints, hopHints)
|
||||||
}
|
}
|
||||||
return spew.Sdump(payment)
|
p := *payment
|
||||||
|
p.RouteHints = routeHints
|
||||||
|
return spew.Sdump(p)
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -29,3 +29,15 @@ type HopHint struct {
|
|||||||
// CLTVExpiryDelta is the time-lock delta of the channel.
|
// CLTVExpiryDelta is the time-lock delta of the channel.
|
||||||
CLTVExpiryDelta uint16
|
CLTVExpiryDelta uint16
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Copy returns a deep copy of the hop hint.
|
||||||
|
func (h HopHint) Copy() HopHint {
|
||||||
|
nodeID := *h.NodeID
|
||||||
|
return HopHint{
|
||||||
|
NodeID: &nodeID,
|
||||||
|
ChannelID: h.ChannelID,
|
||||||
|
FeeBaseMSat: h.FeeBaseMSat,
|
||||||
|
FeeProportionalMillionths: h.FeeProportionalMillionths,
|
||||||
|
CLTVExpiryDelta: h.CLTVExpiryDelta,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user