-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JIT + Server Backup + JSON refactor (#69)
- Loading branch information
Showing
70 changed files
with
2,625 additions
and
911 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using BTCPayApp.Core.Data; | ||
using BTCPayServer.Lightning; | ||
|
||
namespace BTCPayApp.Core.Attempt2; | ||
|
||
public static class AppToServerHelper | ||
{ | ||
|
||
public static LightningInvoice ToInvoice(this AppLightningPayment lightningPayment) | ||
{ | ||
return new LightningInvoice() | ||
{ | ||
Id = lightningPayment.PaymentHash.ToString(), | ||
Amount = lightningPayment.Value, | ||
PaymentHash = lightningPayment.PaymentHash.ToString(), | ||
Preimage = lightningPayment.Preimage, | ||
PaidAt = lightningPayment.Status == LightningPaymentStatus.Complete? DateTimeOffset.UtcNow: null, //TODO: store these in ln payment | ||
BOLT11 = lightningPayment.PaymentRequest.ToString(), | ||
Status = lightningPayment.Status == LightningPaymentStatus.Complete? LightningInvoiceStatus.Paid: lightningPayment.PaymentRequest.ExpiryDate < DateTimeOffset.UtcNow? LightningInvoiceStatus.Expired: LightningInvoiceStatus.Unpaid | ||
}; | ||
} | ||
|
||
public static LightningPayment ToPayment(this AppLightningPayment lightningPayment) | ||
{ | ||
return new LightningPayment() | ||
{ | ||
Id = lightningPayment.PaymentHash.ToString(), | ||
Amount = LightMoney.MilliSatoshis(lightningPayment.Value), | ||
PaymentHash = lightningPayment.PaymentHash.ToString(), | ||
Preimage = lightningPayment.Preimage, | ||
BOLT11 = lightningPayment.PaymentRequest.ToString(), | ||
Status = lightningPayment.Status | ||
}; | ||
} | ||
|
||
public static async Task<List<LightningPayment>> ToPayments(this Task<List<AppLightningPayment>> appLightningPayments) | ||
{ | ||
var result = await appLightningPayments; | ||
return result.Select(ToPayment).ToList(); | ||
} | ||
public static async Task<List<LightningInvoice>> ToInvoices(this Task<List<AppLightningPayment>> appLightningPayments) | ||
{ | ||
var result = await appLightningPayments; | ||
return result.Select(ToInvoice).ToList(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.