mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-19 01:43:50 +01:00
LNURL updates (#4501)
This commit is contained in:
parent
099d65032a
commit
eb90fab640
@ -1888,12 +1888,12 @@ namespace BTCPayServer.Tests
|
||||
Assert.Equal(0.0000001m, fetchedReuqest.MaxSendable.ToDecimal(LightMoneyUnit.BTC));
|
||||
Assert.Equal(0.0000001m, fetchedReuqest.MinSendable.ToDecimal(LightMoneyUnit.BTC));
|
||||
|
||||
await Assert.ThrowsAsync<HttpRequestException>(async () =>
|
||||
await Assert.ThrowsAsync<LNUrlException>(async () =>
|
||||
{
|
||||
await fetchedReuqest.SendRequest(new LightMoney(0.0000002m, LightMoneyUnit.BTC),
|
||||
network, new HttpClient());
|
||||
});
|
||||
await Assert.ThrowsAsync<HttpRequestException>(async () =>
|
||||
await Assert.ThrowsAsync<LNUrlException>(async () =>
|
||||
{
|
||||
await fetchedReuqest.SendRequest(new LightMoney(0.00000005m, LightMoneyUnit.BTC),
|
||||
network, new HttpClient());
|
||||
@ -2014,7 +2014,6 @@ namespace BTCPayServer.Tests
|
||||
var payoutsData = await ctx.Payouts.Where(p => p.PullPaymentDataId == pullPaymentId).ToListAsync();
|
||||
Assert.True(payoutsData.All(p => p.State == PayoutState.Completed));
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -53,7 +53,7 @@
|
||||
<PackageReference Include="Fido2" Version="2.0.2" />
|
||||
<PackageReference Include="Fido2.AspNet" Version="2.0.2" />
|
||||
<PackageReference Include="HtmlSanitizer" Version="5.0.372" />
|
||||
<PackageReference Include="LNURL" Version="0.0.27" />
|
||||
<PackageReference Include="LNURL" Version="0.0.28" />
|
||||
<PackageReference Include="MailKit" Version="3.3.0" />
|
||||
<PackageReference Include="BTCPayServer.NETCore.Plugins.Mvc" Version="1.4.4" />
|
||||
<PackageReference Include="QRCoder" Version="1.4.3" />
|
||||
|
@ -63,12 +63,12 @@ namespace BTCPayServer
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!global::LNURL.LNAuthRequest.VerifyChallenge(sig, pubKey, k1))
|
||||
if (!LNURL.LNAuthRequest.VerifyChallenge(sig, pubKey, k1))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var newCredential = new Fido2Credential() {Name = name, ApplicationUserId = userId, Type = Fido2Credential.CredentialType.LNURLAuth, Blob = pubkeyBytes};
|
||||
var newCredential = new Fido2Credential {Name = name, ApplicationUserId = userId, Type = Fido2Credential.CredentialType.LNURLAuth, Blob = pubkeyBytes};
|
||||
|
||||
await dbContext.Fido2Credentials.AddAsync(newCredential);
|
||||
await dbContext.SaveChangesAsync();
|
||||
@ -130,7 +130,7 @@ namespace BTCPayServer
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!global::LNURL.LNAuthRequest.VerifyChallenge(sig, pubKey, k1))
|
||||
if (!LNURL.LNAuthRequest.VerifyChallenge(sig, pubKey, k1))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ namespace BTCPayServer
|
||||
TempData.SetStatusMessageModel(new StatusMessageModel
|
||||
{
|
||||
Severity = StatusMessageModel.StatusSeverity.Error,
|
||||
Html = "The lightning node could not be registered."
|
||||
Html = "The Lightning node could not be registered."
|
||||
});
|
||||
|
||||
return RedirectToList();
|
||||
@ -103,10 +103,10 @@ namespace BTCPayServer
|
||||
if (await _lnurlAuthService.CompleteCreation(name, userId,
|
||||
ECDSASignature.FromDER(Encoders.Hex.DecodeData(sig)), new PubKey(key)))
|
||||
{
|
||||
return Ok(new LNUrlStatusResponse() { Status = "OK" });
|
||||
return Ok(new LNUrlStatusResponse { Status = "OK" });
|
||||
}
|
||||
|
||||
return BadRequest(new LNUrlStatusResponse()
|
||||
return BadRequest(new LNUrlStatusResponse
|
||||
{
|
||||
Reason = "The challenge could not be verified", Status = "ERROR"
|
||||
});
|
||||
@ -127,10 +127,10 @@ namespace BTCPayServer
|
||||
if (await _lnurlAuthService.CompleteLogin(userId,
|
||||
ECDSASignature.FromDER(Encoders.Hex.DecodeData(sig)), new PubKey(key)))
|
||||
{
|
||||
return Ok(new LNUrlStatusResponse() { Status = "OK" });
|
||||
return Ok(new LNUrlStatusResponse { Status = "OK" });
|
||||
}
|
||||
|
||||
return BadRequest(new LNUrlStatusResponse()
|
||||
return BadRequest(new LNUrlStatusResponse
|
||||
{
|
||||
Reason = "The challenge could not be verified", Status = "ERROR"
|
||||
});
|
||||
|
@ -3,7 +3,6 @@ using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BTCPayServer.Abstractions.Constants;
|
||||
@ -17,7 +16,6 @@ using BTCPayServer.Data.Payouts.LightningLike;
|
||||
using BTCPayServer.Events;
|
||||
using BTCPayServer.HostedServices;
|
||||
using BTCPayServer.Lightning;
|
||||
using BTCPayServer.Models.AppViewModels;
|
||||
using BTCPayServer.Payments;
|
||||
using BTCPayServer.Payments.Lightning;
|
||||
using BTCPayServer.Plugins.PointOfSale.Models;
|
||||
@ -31,7 +29,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using NBitcoin;
|
||||
using NBitcoin.Crypto;
|
||||
using Newtonsoft.Json;
|
||||
using MarkPayoutRequest = BTCPayServer.HostedServices.MarkPayoutRequest;
|
||||
|
||||
@ -528,7 +525,7 @@ namespace BTCPayServer
|
||||
if ((i.ReceiptOptions?.Enabled ??blob.ReceiptOptions.Enabled ) is true)
|
||||
{
|
||||
successAction =
|
||||
new LNURLPayRequest.LNURLPayRequestCallbackResponse.LNURLPayRequestSuccessActionUrl()
|
||||
new LNURLPayRequest.LNURLPayRequestCallbackResponse.LNURLPayRequestSuccessActionUrl
|
||||
{
|
||||
Tag = "url",
|
||||
Description = "Thank you for your purchase. Here is your receipt",
|
||||
@ -582,16 +579,17 @@ namespace BTCPayServer
|
||||
return BadRequest(new LNUrlStatusResponse
|
||||
{
|
||||
Status = "ERROR",
|
||||
Reason = "Lightning node could not generate invoice with a VALID description hash"
|
||||
Reason = "Lightning node could not generate invoice with a valid description hash"
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(new LNUrlStatusResponse
|
||||
{
|
||||
Status = "ERROR",
|
||||
Reason = "Lightning node could not generate invoice with description hash"
|
||||
Reason = "Lightning node could not generate invoice with description hash" + (
|
||||
string.IsNullOrEmpty(ex.Message) ? "" : $": {ex.Message}")
|
||||
});
|
||||
}
|
||||
|
||||
@ -638,8 +636,7 @@ namespace BTCPayServer
|
||||
Status = "ERROR", Reason = "Invoice not in a valid payable state"
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Authorize(AuthenticationSchemes = AuthenticationSchemes.Cookie)]
|
||||
[Authorize(Policy = Policies.CanModifyStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Cookie)]
|
||||
[HttpGet("~/stores/{storeId}/plugins/lightning-address")]
|
||||
|
Loading…
Reference in New Issue
Block a user