[Bug]: amount parameter not overriding BOLT11 amount when paying lightning invoices
What is your BTCPay version?
v2.2.1+790616d2a
How did you deploy BTCPay Server?
Docker on Lunanode
What happened?
amount parameter not overriding BOLT11 amount
Endpoint:
POST /api/v1/stores/{storeId}/lightning/{cryptoCode}/invoices/pay
(Reference: [BTCPay API Docs](https://docs.btcpayserver.org/API/Greenfield/v1/#operation/StoreLightningNodeApi_PayInvoice))
According to the documentation, the amount parameter in the request body should override the amount specified in the BOLT11 invoice.
However, in practice, the amount value passed in the request does not override the value encoded in the BOLT11 invoice — the payment still uses the amount embedded in the invoice.
Steps to Reproduce
- Create a BOLT11 invoice in Speed Wallet with 39,700 sats
- Send a
POSTrequest to the endpoint with a valid BOLT11 invoice and include a customamountfield, which is 29,700. - Observe that the payment is processed using the original BOLT11 invoice amount, not the amount supplied in the request.
Expected behavior:
The payment should use the amount value provided in the request payload, overriding the amount embedded in the BOLT11 invoice (as stated in the API documentation).
Actual behavior:
The payment always uses the original amount from the BOLT11 invoice, ignoring the amount parameter.
How did you encounter this bug?
- Create a BOLT11 invoice in Speed Wallet with 39700 sats
- Send a
POSTrequest to the endpoint with a valid BOLT11 invoice and include a customamountfield, which is 21700. - Observe that the payment is processed using the original BOLT11 invoice amount, not the amount supplied in the request.
Are you sure this is a bug report?
- [x] I confirm this is a bug report
Tested in postman params as seen in the screenshot below:
However, I got 39,700 instead of 29,700 as seen in the screenshot below:
@Kukks @NicolasDorier Guys, can you take a look at this one and confirm if it's expected behaviour or not?
It's expected. BOLT11 specifies a minimum amount not an optional amount. A custom amount provided in the endpoint can only be higher. We should make the api throw an error for clarity.
It's expected. BOLT11 specifies a minimum amount, not an optional amount. A custom amount provided in the endpoint can only be higher. We should make the api throw an error for clarity.
I specified the BOLT11 invoice to be less than the custom amount in the BTCPay Server endpoint, but I still get the BOLT11 invoice amount. In the screenshot below, you'll notice that the amount in the request body is 2,000,000 milisats, while in the response body for totalAmount is 1,135,568 milisats. 1,135 sats is the BOLT invoice amount. Thus, BTCPay Server does not override even when the custom amount is higher. Would you happen to know why, or have any thoughts on the matter?