mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-01-18 13:26:47 +01:00
Fix conversion
This commit is contained in:
parent
2c480f57c2
commit
2d370b8cea
@ -1997,6 +1997,7 @@ namespace BTCPayServer.Tests
|
|||||||
public async Task CanUsePullPaymentsViaUI()
|
public async Task CanUsePullPaymentsViaUI()
|
||||||
{
|
{
|
||||||
using var s = CreateSeleniumTester();
|
using var s = CreateSeleniumTester();
|
||||||
|
s.Server.DeleteStore = false;
|
||||||
s.Server.ActivateLightning(LightningConnectionType.LndREST);
|
s.Server.ActivateLightning(LightningConnectionType.LndREST);
|
||||||
await s.StartAsync();
|
await s.StartAsync();
|
||||||
await s.Server.EnsureChannelsSetup();
|
await s.Server.EnsureChannelsSetup();
|
||||||
@ -2308,6 +2309,22 @@ namespace BTCPayServer.Tests
|
|||||||
|
|
||||||
// Simulate a boltcard
|
// Simulate a boltcard
|
||||||
{
|
{
|
||||||
|
// LNURL Withdraw support check with BTC denomination
|
||||||
|
s.GoToStore(s.StoreId, StoreNavPages.PullPayments);
|
||||||
|
s.Driver.FindElement(By.Id("NewPullPayment")).Click();
|
||||||
|
s.Driver.FindElement(By.Id("Name")).SendKeys("TopUpTest");
|
||||||
|
s.Driver.SetCheckbox(By.Id("AutoApproveClaims"), true);
|
||||||
|
s.Driver.FindElement(By.Id("Amount")).Clear();
|
||||||
|
s.Driver.FindElement(By.Id("Amount")).SendKeys("100000");
|
||||||
|
s.Driver.FindElement(By.Id("Currency")).Clear();
|
||||||
|
s.Driver.FindElement(By.Id("Currency")).SendKeys("SATS" + Keys.Enter);
|
||||||
|
s.FindAlertMessage();
|
||||||
|
s.Driver.FindElement(By.LinkText("View")).Click();
|
||||||
|
s.Driver.SwitchTo().Window(s.Driver.WindowHandles.Last());
|
||||||
|
|
||||||
|
s.Driver.FindElement(By.CssSelector("#lnurlwithdraw-button")).Click();
|
||||||
|
s.Driver.WaitForElement(By.Id("qr-code-data-input"));
|
||||||
|
lnurl = new Uri(LNURL.LNURL.Parse(s.Driver.FindElement(By.Id("qr-code-data-input")).GetAttribute("value"), out _).ToString().Replace("https", "http"));
|
||||||
var db = s.Server.PayTester.GetService<ApplicationDbContextFactory>();
|
var db = s.Server.PayTester.GetService<ApplicationDbContextFactory>();
|
||||||
var ppid = lnurl.AbsoluteUri.Split("/").Last();
|
var ppid = lnurl.AbsoluteUri.Split("/").Last();
|
||||||
var issuerKey = new IssuerKey(SettingsRepositoryExtensions.FixedKey());
|
var issuerKey = new IssuerKey(SettingsRepositoryExtensions.FixedKey());
|
||||||
@ -2329,6 +2346,8 @@ namespace BTCPayServer.Tests
|
|||||||
var payReq = (LNURLPayRequest)await LNURL.LNURL.FetchInformation(info.PayLink, s.Server.PayTester.HttpClient);
|
var payReq = (LNURLPayRequest)await LNURL.LNURL.FetchInformation(info.PayLink, s.Server.PayTester.HttpClient);
|
||||||
var callback = await payReq.SendRequest(LightMoney.Satoshis(100), Network.RegTest, s.Server.PayTester.HttpClient);
|
var callback = await payReq.SendRequest(LightMoney.Satoshis(100), Network.RegTest, s.Server.PayTester.HttpClient);
|
||||||
Assert.NotNull(callback.Pr);
|
Assert.NotNull(callback.Pr);
|
||||||
|
var pr = BOLT11PaymentRequest.Parse(callback.Pr, Network.RegTest);
|
||||||
|
Assert.Equal(LightMoney.Satoshis(100), pr.MinimumAmount);
|
||||||
var res = await s.Server.CustomerLightningD.Pay(callback.Pr);
|
var res = await s.Server.CustomerLightningD.Pay(callback.Pr);
|
||||||
Assert.Equal(PayResult.Ok, res.Result);
|
Assert.Equal(PayResult.Ok, res.Result);
|
||||||
var ppService = s.Server.PayTester.GetService<PullPaymentHostedService>();
|
var ppService = s.Server.PayTester.GetService<PullPaymentHostedService>();
|
||||||
|
@ -79,6 +79,16 @@ public class UIBoltcardController : Controller
|
|||||||
return Ok(payRequest);
|
return Ok(payRequest);
|
||||||
|
|
||||||
var cryptoCode = "BTC";
|
var cryptoCode = "BTC";
|
||||||
|
|
||||||
|
var currency = "BTC";
|
||||||
|
var invoiceAmount = LightMoney.FromUnit(amount.Value, LightMoneyUnit.MilliSatoshi).ToUnit(LightMoneyUnit.BTC);
|
||||||
|
|
||||||
|
if (pp.GetBlob().Currency == "SATS")
|
||||||
|
{
|
||||||
|
currency = "SATS";
|
||||||
|
invoiceAmount = LightMoney.FromUnit(amount.Value, LightMoneyUnit.MilliSatoshi).ToUnit(LightMoneyUnit.Satoshi);
|
||||||
|
}
|
||||||
|
|
||||||
LNURLController.ControllerContext.HttpContext = HttpContext;
|
LNURLController.ControllerContext.HttpContext = HttpContext;
|
||||||
var result = await LNURLController.GetLNURLRequest(
|
var result = await LNURLController.GetLNURLRequest(
|
||||||
cryptoCode,
|
cryptoCode,
|
||||||
@ -86,8 +96,8 @@ public class UIBoltcardController : Controller
|
|||||||
store.GetStoreBlob(),
|
store.GetStoreBlob(),
|
||||||
new CreateInvoiceRequest()
|
new CreateInvoiceRequest()
|
||||||
{
|
{
|
||||||
Currency = "BTC",
|
Currency = currency,
|
||||||
Amount = LightMoney.FromUnit(amount.Value, LightMoneyUnit.MilliSatoshi).ToUnit(LightMoneyUnit.BTC)
|
Amount = invoiceAmount
|
||||||
},
|
},
|
||||||
payRequest,
|
payRequest,
|
||||||
null,
|
null,
|
||||||
|
Loading…
Reference in New Issue
Block a user