lnrpc: ensure parsing of the Amp flag for payments is consistent

In this commit, we fix an inconsistent in the API related to AMP
payments. When a payment request isn't specified, we require the `--amp`
flag on the CLI to make an AMP payment. However, for payment requests,
we don't require this flag. To fix this inconsistency, we now require
the `--amp` flag to _also_ be set for payment requests.
This commit is contained in:
Olaoluwa Osuntokun committed 2024-04-25 16:16:16 -07:00
1 parent ab2f34e13b
commit e8031fdccf
4 files changed
+52 -3

No files matched your search

+8
View File
@@ -940,6 +940,14 @@ func (r *RouterBackend) extractIntentFromSendRequest(
payAddr := payReq.PaymentAddr
if payReq.Features.HasFeature(lnwire.AMPOptional) {
// The opt-in AMP flag is required to pay an AMP
// invoice.
if !rpcPayReq.Amp {
return nil, fmt.Errorf("the AMP flag (--amp " +
"or SendPaymentRequest.Amp) must be " +
"set to pay an AMP invoice")
}
// Generate random SetID and root share.
var setID [32]byte
_, err = rand.Read(setID[:])