Pull payment improvements (#5453)

This commit is contained in:
d11n
2023-11-09 10:17:52 +01:00
committed by GitHub
parent 696a414e95
commit 7708084331
5 changed files with 23 additions and 18 deletions

View File

@@ -92,7 +92,7 @@ namespace BTCPayServer
}
[HttpGet("withdraw/pp/{pullPaymentId}")]
public async Task<IActionResult> GetLNURLForPullPayment(string cryptoCode, string pullPaymentId, string pr, CancellationToken cancellationToken)
public async Task<IActionResult> GetLNURLForPullPayment(string cryptoCode, string pullPaymentId, [FromQuery] string pr, CancellationToken cancellationToken)
{
var network = _btcPayNetworkProvider.GetNetwork<BTCPayNetwork>(cryptoCode);
if (network is null || !network.SupportLightning)

View File

@@ -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
{
}
}

View File

@@ -19,9 +19,9 @@
<a class="btcpay-pill" :class="{ 'active': key === mode }" href="#" v-on:click="mode = key">{{item.title}}</a>
</li>
</ul>
<div class="input-group input-group-sm mt-3" :data-clipboard="currentFragment" v-if="currentFragment && currentMode.showData">
<input type="text" class="form-control" readonly="readonly" :value="currentFragment" id="qr-code-data-input">
<button type="button" class="btn btn-outline-secondary px-3">
<div class="input-group input-group-sm mt-3" v-if="currentFragment && currentMode.showData">
<input type="text" class="form-control" readonly :value="currentFragment" id="qr-code-data-input">
<button type="button" class="btn btn-outline-secondary px-3" data-clipboard-target="#qr-code-data-input">
<vc:icon symbol="copy" />
</button>
</div>
@@ -112,7 +112,7 @@ function initQRShow(data) {
this.mode = "default";
this.show();
},
show(){
show() {
$(`#${this.modalId}`).modal("show");
}
}

View File

@@ -203,15 +203,15 @@
<tr class="payout mass-action-row">
@if (stateActions.Any())
{
<td class="only-for-js mass-action-select-col" permission="@Policies.CanModifyStoreSettings">
<td class="only-for-js mass-action-select-col align-middle" permission="@Policies.CanModifyStoreSettings">
<input type="checkbox" class="selection-item-@Model.PayoutState.ToString() form-check-input mass-action-select" asp-for="Payouts[i].Selected" />
<input type="hidden" asp-for="Payouts[i].PayoutId" />
</td>
}
<td class="date-col">
<td class="date-col align-middle">
@pp.Date.ToBrowserDate()
</td>
<td class="mw-100">
<td class="align-middle">
@if (pp.SourceLink is not null && pp.Source is not null)
{
<a href="@pp.SourceLink" rel="noreferrer noopener">@pp.Source</a>
@@ -221,16 +221,16 @@
<span>@pp.Source</span>
}
</td>
<td title="@pp.Destination">
<span class="text-break">@pp.Destination</span>
<td class="align-middle">
<vc:truncate-center text="@pp.Destination" classes="truncate-center-id" />
</td>
<td class="amount-col">
<td class="amount-col align-middle">
<span data-sensitive>@pp.Amount</span>
</td>
@if (Model.PayoutState != PayoutState.AwaitingApproval)
{
<td class="text-end">
@if (!(pp.ProofLink is null))
<td class="text-end align-middle">
@if (!string.IsNullOrEmpty(pp.ProofLink))
{
<a class="transaction-link" href="@pp.ProofLink" rel="noreferrer noopener">Link</a>
}

View File

@@ -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;