lnd: only set payment address if not empty in PaymentRequest

This commit is contained in:
Bjarne Magnussen 2021-06-22 10:58:13 +02:00
parent 5d29e9b099
commit 4d0601c648
No known key found for this signature in database
GPG Key ID: B0A9ADF6B24CE67F

@ -4347,10 +4347,14 @@ func (r *rpcServer) extractPaymentIntent(rpcPayReq *rpcPaymentRequest) (rpcPayme
return payIntent, errors.New("invalid payment address length")
}
if payIntent.paymentAddr == nil {
// Set the payment address if it was explicitly defined with the
// rpcPaymentRequest.
// Note that the payment address for the payIntent should be nil if none
// was provided with the rpcPaymentRequest.
if len(rpcPayReq.PaymentAddr) != 0 {
payIntent.paymentAddr = &[32]byte{}
copy(payIntent.paymentAddr[:], rpcPayReq.PaymentAddr)
}
copy(payIntent.paymentAddr[:], rpcPayReq.PaymentAddr)
// Otherwise, If the payment request field was not specified
// (and a custom route wasn't specified), construct the payment