mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-22 06:21:44 +01:00
fix: check lightning payment status (#6219)
This commit is contained in:
parent
0f93581ff5
commit
2d2c1d5f2d
1 changed files with 21 additions and 10 deletions
|
@ -319,23 +319,34 @@ namespace BTCPayServer.Data.Payouts.LightningLike
|
||||||
string message = null;
|
string message = null;
|
||||||
if (result.Result == PayResult.Ok)
|
if (result.Result == PayResult.Ok)
|
||||||
{
|
{
|
||||||
message = result.Details?.TotalAmount != null
|
payoutData.State = result.Details?.Status switch
|
||||||
? $"Paid out {result.Details.TotalAmount.ToDecimal(LightMoneyUnit.BTC)}"
|
|
||||||
: null;
|
|
||||||
payoutData.State = PayoutState.Completed;
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
var payment = await lightningClient.GetPayment(bolt11PaymentRequest.PaymentHash.ToString(), cancellationToken);
|
LightningPaymentStatus.Pending => PayoutState.InProgress,
|
||||||
proofBlob.Preimage = payment.Preimage;
|
_ => PayoutState.Completed,
|
||||||
}
|
};
|
||||||
catch (Exception)
|
if (payoutData.State == PayoutState.Completed)
|
||||||
{
|
{
|
||||||
// ignored
|
message = result.Details?.TotalAmount != null
|
||||||
|
? $"Paid out {result.Details.TotalAmount.ToDecimal(LightMoneyUnit.BTC)}"
|
||||||
|
: null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var payment = await lightningClient.GetPayment(bolt11PaymentRequest.PaymentHash.ToString(),
|
||||||
|
cancellationToken);
|
||||||
|
proofBlob.Preimage = payment.Preimage;
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
// ignored
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (result.Result == PayResult.Unknown)
|
else if (result.Result == PayResult.Unknown)
|
||||||
{
|
{
|
||||||
payoutData.State = PayoutState.InProgress;
|
payoutData.State = PayoutState.InProgress;
|
||||||
|
}
|
||||||
|
if (payoutData.State == PayoutState.InProgress)
|
||||||
|
{
|
||||||
message = "The payment has been initiated but is still in-flight.";
|
message = "The payment has been initiated but is still in-flight.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue