routing+zpay32: copy pubkeys before nilling Curve and spewing

Since nilling the pubkey curve will lead to a nil-pointer exception if
the key is later used for signature verification, we make sure to make a
copy before nilling and spewing.
This commit is contained in:
Johan T. Halseth
2019-06-12 12:19:43 +02:00
parent 00a86696a8
commit 386f8ece54
2 changed files with 35 additions and 8 deletions

View File

@@ -29,3 +29,15 @@ type HopHint struct {
// CLTVExpiryDelta is the time-lock delta of the channel.
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,
}
}