mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-19 01:43:50 +01:00
Setting exchange rate after CreateInvoice call to take into account what API has returned
This commit is contained in:
parent
597e2b0ec1
commit
b333aeb450
@ -97,6 +97,15 @@ namespace BTCPayServer.Payments.Lightning
|
|||||||
var request = new CreateInvoiceParams(new LightMoney(due, LightMoneyUnit.BTC), description, expiry);
|
var request = new CreateInvoiceParams(new LightMoney(due, LightMoneyUnit.BTC), description, expiry);
|
||||||
request.PrivateRouteHints = storeBlob.LightningPrivateRouteHints;
|
request.PrivateRouteHints = storeBlob.LightningPrivateRouteHints;
|
||||||
lightningInvoice = await client.CreateInvoice(request, cts.Token);
|
lightningInvoice = await client.CreateInvoice(request, cts.Token);
|
||||||
|
|
||||||
|
// Only apply Rate on non BTC invoices
|
||||||
|
// if API due is larger, otherwise it will mask problems with exchange rate
|
||||||
|
if (invoice.Currency != "BTC")
|
||||||
|
{
|
||||||
|
var apiDue = lightningInvoice.Amount.ToUnit(LightMoneyUnit.BTC);
|
||||||
|
if (apiDue > due)
|
||||||
|
paymentMethod.Rate = invoice.MinimumNetDue / apiDue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (OperationCanceledException) when (cts.IsCancellationRequested)
|
catch (OperationCanceledException) when (cts.IsCancellationRequested)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user