mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-26 06:57:34 +02:00
lnrpc: allow payment addr override for AMP invoices
This permits an AMP invoice to be "pseudo-reusable", where the invoice paramters can be used multiple times so long as a new payment address is supplied. This prevents additional round trips between payer and payee to obtain a new invoice, even though the payments/invoices won't be logically associated via the RPC interface like they would when the full reusable invoices are deployed.
This commit is contained in:
@@ -710,6 +710,7 @@ func (r *RouterBackend) extractIntentFromSendRequest(
|
||||
payIntent.MaxParts = 1
|
||||
}
|
||||
|
||||
payAddr := payReq.PaymentAddr
|
||||
if payReq.Features.HasFeature(lnwire.AMPOptional) {
|
||||
// Generate random SetID and root share.
|
||||
var setID [32]byte
|
||||
@@ -730,6 +731,17 @@ func (r *RouterBackend) extractIntentFromSendRequest(
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// For AMP invoices, we'll allow users to override the
|
||||
// included payment addr to allow the invoice to be
|
||||
// pseudo-reusable, e.g. the invoice parameters are
|
||||
// reused (amt, cltv, hop hints, etc) even though the
|
||||
// payments will share different payment hashes.
|
||||
if len(rpcPayReq.PaymentAddr) > 0 {
|
||||
var addr [32]byte
|
||||
copy(addr[:], rpcPayReq.PaymentAddr)
|
||||
payAddr = &addr
|
||||
}
|
||||
} else {
|
||||
err = payIntent.SetPaymentHash(*payReq.PaymentHash)
|
||||
if err != nil {
|
||||
@@ -745,7 +757,7 @@ func (r *RouterBackend) extractIntentFromSendRequest(
|
||||
payIntent.RouteHints, payReq.RouteHints...,
|
||||
)
|
||||
payIntent.DestFeatures = payReq.Features
|
||||
payIntent.PaymentAddr = payReq.PaymentAddr
|
||||
payIntent.PaymentAddr = payAddr
|
||||
payIntent.PaymentRequest = []byte(rpcPayReq.PaymentRequest)
|
||||
} else {
|
||||
// Otherwise, If the payment request field was not specified
|
||||
|
Reference in New Issue
Block a user