mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-19 06:54:19 +01:00
Add more details to lnaddress not found errors, make sure lnaddress is only for BTC (#3067)
* Add more details to lnaddress not found errors, make sure lnaddress is only for BTC * Update BTCPayServer/LNURL/LNURLController.cs Co-authored-by: d11n <mail@dennisreimann.de> * Update BTCPayServer/LNURL/LNURLController.cs Co-authored-by: d11n <mail@dennisreimann.de> * Update BTCPayServer/LNURL/LNURLController.cs Co-authored-by: d11n <mail@dennisreimann.de> Co-authored-by: d11n <mail@dennisreimann.de>
This commit is contained in:
@@ -3303,19 +3303,8 @@ namespace BTCPayServer.Tests
|
|||||||
}
|
}
|
||||||
else if (result.ExpectedName == "ripio")
|
else if (result.ExpectedName == "ripio")
|
||||||
{
|
{
|
||||||
// This test is strange because ripio sometimes change the pairs it supports
|
// Ripio keeps changing their pair, so anything is fine...
|
||||||
try
|
Assert.NotEmpty(exchangeRates.ByExchange[result.ExpectedName]);
|
||||||
{
|
|
||||||
Assert.Contains(exchangeRates.ByExchange[result.ExpectedName],
|
|
||||||
e => e.CurrencyPair == new CurrencyPair("BTC", "ARS") &&
|
|
||||||
e.BidAsk.Bid > 1.0m); // 1 BTC will always be more than 1 ARS
|
|
||||||
}
|
|
||||||
catch (XunitException)
|
|
||||||
{
|
|
||||||
Assert.Contains(exchangeRates.ByExchange[result.ExpectedName],
|
|
||||||
e => (e.CurrencyPair == new CurrencyPair("BTC", "USDC")
|
|
||||||
&& e.BidAsk.Bid > 1.0m)); // 1BTC will always be more than 1USD
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (result.ExpectedName == "cryptomarket")
|
else if (result.ExpectedName == "cryptomarket")
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
@@ -155,7 +155,6 @@ namespace BTCPayServer
|
|||||||
public string StoreId { get; set; }
|
public string StoreId { get; set; }
|
||||||
[Display(Name = "Invoice currency")]
|
[Display(Name = "Invoice currency")]
|
||||||
public string CurrencyCode { get; set; }
|
public string CurrencyCode { get; set; }
|
||||||
public string CryptoCode { get; set; }
|
|
||||||
|
|
||||||
[Display(Name = "Min sats")]
|
[Display(Name = "Min sats")]
|
||||||
[Range(1, double.PositiveInfinity)]
|
[Range(1, double.PositiveInfinity)]
|
||||||
@@ -185,10 +184,10 @@ namespace BTCPayServer
|
|||||||
new LightningAddressSettings();
|
new LightningAddressSettings();
|
||||||
if (!lightningAddressSettings.Items.TryGetValue(username.ToLowerInvariant(), out var item))
|
if (!lightningAddressSettings.Items.TryGetValue(username.ToLowerInvariant(), out var item))
|
||||||
{
|
{
|
||||||
return NotFound();
|
return NotFound("Unknown username");
|
||||||
}
|
}
|
||||||
|
|
||||||
return await GetLNURL(item.CryptoCode, item.StoreId, item.CurrencyCode, item.Min, item.Max,
|
return await GetLNURL("BTC", item.StoreId, item.CurrencyCode, item.Min, item.Max,
|
||||||
() => (username, null, null, true));
|
() => (username, null, null, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,13 +200,13 @@ namespace BTCPayServer
|
|||||||
var network = _btcPayNetworkProvider.GetNetwork<BTCPayNetwork>(cryptoCode);
|
var network = _btcPayNetworkProvider.GetNetwork<BTCPayNetwork>(cryptoCode);
|
||||||
if (network is null || !network.SupportLightning)
|
if (network is null || !network.SupportLightning)
|
||||||
{
|
{
|
||||||
return NotFound();
|
return NotFound("This network does not support Lightning");
|
||||||
}
|
}
|
||||||
|
|
||||||
var store = await _storeRepository.FindStore(storeId);
|
var store = await _storeRepository.FindStore(storeId);
|
||||||
if (store is null)
|
if (store is null)
|
||||||
{
|
{
|
||||||
return NotFound();
|
return NotFound("Store not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
currencyCode ??= store.GetStoreBlob().DefaultCurrency ?? cryptoCode;
|
currencyCode ??= store.GetStoreBlob().DefaultCurrency ?? cryptoCode;
|
||||||
@@ -219,13 +218,13 @@ namespace BTCPayServer
|
|||||||
var lnMethod = methods.FirstOrDefault(method => method.PaymentId == lnpmi);
|
var lnMethod = methods.FirstOrDefault(method => method.PaymentId == lnpmi);
|
||||||
if (lnUrlMethod is null || lnMethod is null)
|
if (lnUrlMethod is null || lnMethod is null)
|
||||||
{
|
{
|
||||||
return NotFound();
|
return NotFound("LNURL or Lightning payment method not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
var blob = store.GetStoreBlob();
|
var blob = store.GetStoreBlob();
|
||||||
if (blob.GetExcludedPaymentMethods().Match(pmi) || blob.GetExcludedPaymentMethods().Match(lnpmi))
|
if (blob.GetExcludedPaymentMethods().Match(pmi) || blob.GetExcludedPaymentMethods().Match(lnpmi))
|
||||||
{
|
{
|
||||||
return NotFound();
|
return NotFound("LNURL or Lightning payment method disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
(string username, List<string> additionalTags, decimal? invoiceAmount, bool? anyoneCanInvoice) =
|
(string username, List<string> additionalTags, decimal? invoiceAmount, bool? anyoneCanInvoice) =
|
||||||
@@ -470,7 +469,6 @@ namespace BTCPayServer
|
|||||||
Max = lightningAddressSettings.Items[s].Max,
|
Max = lightningAddressSettings.Items[s].Max,
|
||||||
Min = lightningAddressSettings.Items[s].Min,
|
Min = lightningAddressSettings.Items[s].Min,
|
||||||
CurrencyCode = lightningAddressSettings.Items[s].CurrencyCode,
|
CurrencyCode = lightningAddressSettings.Items[s].CurrencyCode,
|
||||||
CryptoCode = lightningAddressSettings.Items[s].CryptoCode,
|
|
||||||
StoreId = lightningAddressSettings.Items[s].StoreId,
|
StoreId = lightningAddressSettings.Items[s].StoreId,
|
||||||
Username = s,
|
Username = s,
|
||||||
}).ToList()
|
}).ToList()
|
||||||
@@ -522,11 +520,6 @@ namespace BTCPayServer
|
|||||||
|
|
||||||
lightningAddressSettings.StoreToItemMap.AddOrReplace(storeId, ids);
|
lightningAddressSettings.StoreToItemMap.AddOrReplace(storeId, ids);
|
||||||
vm.Add.StoreId = storeId;
|
vm.Add.StoreId = storeId;
|
||||||
vm.Add.CryptoCode = ControllerContext.HttpContext.GetStoreData()
|
|
||||||
.GetEnabledPaymentIds(_btcPayNetworkProvider)
|
|
||||||
.OrderBy(id => id.CryptoCode == "BTC")
|
|
||||||
.First()
|
|
||||||
.CryptoCode;
|
|
||||||
lightningAddressSettings.Items.TryAdd(vm.Add.Username.ToLowerInvariant(), vm.Add);
|
lightningAddressSettings.Items.TryAdd(vm.Add.Username.ToLowerInvariant(), vm.Add);
|
||||||
await _settingsRepository.UpdateSetting(lightningAddressSettings);
|
await _settingsRepository.UpdateSetting(lightningAddressSettings);
|
||||||
TempData.SetStatusMessageModel(new StatusMessageModel
|
TempData.SetStatusMessageModel(new StatusMessageModel
|
||||||
|
|||||||
Reference in New Issue
Block a user