diff --git a/Plugins/BTCPayServer.Plugins.NFC/BTCPayServer.Plugins.NFC.csproj b/Plugins/BTCPayServer.Plugins.NFC/BTCPayServer.Plugins.NFC.csproj deleted file mode 100644 index 0068d1c..0000000 --- a/Plugins/BTCPayServer.Plugins.NFC/BTCPayServer.Plugins.NFC.csproj +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - net6.0 - 10 - - - - - LNURL NFC Support - Allows you to support contactless card payments over NFC and LNURL Withdraw! - 1.0.8 - - - - true - false - true - - - - - - StaticWebAssetsEnabled=false - false - runtime;native;build;buildTransitive;contentFiles - - - - - - - - - - - - diff --git a/Plugins/BTCPayServer.Plugins.NFC/NFCController.cs b/Plugins/BTCPayServer.Plugins.NFC/NFCController.cs deleted file mode 100644 index e0e8a75..0000000 --- a/Plugins/BTCPayServer.Plugins.NFC/NFCController.cs +++ /dev/null @@ -1,97 +0,0 @@ -using System; -using System.Net.Http; -using System.Threading.Tasks; -using LNURL; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using NBitcoin; - -namespace BTCPayServer.Plugins.NFC -{ - [Route("plugins/NFC")] - public class NFCController : Controller - { - private readonly IHttpClientFactory _httpClientFactory; - - public NFCController(IHttpClientFactory httpClientFactory) - { - _httpClientFactory = httpClientFactory; - } - - public class SubmitRequest - { - public string Lnurl { get; set; } - public string Destination { get; set; } - } - - [AllowAnonymous] - public async Task SubmitLNURLWithdrawForInvoice([FromBody] SubmitRequest request) - { - Uri uri; - string tag; - try - { - uri = LNURL.LNURL.Parse(request.Lnurl, out tag); - if (uri is null) - { - return BadRequest("lnurl was malformed"); - } - } - catch (Exception e) - { - - return BadRequest(e.Message); - } - - - if (!string.IsNullOrEmpty(tag) && !tag.Equals("withdrawRequest")) - { - return BadRequest("lnurl was not lnurl-withdraw"); - } - - var httpClient = _httpClientFactory.CreateClient(uri.IsOnion() - ? "LightningLikePayoutHandlerOnionNamedClient" - : "LightningLikePayoutHandlerClearnetNamedClient"); - var info = (await - LNURL.LNURL.FetchInformation(uri, "withdrawRequest", httpClient)) as LNURLWithdrawRequest; - if (info is null) - { - return BadRequest("Could not fetch info from lnurl-withdraw "); - } - - httpClient = _httpClientFactory.CreateClient(info.Callback.IsOnion() - ? "LightningLikePayoutHandlerOnionNamedClient" - : "LightningLikePayoutHandlerClearnetNamedClient"); - - try - { - var destinationuri = LNURL.LNURL.Parse(request.Destination, out string _); - - var destinfo = (await - LNURL.LNURL.FetchInformation(destinationuri, "payRequest", httpClient)) as LNURLPayRequest; - - if (destinfo is null) - { - return BadRequest("Could not fetch bolt11 invoice to pay to."); - } - - httpClient = _httpClientFactory.CreateClient(destinfo.Callback.IsOnion() - ? "LightningLikePayoutHandlerOnionNamedClient" - : "LightningLikePayoutHandlerClearnetNamedClient"); - var destCallback = await destinfo.SendRequest(destinfo.MinSendable, Network.Main, httpClient); - request.Destination = destCallback.Pr; - } - catch (Exception e) - { - } - - var result = await info.SendRequest(request.Destination, httpClient); - if (result.Status.Equals("ok", StringComparison.InvariantCultureIgnoreCase)) - { - return Ok(result.Reason); - } - - return BadRequest(result.Reason); - } - } -} diff --git a/Plugins/BTCPayServer.Plugins.NFC/NFCPlugin.cs b/Plugins/BTCPayServer.Plugins.NFC/NFCPlugin.cs deleted file mode 100644 index 42d31a4..0000000 --- a/Plugins/BTCPayServer.Plugins.NFC/NFCPlugin.cs +++ /dev/null @@ -1,23 +0,0 @@ -using BTCPayServer.Abstractions.Contracts; -using BTCPayServer.Abstractions.Models; -using BTCPayServer.Abstractions.Services; -using Microsoft.Extensions.DependencyInjection; - -namespace BTCPayServer.Plugins.FixedFloat -{ - public class NFCPlugin : BaseBTCPayServerPlugin - { - public override IBTCPayServerPlugin.PluginDependency[] Dependencies { get; } = - { - new() { Identifier = nameof(BTCPayServer), Condition = ">=1.7.4" } - }; - public override void Execute(IServiceCollection applicationBuilder) - { - applicationBuilder.AddSingleton(new UIExtension("NFC/CheckoutEnd", - "checkout-end")); - applicationBuilder.AddSingleton(new UIExtension("NFC/LightningCheckoutPostContent", - "checkout-lightning-post-content")); - base.Execute(applicationBuilder); - } - } -} diff --git a/Plugins/BTCPayServer.Plugins.NFC/Pack.ps1 b/Plugins/BTCPayServer.Plugins.NFC/Pack.ps1 deleted file mode 100644 index 14449fb..0000000 --- a/Plugins/BTCPayServer.Plugins.NFC/Pack.ps1 +++ /dev/null @@ -1,2 +0,0 @@ -dotnet publish -c Altcoins-Release -o bin/publish/BTCPayServer.Plugins.NFC -dotnet run -p ../../BTCPayServer.PluginPacker bin/publish/BTCPayServer.Plugins.NFC BTCPayServer.Plugins.NFC ../packed diff --git a/Plugins/BTCPayServer.Plugins.NFC/Resources/js/lnurlwnfc.js b/Plugins/BTCPayServer.Plugins.NFC/Resources/js/lnurlwnfc.js deleted file mode 100644 index 1f981f5..0000000 --- a/Plugins/BTCPayServer.Plugins.NFC/Resources/js/lnurlwnfc.js +++ /dev/null @@ -1,80 +0,0 @@ -Vue.component("LNURLWithdrawContactless", { - data: function () { - return { - supported: ('NDEFReader' in window && window.self === window.top), - scanning: false, - submitting: false, - readerAbortController: null, - } - }, - methods: { - startScan: async function () { - try { - if (this.scanning || this.submitting) { - return; - } - const self = this; - self.submitting = false; - self.scanning = true; - if (!this.supported) { - const result = prompt("enter lnurl withdraw"); - if (result) { - self.sendData.bind(self)(result); - return; - } - self.scanning = false; - } - ndef = new NDEFReader() - self.readerAbortController = new AbortController() - await ndef.scan({signal: self.readerAbortController.signal}) - - ndef.addEventListener('readingerror', () => { - self.scanning = false; - self.readerAbortController.abort() - }) - - ndef.addEventListener('reading', ({message, serialNumber}) => { - //Decode NDEF data from tag - const record = message.records[0] - const textDecoder = new TextDecoder('utf-8') - const lnurl = textDecoder.decode(record.data) - - //User feedback, show loader icon - self.scanning = false; - self.sendData.bind(self)(lnurl); - - }) - } catch(e) { - self.scanning = false; - self.submitting = false; - } - }, - sendData: function (lnurl) { - - this.submitting = true; - //Post LNURLW data to server - var xhr = new XMLHttpRequest() - xhr.open('POST', window.lnurlWithdrawSubmitUrl, true) - xhr.setRequestHeader('Content-Type', 'application/json') - xhr.send(JSON.stringify({lnurl, destination: this.$parent.srvModel.btcAddress})) - const self = this; - //User feedback, reset on failure - xhr.onload = function () { - if (xhr.readyState === xhr.DONE) { - console.log(xhr.response); - console.log(xhr.responseText); - self.scanning = false; - self.submitting = false; - - if(self.readerAbortController) { - self.readerAbortController.abort() - } - - if(xhr.response){ - alert(xhr.response) - } - } - } - } - } -}); diff --git a/Plugins/BTCPayServer.Plugins.NFC/Views/Shared/NFC/CheckoutEnd.cshtml b/Plugins/BTCPayServer.Plugins.NFC/Views/Shared/NFC/CheckoutEnd.cshtml deleted file mode 100644 index e01fd0f..0000000 --- a/Plugins/BTCPayServer.Plugins.NFC/Views/Shared/NFC/CheckoutEnd.cshtml +++ /dev/null @@ -1,14 +0,0 @@ -@inject ContentSecurityPolicies contentSecurityPolicies -@using BTCPayServer.Abstractions.Extensions -@using BTCPayServer.Security -@using NBitcoin -@{ - var nonce = RandomUtils.GetUInt256().ToString().Substring(0, 32); - contentSecurityPolicies.Add("script-src", $"'nonce-{nonce}'"); - var url = Context.Request.GetAbsoluteUri(Url.Action("SubmitLNURLWithdrawForInvoice", "NFC")); -} - - - diff --git a/Plugins/BTCPayServer.Plugins.NFC/Views/Shared/NFC/LightningCheckoutPostContent.cshtml b/Plugins/BTCPayServer.Plugins.NFC/Views/Shared/NFC/LightningCheckoutPostContent.cshtml deleted file mode 100644 index 1450249..0000000 --- a/Plugins/BTCPayServer.Plugins.NFC/Views/Shared/NFC/LightningCheckoutPostContent.cshtml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - diff --git a/Plugins/BTCPayServer.Plugins.NFC/Views/_ViewImports.cshtml b/Plugins/BTCPayServer.Plugins.NFC/Views/_ViewImports.cshtml deleted file mode 100644 index afa82bb..0000000 --- a/Plugins/BTCPayServer.Plugins.NFC/Views/_ViewImports.cshtml +++ /dev/null @@ -1 +0,0 @@ -@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers