multi: update PaymentAddr to use fn.Option
Since it is allowed to not be set and so can lead to nil deref panics if it is a pointer.
This commit is contained in:
14 files changed
+87
-70
No files matched your search
@@ -528,11 +528,16 @@ func (s *Server) probePaymentRequest(ctx context.Context, paymentRequest string,
|
||||
AmtMsat: amtMsat,
|
||||
PaymentHash: paymentHash[:],
|
||||
FeeLimitSat: routeFeeLimitSat,
|
||||
PaymentAddr: payReq.PaymentAddr[:],
|
||||
FinalCltvDelta: int32(payReq.MinFinalCLTVExpiry()),
|
||||
DestFeatures: MarshalFeatures(payReq.Features),
|
||||
}
|
||||
|
||||
// If the payment addresses is specified, then we'll also populate that
|
||||
// now as well.
|
||||
payReq.PaymentAddr.WhenSome(func(addr [32]byte) {
|
||||
copy(probeRequest.PaymentAddr, addr[:])
|
||||
})
|
||||
|
||||
hints := payReq.RouteHints
|
||||
|
||||
// If the hints don't indicate an LSP then chances are that our probe
|
||||
@@ -1453,12 +1458,12 @@ func (s *Server) BuildRoute(_ context.Context,
|
||||
outgoingChan = &req.OutgoingChanId
|
||||
}
|
||||
|
||||
var payAddr *[32]byte
|
||||
var payAddr fn.Option[[32]byte]
|
||||
if len(req.PaymentAddr) != 0 {
|
||||
var backingPayAddr [32]byte
|
||||
copy(backingPayAddr[:], req.PaymentAddr)
|
||||
|
||||
payAddr = &backingPayAddr
|
||||
payAddr = fn.Some(backingPayAddr)
|
||||
}
|
||||
|
||||
if req.FinalCltvDelta == 0 {
|
||||
|
||||
Reference in new issue
Block a user