From 4d0601c6487c5b5e25c64e296442b0ead837989b Mon Sep 17 00:00:00 2001 From: Bjarne Magnussen Date: Tue, 22 Jun 2021 10:58:13 +0200 Subject: [PATCH] lnd: only set payment address if not empty in PaymentRequest --- rpcserver.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rpcserver.go b/rpcserver.go index ca8bd5f6..3c667223 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -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