mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-21 14:04:12 +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;
|
||||
if (result.Result == PayResult.Ok)
|
||||
{
|
||||
message = result.Details?.TotalAmount != null
|
||||
? $"Paid out {result.Details.TotalAmount.ToDecimal(LightMoneyUnit.BTC)}"
|
||||
: null;
|
||||
payoutData.State = PayoutState.Completed;
|
||||
try
|
||||
payoutData.State = result.Details?.Status switch
|
||||
{
|
||||
var payment = await lightningClient.GetPayment(bolt11PaymentRequest.PaymentHash.ToString(), cancellationToken);
|
||||
proofBlob.Preimage = payment.Preimage;
|
||||
}
|
||||
catch (Exception)
|
||||
LightningPaymentStatus.Pending => PayoutState.InProgress,
|
||||
_ => PayoutState.Completed,
|
||||
};
|
||||
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)
|
||||
{
|
||||
payoutData.State = PayoutState.InProgress;
|
||||
}
|
||||
if (payoutData.State == PayoutState.InProgress)
|
||||
{
|
||||
message = "The payment has been initiated but is still in-flight.";
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue