btcpayserver / btcpayserver-plugins

A repository storing verified BTCPay Server Plugins.
https://btcpayserver.org
19 stars 5 forks source link

Failure when attempting to receive payments with a LNBank Wallet #12

Closed golyalpha closed 2 years ago

golyalpha commented 2 years ago

Describe the bug Attempting to receive a LN payment with a store connected to a LNBank wallet, or attempting to receive a payment via the LNBank plugin UI fails with an error.

To Reproduce the bug Steps to reproduce the reported bug:

  1. Create a LNBank Wallet
  2. Set up your store to use the LNBank Wallet (and allow LNURL for standard invoices)
  3. Attempt to create an invoice (optionally force Lightning-only invoice via store settings)
  4. The BTCPay invoice will get created, but attempting to pay it will result in an error in the wallet

Expected behavior The LNBank UI should display a LN invoice (or a working LNURL). Attempting to pay a BTCPay Invoice shouldn't fail with Error 400

Screenshots

Your BTCPay Environment (please complete the following information):

Logs (if applicable) Traceback from BTCPayServer:

fail: Microsoft.AspNetCore.Server.Kestrel: Connection id "0HMFGI0ORSGGC", Request id "0HMFGI0ORSGGC:00000002": An unhandled exception was thrown by the application.
System.NullReferenceException: Object reference not set to an instance of an object.
   at AspNetCoreGeneratedDocument.Views_Shared__Layout.<>c__DisplayClass19_0.<<ExecuteAsync>b__1>d.MoveNext() in /source/BTCPayServer/Views/Shared/_Layout.cshtml:line 73
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperExecutionContext.SetOutputContentAsync()
   at AspNetCoreGeneratedDocument.Views_Shared__Layout.ExecuteAsync() in /source/BTCPayServer/Views/Shared/_Layout.cshtml:line 18
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context)
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, Boolean invokeViewStarts)
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderLayoutAsync(ViewContext context, ViewBufferTextWriter bodyWriter)
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context)
   at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable`1 statusCode)
   at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable`1 statusCode)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResultFilterAsync>g__Awaited|30_0[TFilter,TFilterAsync](ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeResultFilters>g__Awaited|28_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authorization.Policy.AuthorizationMiddlewareResultHandler.HandleAsync(RequestDelegate next, HttpContext context, AuthorizationPolicy policy, PolicyAuthorizationResult authorizeResult)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at BTCPayServer.Hosting.BTCPayMiddleware.Invoke(HttpContext httpContext) in /source/BTCPayServer/Hosting/BTCpayMiddleware.cs:line 100
   at BTCPayServer.Hosting.GreenfieldMiddleware.Invoke(HttpContext httpContext) in /source/BTCPayServer/Hosting/GreenfieldMiddleware.cs:line 50
   at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
   at BTCPayServer.Hosting.HeadersOverrideMiddleware.Invoke(HttpContext httpContext) in /source/BTCPayServer/Hosting/HeadersOverrideMiddleware.cs:line 30
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)

Logs from NGINX (hostname and IP modified):

btcpay.host.example 1.1.1.1 - - [15/Feb/2022:18:00:12 +0000] "GET /BTC/lnurl/pay/i/Rm9wvFvqW7Br99SfdhjDKE HTTP/2.0" 200 247 "-" "okhttp/3.11.0"
btcpay.host.example 1.1.1.1 - - [15/Feb/2022:18:00:17 +0000] "GET /BTC/lnurl/pay/i/Rm9wvFvqW7Br99SfdhjDKE?amount=107000&nonce=%16%D8%96%2F%2Cd%EF%BF%BDA&comment= HTTP/2.0" 400 93 "-" "okhttp/3.11.0"
dennisreimann commented 2 years ago

Thanks, this will be fixed in the upcoming version!

golyalpha commented 2 years ago

So, got an update - when a description is provided in the LNBank UI, the LN invoice is displayed on the next page, however, the public share URL does not work:

btcpayserver_1                       | fail: Microsoft.AspNetCore.Server.Kestrel: Connection id "0HMFGO6D2RDP7", Request id "0HMFGO6D2RDP7:00000002": An unhandled exception was thrown by the application.
btcpayserver_1                       | BTCPayServer.Hosting.ValidateControllerNameTransformer+ControllerNotFoundException: The controller Home has not been found
btcpayserver_1                       |    at BTCPayServer.Hosting.ValidateControllerNameTransformer.TransformOutbound(Object value) in /source/BTCPayServer/Hosting/ValidateControllerNameTransformer.cs:line 70
btcpayserver_1                       |    at Microsoft.AspNetCore.Routing.Template.TemplateBinder.TryBindValuesCore(UriBuildingContext context, RouteValueDictionary acceptedValues)
btcpayserver_1                       |    at Microsoft.AspNetCore.Routing.Template.TemplateBinder.TryBindValues(RouteValueDictionary acceptedValues, LinkOptions options, LinkOptions globalOptions, ValueTuple`2& result)
btcpayserver_1                       |    at Microsoft.AspNetCore.Routing.DefaultLinkGenerator.TryProcessTemplate(HttpContext httpContext, RouteEndpoint endpoint, RouteValueDictionary values, RouteValueDictionary ambientValues, LinkOptions options, ValueTuple`2& result)
btcpayserver_1                       |    at Microsoft.AspNetCore.Routing.DefaultLinkGenerator.GetPathByEndpoints(HttpContext httpContext, List`1 endpoints, RouteValueDictionary values, RouteValueDictionary ambientValues, PathString pathBase, FragmentString fragment, LinkOptions options)
btcpayserver_1                       |    at Microsoft.AspNetCore.Routing.DefaultLinkGenerator.GetPathByAddress[TAddress](HttpContext httpContext, TAddress address, RouteValueDictionary values, RouteValueDictionary ambientValues, Nullable`1 pathBase, FragmentString fragment, LinkOptions options)
btcpayserver_1                       |    at Microsoft.AspNetCore.Routing.LinkGeneratorRouteValuesAddressExtensions.GetPathByRouteValues(LinkGenerator generator, HttpContext httpContext, String routeName, Object values, Nullable`1 pathBase, FragmentString fragment, LinkOptions options)
btcpayserver_1                       |    at Microsoft.AspNetCore.Mvc.Routing.EndpointRoutingUrlHelper.Action(UrlActionContext urlActionContext)
btcpayserver_1                       |    at Microsoft.AspNetCore.Mvc.ViewFeatures.DefaultHtmlGenerator.GenerateActionLink(ViewContext viewContext, String linkText, String actionName, String controllerName, String protocol, String hostname, String fragment, Object routeValues, Object htmlAttributes)
btcpayserver_1                       |    at Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper.Process(TagHelperContext context, TagHelperOutput output)
btcpayserver_1                       |    at Microsoft.AspNetCore.Razor.TagHelpers.TagHelper.ProcessAsync(TagHelperContext context, TagHelperOutput output)
btcpayserver_1                       |    at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner.RunAsync(TagHelperExecutionContext executionContext)
btcpayserver_1                       |    at AspNetCoreGeneratedDocument.Pages_Transactions_Share.ExecuteAsync() in /home/d11n/Sources/btcpay/server/BTCPayServer.Plugins.LNbank/Pages/Transactions/Share.cshtml:line 8
btcpayserver_1                       |    at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context)
btcpayserver_1                       |    at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, Boolean invokeViewStarts)
btcpayserver_1                       |    at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context)
btcpayserver_1                       |    at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable`1 statusCode)
btcpayserver_1                       |    at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable`1 statusCode)
btcpayserver_1                       |    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResultFilterAsync>g__Awaited|30_0[TFilter,TFilterAsync](ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
btcpayserver_1                       |    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context)
btcpayserver_1                       |    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State& next, Scope& scope, Object& state, Boolean& isCompleted)
btcpayserver_1                       |    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultFilters()
btcpayserver_1                       | --- End of stack trace from previous location ---
btcpayserver_1                       |    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
btcpayserver_1                       |    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
btcpayserver_1                       |    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
btcpayserver_1                       |    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
btcpayserver_1                       | --- End of stack trace from previous location ---
btcpayserver_1                       |    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
btcpayserver_1                       |    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
btcpayserver_1                       |    at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
btcpayserver_1                       |    at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
btcpayserver_1                       |    at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
btcpayserver_1                       |    at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
btcpayserver_1                       |    at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
btcpayserver_1                       |    at BTCPayServer.Hosting.BTCPayMiddleware.Invoke(HttpContext httpContext) in /source/BTCPayServer/Hosting/BTCpayMiddleware.cs:line 100
btcpayserver_1                       |    at BTCPayServer.Hosting.GreenfieldMiddleware.Invoke(HttpContext httpContext) in /source/BTCPayServer/Hosting/GreenfieldMiddleware.cs:line 50
btcpayserver_1                       |    at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
btcpayserver_1                       |    at BTCPayServer.Hosting.HeadersOverrideMiddleware.Invoke(HttpContext httpContext) in /source/BTCPayServer/Hosting/HeadersOverrideMiddleware.cs:line 30
btcpayserver_1                       |    at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)
dennisreimann commented 2 years ago

@golyalpha Yes, these bugs are both fixed but not released yet. Hopefully there'll be a new release of LNbank 1.1.0 this week :)

golyalpha commented 2 years ago

LNURL Payments still don't work. Seems to still be a problem of "description" not being provided.

fail: Microsoft.AspNetCore.Server.Kestrel: Connection id "0HMFM7TMCOKRL", Request id "0HMFM7TMCOKRL:00000002": An unhandled exception was thrown by the application.
BTCPayServer.Client.GreenfieldAPIException: Value cannot be null. (Parameter 'description')
   at BTCPayServer.Controllers.Greenfield.LocalBTCPayServerClient.HandleActionResult(IActionResult result) in /source/BTCPayServer/Controllers/GreenField/LocalBTCPayServerClient.cs:line 543
   at BTCPayServer.Controllers.Greenfield.LocalBTCPayServerClient.GetFromActionResult[T](IActionResult result) in /source/BTCPayServer/Controllers/GreenField/LocalBTCPayServerClient.cs:line 524
   at BTCPayServer.Controllers.Greenfield.LocalBTCPayServerClient.CreateLightningInvoice(String cryptoCode, CreateLightningInvoiceRequest request, CancellationToken token) in /source/BTCPayServer/Controllers/GreenField/LocalBTCPayServerClient.cs:line 518
   at BTCPayServer.Plugins.LNbank.Services.BTCPayService.CreateLightningInvoice(LightningInvoiceCreateRequest req) in /home/d11n/Sources/btcpay/server/BTCPayServer.Plugins.LNbank/Services/BTCPayService.cs:line 25
   at BTCPayServer.Plugins.LNbank.Services.Wallets.WalletService.Receive(Wallet wallet, Int64 amount, String description, uint256 descriptionHash, TimeSpan expiry) in /home/d11n/Sources/btcpay/server/BTCPayServer.Plugins.LNbank/Services/Wallets/WalletService.cs:line 102
   at BTCPayServer.Plugins.LNbank.Services.Wallets.WalletService.Receive(Wallet wallet, Int64 amount, String description, uint256 descriptionHash, TimeSpan expiry) in /home/d11n/Sources/btcpay/server/BTCPayServer.Plugins.LNbank/Services/Wallets/WalletService.cs:line 122
   at BTCPayServer.Plugins.LNbank.Services.Wallets.WalletService.Receive(Wallet wallet, Int64 amount, uint256 description) in /home/d11n/Sources/btcpay/server/BTCPayServer.Plugins.LNbank/Services/Wallets/WalletService.cs:line 95
   at BTCPayServer.Plugins.LNbank.Controllers.API.LightningController.CreateLightningInvoice(LightningInvoiceCreateRequest req) in /home/d11n/Sources/btcpay/server/BTCPayServer.Plugins.LNbank/Controllers/API/LightningController.cs:line 42
   at lambda_method2146(Closure , Object )
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ExceptionContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authorization.Policy.AuthorizationMiddlewareResultHandler.HandleAsync(RequestDelegate next, HttpContext context, AuthorizationPolicy policy, PolicyAuthorizationResult authorizeResult)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at BTCPayServer.Hosting.BTCPayMiddleware.Invoke(HttpContext httpContext) in /source/BTCPayServer/Hosting/BTCpayMiddleware.cs:line 100
   at BTCPayServer.Hosting.GreenfieldMiddleware.Invoke(HttpContext httpContext) in /source/BTCPayServer/Hosting/GreenfieldMiddleware.cs:line 50
   at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
   at BTCPayServer.Hosting.HeadersOverrideMiddleware.Invoke(HttpContext httpContext) in /source/BTCPayServer/Hosting/HeadersOverrideMiddleware.cs:line 30
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)

This is happening with BTCPayServer 1.4.6

dennisreimann commented 2 years ago

Please wait for BTCPay Server v1.4.7 + LNbank v1.1.0

dennisreimann commented 2 years ago

btw: I haven't checked for LNURL compatibility, I still need to get to that.

golyalpha commented 2 years ago

Huh, well, for some reason the public node info on one of my servers shows up as Unavailable on the LNBank wallet even though the LN node is running just fine (and the LNBank UI can receive payments just fine).

That is working fine on another server, but there it takes way too long for BTCPayServer to notice the payment has arrived, even though it's already showing up as received in the LNBank UI.

Both servers are running BTCPayServer 1.4.6, but the one that has the "Unavailable" issue is running on an ARM64 machine.

golyalpha commented 2 years ago

So, apparently, the LNBank wallet needs to be "primed" by receiving a transaction via the LNBank UI first - then it works fine.

Either that, or some other fix has been deployed since last time.

dennisreimann commented 2 years ago

@golyalpha BTCPay Server v1.4.9 + LNbank v1.2.0 fixed the previous errors. All should be working as expected now.

golyalpha commented 2 years ago

ahh, that explains it, thanks