From 7708084331ebaf4d8440b22364af942ae91f811e Mon Sep 17 00:00:00 2001 From: d11n Date: Thu, 9 Nov 2023 10:17:52 +0100 Subject: [PATCH] Pull payment improvements (#5453) --- BTCPayServer/Controllers/UILNURLController.cs | 2 +- .../UILightningLikePayoutController.cs | 11 ++++++++--- BTCPayServer/Views/Shared/ShowQR.cshtml | 8 ++++---- .../Views/UIStorePullPayments/Payouts.cshtml | 16 ++++++++-------- BTCPayServer/wwwroot/main/site.css | 4 ++-- 5 files changed, 23 insertions(+), 18 deletions(-) diff --git a/BTCPayServer/Controllers/UILNURLController.cs b/BTCPayServer/Controllers/UILNURLController.cs index d071d7a08..ebcfcb5ec 100644 --- a/BTCPayServer/Controllers/UILNURLController.cs +++ b/BTCPayServer/Controllers/UILNURLController.cs @@ -92,7 +92,7 @@ namespace BTCPayServer } [HttpGet("withdraw/pp/{pullPaymentId}")] - public async Task GetLNURLForPullPayment(string cryptoCode, string pullPaymentId, string pr, CancellationToken cancellationToken) + public async Task GetLNURLForPullPayment(string cryptoCode, string pullPaymentId, [FromQuery] string pr, CancellationToken cancellationToken) { var network = _btcPayNetworkProvider.GetNetwork(cryptoCode); if (network is null || !network.SupportLightning) diff --git a/BTCPayServer/Data/Payouts/LightningLike/UILightningLikePayoutController.cs b/BTCPayServer/Data/Payouts/LightningLike/UILightningLikePayoutController.cs index 00b1d578f..7339fd98a 100644 --- a/BTCPayServer/Data/Payouts/LightningLike/UILightningLikePayoutController.cs +++ b/BTCPayServer/Data/Payouts/LightningLike/UILightningLikePayoutController.cs @@ -289,7 +289,7 @@ namespace BTCPayServer.Data.Payouts.LightningLike }; } - var proofBlob = new PayoutLightningBlob() { PaymentHash = bolt11PaymentRequest.PaymentHash.ToString() }; + var proofBlob = new PayoutLightningBlob { PaymentHash = bolt11PaymentRequest.PaymentHash.ToString() }; try { var result = await lightningClient.Pay(bolt11PaymentRequest.ToString(), @@ -298,6 +298,8 @@ namespace BTCPayServer.Data.Payouts.LightningLike // CLN does not support explicit amount param if it is the same as the invoice amount Amount = payoutBlob.CryptoAmount == bolt11PaymentRequest.MinimumAmount.ToDecimal(LightMoneyUnit.BTC)? null: new LightMoney((decimal)payoutBlob.CryptoAmount, LightMoneyUnit.BTC) }, cancellationToken); + if (result == null) throw new NoPaymentResultException(); + string message = null; if (result.Result == PayResult.Ok) { @@ -330,7 +332,7 @@ namespace BTCPayServer.Data.Payouts.LightningLike Message = message }; } - catch (Exception ex) when (ex is TaskCanceledException or OperationCanceledException) + catch (Exception ex) when (ex is TaskCanceledException or OperationCanceledException or NoPaymentResultException) { // Timeout, potentially caused by hold invoices // Payment will be saved as pending, the LightningPendingPayoutListener will handle settling/cancelling @@ -347,7 +349,6 @@ namespace BTCPayServer.Data.Payouts.LightningLike } } - private async Task SetStoreContext() { var storeId = HttpContext.GetUserPrefsCookie()?.CurrentStoreId; @@ -377,4 +378,8 @@ namespace BTCPayServer.Data.Payouts.LightningLike public decimal Amount { get; set; } } } + + public class NoPaymentResultException : Exception + { + } } diff --git a/BTCPayServer/Views/Shared/ShowQR.cshtml b/BTCPayServer/Views/Shared/ShowQR.cshtml index 76627dc8a..1d9d8b6d1 100644 --- a/BTCPayServer/Views/Shared/ShowQR.cshtml +++ b/BTCPayServer/Views/Shared/ShowQR.cshtml @@ -19,9 +19,9 @@ {{item.title}} -
- -
@@ -112,7 +112,7 @@ function initQRShow(data) { this.mode = "default"; this.show(); }, - show(){ + show() { $(`#${this.modalId}`).modal("show"); } } diff --git a/BTCPayServer/Views/UIStorePullPayments/Payouts.cshtml b/BTCPayServer/Views/UIStorePullPayments/Payouts.cshtml index e00c5adab..c1e7908d4 100644 --- a/BTCPayServer/Views/UIStorePullPayments/Payouts.cshtml +++ b/BTCPayServer/Views/UIStorePullPayments/Payouts.cshtml @@ -203,15 +203,15 @@ @if (stateActions.Any()) { - + } - + @pp.Date.ToBrowserDate() - + @if (pp.SourceLink is not null && pp.Source is not null) { @pp.Source @@ -221,16 +221,16 @@ @pp.Source } - - @pp.Destination + + - + @pp.Amount @if (Model.PayoutState != PayoutState.AwaitingApproval) { - - @if (!(pp.ProofLink is null)) + + @if (!string.IsNullOrEmpty(pp.ProofLink)) { Link } diff --git a/BTCPayServer/wwwroot/main/site.css b/BTCPayServer/wwwroot/main/site.css index 225cc86e4..22a813ac3 100644 --- a/BTCPayServer/wwwroot/main/site.css +++ b/BTCPayServer/wwwroot/main/site.css @@ -1078,8 +1078,8 @@ input.ts-wrapper.form-control:not(.ts-hidden-accessible,.ts-inline) { content: ''; position: absolute; top: -1px; - left: -1px; - right: -1px; + left: 0; + right: 0; bottom: 0; border-bottom: 1px solid; border-color: inherit;