mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-12-10 04:43:33 +01: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:
@@ -862,7 +862,7 @@ type LightningPayment struct {
|
||||
// PaymentAddr is the payment address specified by the receiver. This
|
||||
// field should be a random 32-byte nonce presented in the receiver's
|
||||
// invoice to prevent probing of the destination.
|
||||
PaymentAddr *[32]byte
|
||||
PaymentAddr fn.Option[[32]byte]
|
||||
|
||||
// PaymentRequest is an optional payment request that this payment is
|
||||
// attempting to complete.
|
||||
@@ -1063,9 +1063,10 @@ func (r *ChannelRouter) PreparePayment(payment *LightningPayment) (
|
||||
switch {
|
||||
// If this is an AMP payment, we'll use the AMP shard tracker.
|
||||
case payment.amp != nil:
|
||||
addr := payment.PaymentAddr.UnwrapOr([32]byte{})
|
||||
shardTracker = amp.NewShardTracker(
|
||||
payment.amp.RootShare, payment.amp.SetID,
|
||||
*payment.PaymentAddr, payment.Amount,
|
||||
payment.amp.RootShare, payment.amp.SetID, addr,
|
||||
payment.Amount,
|
||||
)
|
||||
|
||||
// Otherwise we'll use the simple tracker that will map each attempt to
|
||||
@@ -1367,8 +1368,8 @@ func (e ErrNoChannel) Error() string {
|
||||
// outgoing channel, use the outgoingChan parameter.
|
||||
func (r *ChannelRouter) BuildRoute(amt fn.Option[lnwire.MilliSatoshi],
|
||||
hops []route.Vertex, outgoingChan *uint64, finalCltvDelta int32,
|
||||
payAddr *[32]byte, firstHopBlob fn.Option[[]byte]) (*route.Route,
|
||||
error) {
|
||||
payAddr fn.Option[[32]byte], firstHopBlob fn.Option[[]byte]) (
|
||||
*route.Route, error) {
|
||||
|
||||
log.Tracef("BuildRoute called: hopsCount=%v, amt=%v", len(hops), amt)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user