mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-20 21:30:06 +02:00
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:
committed by
Oliver Gugger
parent
7857f38f45
commit
d2c745e610
@@ -16,6 +16,7 @@ import (
|
||||
sphinx "github.com/lightningnetwork/lightning-onion"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/feature"
|
||||
"github.com/lightningnetwork/lnd/fn"
|
||||
"github.com/lightningnetwork/lnd/htlcswitch"
|
||||
"github.com/lightningnetwork/lnd/lnrpc"
|
||||
"github.com/lightningnetwork/lnd/lntypes"
|
||||
@@ -1011,7 +1012,7 @@ func (r *RouterBackend) extractIntentFromSendRequest(
|
||||
if len(rpcPayReq.PaymentAddr) > 0 {
|
||||
var addr [32]byte
|
||||
copy(addr[:], rpcPayReq.PaymentAddr)
|
||||
payAddr = &addr
|
||||
payAddr = fn.Some(addr)
|
||||
}
|
||||
} else {
|
||||
err = payIntent.SetPaymentHash(*payReq.PaymentHash)
|
||||
@@ -1128,7 +1129,7 @@ func (r *RouterBackend) extractIntentFromSendRequest(
|
||||
} else {
|
||||
copy(payAddr[:], rpcPayReq.PaymentAddr)
|
||||
}
|
||||
payIntent.PaymentAddr = &payAddr
|
||||
payIntent.PaymentAddr = fn.Some(payAddr)
|
||||
|
||||
// Generate random SetID and root share.
|
||||
var setID [32]byte
|
||||
@@ -1167,7 +1168,7 @@ func (r *RouterBackend) extractIntentFromSendRequest(
|
||||
var payAddr [32]byte
|
||||
copy(payAddr[:], rpcPayReq.PaymentAddr)
|
||||
|
||||
payIntent.PaymentAddr = &payAddr
|
||||
payIntent.PaymentAddr = fn.Some(payAddr)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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