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}")] [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); var network = _btcPayNetworkProvider.GetNetwork<BTCPayNetwork>(cryptoCode);
if (network is null || !network.SupportLightning) 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 try
{ {
var result = await lightningClient.Pay(bolt11PaymentRequest.ToString(), 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 // 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) Amount = payoutBlob.CryptoAmount == bolt11PaymentRequest.MinimumAmount.ToDecimal(LightMoneyUnit.BTC)? null: new LightMoney((decimal)payoutBlob.CryptoAmount, LightMoneyUnit.BTC)
}, cancellationToken); }, cancellationToken);
if (result == null) throw new NoPaymentResultException();
string message = null; string message = null;
if (result.Result == PayResult.Ok) if (result.Result == PayResult.Ok)
{ {
@@ -330,7 +332,7 @@ namespace BTCPayServer.Data.Payouts.LightningLike
Message = message 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 // Timeout, potentially caused by hold invoices
// Payment will be saved as pending, the LightningPendingPayoutListener will handle settling/cancelling // 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() private async Task SetStoreContext()
{ {
var storeId = HttpContext.GetUserPrefsCookie()?.CurrentStoreId; var storeId = HttpContext.GetUserPrefsCookie()?.CurrentStoreId;
@@ -377,4 +378,8 @@ namespace BTCPayServer.Data.Payouts.LightningLike
public decimal Amount { get; set; } 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> <a class="btcpay-pill" :class="{ 'active': key === mode }" href="#" v-on:click="mode = key">{{item.title}}</a>
</li> </li>
</ul> </ul>
<div class="input-group input-group-sm mt-3" :data-clipboard="currentFragment" v-if="currentFragment && currentMode.showData"> <div class="input-group input-group-sm mt-3" v-if="currentFragment && currentMode.showData">
<input type="text" class="form-control" readonly="readonly" :value="currentFragment" id="qr-code-data-input"> <input type="text" class="form-control" readonly :value="currentFragment" id="qr-code-data-input">
<button type="button" class="btn btn-outline-secondary px-3"> <button type="button" class="btn btn-outline-secondary px-3" data-clipboard-target="#qr-code-data-input">
<vc:icon symbol="copy" /> <vc:icon symbol="copy" />
</button> </button>
</div> </div>
@@ -112,7 +112,7 @@ function initQRShow(data) {
this.mode = "default"; this.mode = "default";
this.show(); this.show();
}, },
show(){ show() {
$(`#${this.modalId}`).modal("show"); $(`#${this.modalId}`).modal("show");
} }
} }

View File

@@ -203,15 +203,15 @@
<tr class="payout mass-action-row"> <tr class="payout mass-action-row">
@if (stateActions.Any()) @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="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" /> <input type="hidden" asp-for="Payouts[i].PayoutId" />
</td> </td>
} }
<td class="date-col"> <td class="date-col align-middle">
@pp.Date.ToBrowserDate() @pp.Date.ToBrowserDate()
</td> </td>
<td class="mw-100"> <td class="align-middle">
@if (pp.SourceLink is not null && pp.Source is not null) @if (pp.SourceLink is not null && pp.Source is not null)
{ {
<a href="@pp.SourceLink" rel="noreferrer noopener">@pp.Source</a> <a href="@pp.SourceLink" rel="noreferrer noopener">@pp.Source</a>
@@ -221,16 +221,16 @@
<span>@pp.Source</span> <span>@pp.Source</span>
} }
</td> </td>
<td title="@pp.Destination"> <td class="align-middle">
<span class="text-break">@pp.Destination</span> <vc:truncate-center text="@pp.Destination" classes="truncate-center-id" />
</td> </td>
<td class="amount-col"> <td class="amount-col align-middle">
<span data-sensitive>@pp.Amount</span> <span data-sensitive>@pp.Amount</span>
</td> </td>
@if (Model.PayoutState != PayoutState.AwaitingApproval) @if (Model.PayoutState != PayoutState.AwaitingApproval)
{ {
<td class="text-end"> <td class="text-end align-middle">
@if (!(pp.ProofLink is null)) @if (!string.IsNullOrEmpty(pp.ProofLink))
{ {
<a class="transaction-link" href="@pp.ProofLink" rel="noreferrer noopener">Link</a> <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: ''; content: '';
position: absolute; position: absolute;
top: -1px; top: -1px;
left: -1px; left: 0;
right: -1px; right: 0;
bottom: 0; bottom: 0;
border-bottom: 1px solid; border-bottom: 1px solid;
border-color: inherit; border-color: inherit;