mirror of
https://github.com/aljazceru/BTCPayServerPlugins.git
synced 2025-12-17 07:34:24 +01:00
remove nfc plugin
This commit is contained in:
@@ -1,40 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<LangVersion>10</LangVersion>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<!-- Plugin specific properties -->
|
|
||||||
<PropertyGroup>
|
|
||||||
<Product>LNURL NFC Support</Product>
|
|
||||||
<Description>Allows you to support contactless card payments over NFC and LNURL Withdraw!</Description>
|
|
||||||
<Version>1.0.8</Version>
|
|
||||||
</PropertyGroup>
|
|
||||||
<!-- Plugin development properties -->
|
|
||||||
<PropertyGroup>
|
|
||||||
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
|
|
||||||
<PreserveCompilationContext>false</PreserveCompilationContext>
|
|
||||||
<GenerateEmbeddedFilesManifest>true</GenerateEmbeddedFilesManifest>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<!-- This will make sure that referencing BTCPayServer doesn't put any artifact in the published directory -->
|
|
||||||
<ItemDefinitionGroup>
|
|
||||||
<ProjectReference>
|
|
||||||
<Properties>StaticWebAssetsEnabled=false</Properties>
|
|
||||||
<Private>false</Private>
|
|
||||||
<ExcludeAssets>runtime;native;build;buildTransitive;contentFiles</ExcludeAssets>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<EmbeddedResource Include="Resources\**"/>
|
|
||||||
<ProjectReference Include="..\..\submodules\btcpayserver\BTCPayServer\BTCPayServer.csproj"/>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="Resources"/>
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
|
||||||
@@ -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<IActionResult> 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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<IUIExtension>(new UIExtension("NFC/CheckoutEnd",
|
|
||||||
"checkout-end"));
|
|
||||||
applicationBuilder.AddSingleton<IUIExtension>(new UIExtension("NFC/LightningCheckoutPostContent",
|
|
||||||
"checkout-lightning-post-content"));
|
|
||||||
base.Execute(applicationBuilder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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
|
|
||||||
@@ -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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
@@ -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"));
|
|
||||||
}
|
|
||||||
|
|
||||||
<script type="text/javascript" nonce="@nonce">
|
|
||||||
window.lnurlWithdrawSubmitUrl = '@url';
|
|
||||||
</script>
|
|
||||||
<script src="~/Resources/js/lnurlwnfc.js"></script>
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
<LNURLWithdrawContactless inline-template v-if="!srvModel.isUnsetTopUp">
|
|
||||||
|
|
||||||
<bp-loading-button>
|
|
||||||
<button v-on:click="startScan" class="action-button" style="margin-top: 15px;" v-bind:disabled="scanning || submitting" v-bind:class="{ 'loading': scanning || submitting }">
|
|
||||||
<span class="button-text" v-if="supported">Pay by NFC & LNURL-Withdraw</span>
|
|
||||||
<span class="button-text" v-else>Pay by LNURL-Withdraw</span>
|
|
||||||
<div class="loader-wrapper">
|
|
||||||
<partial name="Checkout-Spinner"/>
|
|
||||||
</div>
|
|
||||||
</button>
|
|
||||||
</bp-loading-button>
|
|
||||||
</LNURLWithdrawContactless>
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
|
||||||
Reference in New Issue
Block a user