diff --git a/BTCPayServer.Data/BTCPayServer.Data.csproj b/BTCPayServer.Data/BTCPayServer.Data.csproj
new file mode 100644
index 000000000..bf1f47887
--- /dev/null
+++ b/BTCPayServer.Data/BTCPayServer.Data.csproj
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BTCPayServer/Data/APIKeyData.cs b/BTCPayServer.Data/Data/APIKeyData.cs
similarity index 100%
rename from BTCPayServer/Data/APIKeyData.cs
rename to BTCPayServer.Data/Data/APIKeyData.cs
diff --git a/BTCPayServer.Data/Data/AddressInvoiceData.cs b/BTCPayServer.Data/Data/AddressInvoiceData.cs
new file mode 100644
index 000000000..4ae68a567
--- /dev/null
+++ b/BTCPayServer.Data/Data/AddressInvoiceData.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace BTCPayServer.Data
+{
+ public class AddressInvoiceData
+ {
+ ///
+ /// Some crypto currencies share same address prefix
+ /// For not having exceptions thrown by two address on different network, we suffix by "#CRYPTOCODE"
+ ///
+ [Obsolete("Use GetHash instead")]
+ public string Address
+ {
+ get; set;
+ }
+
+ public InvoiceData InvoiceData
+ {
+ get; set;
+ }
+
+ public string InvoiceDataId
+ {
+ get; set;
+ }
+
+ public DateTimeOffset? CreatedTime
+ {
+ get; set;
+ }
+
+ }
+}
diff --git a/BTCPayServer/Data/AppData.cs b/BTCPayServer.Data/Data/AppData.cs
similarity index 100%
rename from BTCPayServer/Data/AppData.cs
rename to BTCPayServer.Data/Data/AppData.cs
diff --git a/BTCPayServer/Data/ApplicationDbContext.cs b/BTCPayServer.Data/Data/ApplicationDbContext.cs
similarity index 96%
rename from BTCPayServer/Data/ApplicationDbContext.cs
rename to BTCPayServer.Data/Data/ApplicationDbContext.cs
index f1fe43964..d68f4f240 100644
--- a/BTCPayServer/Data/ApplicationDbContext.cs
+++ b/BTCPayServer.Data/Data/ApplicationDbContext.cs
@@ -1,11 +1,7 @@
-using System.Linq;
-using BTCPayServer.Authentication.OpenId.Models;
+using System;
+using System.Linq;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
-using BTCPayServer.Models;
-using BTCPayServer.Services.PaymentRequests;
-using BTCPayServer.Services.U2F.Models;
-using BTCPayServer.Storage.Models;
using Microsoft.EntityFrameworkCore.Infrastructure;
using OpenIddict.EntityFrameworkCore.Models;
@@ -229,7 +225,7 @@ namespace BTCPayServer.Data
.OnDelete(DeleteBehavior.Cascade);
builder.Entity()
.Property(e => e.Created)
- .HasDefaultValue(NBitcoin.Utils.UnixTimeToDateTime(0));
+ .HasDefaultValue(new DateTimeOffset(1970, 1, 1, 0, 0, 0, TimeSpan.Zero));
builder.Entity()
.HasIndex(o => o.Status);
diff --git a/BTCPayServer/Data/ApplicationDbContextFactory.cs b/BTCPayServer.Data/Data/ApplicationDbContextFactory.cs
similarity index 91%
rename from BTCPayServer/Data/ApplicationDbContextFactory.cs
rename to BTCPayServer.Data/Data/ApplicationDbContextFactory.cs
index 05611e87e..e4d0786b2 100644
--- a/BTCPayServer/Data/ApplicationDbContextFactory.cs
+++ b/BTCPayServer.Data/Data/ApplicationDbContextFactory.cs
@@ -88,13 +88,13 @@ namespace BTCPayServer.Data
public void ConfigureBuilder(DbContextOptionsBuilder builder)
{
if (_Type == DatabaseType.Sqlite)
- builder.UseSqlite(_ConnectionString);
+ builder.UseSqlite(_ConnectionString, o => o.MigrationsAssembly("BTCPayServer.Data"));
else if (_Type == DatabaseType.Postgres)
builder
- .UseNpgsql(_ConnectionString)
+ .UseNpgsql(_ConnectionString, o => o.MigrationsAssembly("BTCPayServer.Data"))
.ReplaceService();
else if (_Type == DatabaseType.MySQL)
- builder.UseMySql(_ConnectionString);
+ builder.UseMySql(_ConnectionString, o => o.MigrationsAssembly("BTCPayServer.Data"));
}
}
}
diff --git a/BTCPayServer/Models/ApplicationUser.cs b/BTCPayServer.Data/Data/ApplicationUser.cs
similarity index 83%
rename from BTCPayServer/Models/ApplicationUser.cs
rename to BTCPayServer.Data/Data/ApplicationUser.cs
index 9c87bb965..fd2b1b5d2 100644
--- a/BTCPayServer/Models/ApplicationUser.cs
+++ b/BTCPayServer.Data/Data/ApplicationUser.cs
@@ -2,13 +2,10 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
-using BTCPayServer.Authentication.OpenId.Models;
using Microsoft.AspNetCore.Identity;
using BTCPayServer.Data;
-using BTCPayServer.Services.U2F.Models;
-using BTCPayServer.Storage.Models;
-namespace BTCPayServer.Models
+namespace BTCPayServer.Data
{
// Add profile data for application users by adding properties to the ApplicationUser class
public class ApplicationUser : IdentityUser
diff --git a/BTCPayServer/Authentication/OpenId/Models/BTCPayOpenIdAuthorization.cs b/BTCPayServer.Data/Data/BTCPayOpenIdAuthorization.cs
similarity index 76%
rename from BTCPayServer/Authentication/OpenId/Models/BTCPayOpenIdAuthorization.cs
rename to BTCPayServer.Data/Data/BTCPayOpenIdAuthorization.cs
index 09dbf3691..cfc3c3bfc 100644
--- a/BTCPayServer/Authentication/OpenId/Models/BTCPayOpenIdAuthorization.cs
+++ b/BTCPayServer.Data/Data/BTCPayOpenIdAuthorization.cs
@@ -1,6 +1,6 @@
using OpenIddict.EntityFrameworkCore.Models;
-namespace BTCPayServer.Authentication.OpenId.Models
+namespace BTCPayServer.Data
{
public class BTCPayOpenIdAuthorization : OpenIddictAuthorization { }
-}
\ No newline at end of file
+}
diff --git a/BTCPayServer/Authentication/OpenId/Models/BTCPayOpenIdClient.cs b/BTCPayServer.Data/Data/BTCPayOpenIdClient.cs
similarity index 78%
rename from BTCPayServer/Authentication/OpenId/Models/BTCPayOpenIdClient.cs
rename to BTCPayServer.Data/Data/BTCPayOpenIdClient.cs
index bf2abb797..eb4e94b25 100644
--- a/BTCPayServer/Authentication/OpenId/Models/BTCPayOpenIdClient.cs
+++ b/BTCPayServer.Data/Data/BTCPayOpenIdClient.cs
@@ -1,7 +1,6 @@
-using BTCPayServer.Models;
using OpenIddict.EntityFrameworkCore.Models;
-namespace BTCPayServer.Authentication.OpenId.Models
+namespace BTCPayServer.Data
{
public class BTCPayOpenIdClient: OpenIddictApplication
{
diff --git a/BTCPayServer/Authentication/OpenId/Models/BTCPayOpenIdToken.cs b/BTCPayServer.Data/Data/BTCPayOpenIdToken.cs
similarity index 75%
rename from BTCPayServer/Authentication/OpenId/Models/BTCPayOpenIdToken.cs
rename to BTCPayServer.Data/Data/BTCPayOpenIdToken.cs
index 00714240a..94951a118 100644
--- a/BTCPayServer/Authentication/OpenId/Models/BTCPayOpenIdToken.cs
+++ b/BTCPayServer.Data/Data/BTCPayOpenIdToken.cs
@@ -1,6 +1,6 @@
using OpenIddict.EntityFrameworkCore.Models;
-namespace BTCPayServer.Authentication.OpenId.Models
+namespace BTCPayServer.Data
{
public class BTCPayOpenIdToken : OpenIddictToken { }
-}
\ No newline at end of file
+}
diff --git a/BTCPayServer/Data/HistoricalAddressInvoiceData.cs b/BTCPayServer.Data/Data/HistoricalAddressInvoiceData.cs
similarity index 51%
rename from BTCPayServer/Data/HistoricalAddressInvoiceData.cs
rename to BTCPayServer.Data/Data/HistoricalAddressInvoiceData.cs
index ad29d672b..9bcc2fbdc 100644
--- a/BTCPayServer/Data/HistoricalAddressInvoiceData.cs
+++ b/BTCPayServer.Data/Data/HistoricalAddressInvoiceData.cs
@@ -31,29 +31,6 @@ namespace BTCPayServer.Data
[Obsolete("Use GetCryptoCode instead")]
public string CryptoCode { get; set; }
-#pragma warning disable CS0618
- public Payments.PaymentMethodId GetPaymentMethodId()
- {
- return string.IsNullOrEmpty(CryptoCode) ? new Payments.PaymentMethodId("BTC", Payments.PaymentTypes.BTCLike)
- : Payments.PaymentMethodId.Parse(CryptoCode);
- }
- public string GetAddress()
- {
- if (Address == null)
- return null;
- var index = Address.IndexOf("#", StringComparison.InvariantCulture);
- if (index == -1)
- return Address;
- return Address.Substring(0, index);
- }
- public HistoricalAddressInvoiceData SetAddress(string depositAddress, string cryptoCode)
- {
- Address = depositAddress + "#" + cryptoCode;
- CryptoCode = cryptoCode;
- return this;
- }
-#pragma warning restore CS0618
-
public DateTimeOffset Assigned
{
get; set;
diff --git a/BTCPayServer/Data/InvoiceData.cs b/BTCPayServer.Data/Data/InvoiceData.cs
similarity index 87%
rename from BTCPayServer/Data/InvoiceData.cs
rename to BTCPayServer.Data/Data/InvoiceData.cs
index 4914c9e7e..22484a81e 100644
--- a/BTCPayServer/Data/InvoiceData.cs
+++ b/BTCPayServer.Data/Data/InvoiceData.cs
@@ -1,5 +1,4 @@
-using BTCPayServer.Models;
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
@@ -81,10 +80,5 @@ namespace BTCPayServer.Data
get; set;
}
public List PendingInvoices { get; set; }
-
- public Services.Invoices.InvoiceState GetInvoiceState()
- {
- return new Services.Invoices.InvoiceState(Status, ExceptionStatus);
- }
}
}
diff --git a/BTCPayServer/Data/InvoiceEventData.cs b/BTCPayServer.Data/Data/InvoiceEventData.cs
similarity index 89%
rename from BTCPayServer/Data/InvoiceEventData.cs
rename to BTCPayServer.Data/Data/InvoiceEventData.cs
index e968f44f6..23dd7901e 100644
--- a/BTCPayServer/Data/InvoiceEventData.cs
+++ b/BTCPayServer.Data/Data/InvoiceEventData.cs
@@ -15,7 +15,7 @@ namespace BTCPayServer.Data
{
get; set;
}
- public string UniqueId { get; internal set; }
+ public string UniqueId { get; set; }
public DateTimeOffset Timestamp
{
get; set;
diff --git a/BTCPayServer/Data/PairedSINData.cs b/BTCPayServer.Data/Data/PairedSINData.cs
similarity index 100%
rename from BTCPayServer/Data/PairedSINData.cs
rename to BTCPayServer.Data/Data/PairedSINData.cs
diff --git a/BTCPayServer/Data/PairingCodeData.cs b/BTCPayServer.Data/Data/PairingCodeData.cs
similarity index 100%
rename from BTCPayServer/Data/PairingCodeData.cs
rename to BTCPayServer.Data/Data/PairingCodeData.cs
diff --git a/BTCPayServer/Data/PaymentData.cs b/BTCPayServer.Data/Data/PaymentData.cs
similarity index 100%
rename from BTCPayServer/Data/PaymentData.cs
rename to BTCPayServer.Data/Data/PaymentData.cs
diff --git a/BTCPayServer.Data/Data/PaymentRequestData.cs b/BTCPayServer.Data/Data/PaymentRequestData.cs
new file mode 100644
index 000000000..0911b233b
--- /dev/null
+++ b/BTCPayServer.Data/Data/PaymentRequestData.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace BTCPayServer.Data
+{
+ public class PaymentRequestData
+ {
+ public string Id { get; set; }
+ public DateTimeOffset Created
+ {
+ get; set;
+ }
+ public string StoreDataId { get; set; }
+
+ public StoreData StoreData { get; set; }
+
+ public PaymentRequestStatus Status { get; set; }
+
+ public byte[] Blob { get; set; }
+
+ public class PaymentRequestBlob
+ {
+ public decimal Amount { get; set; }
+ public string Currency { get; set; }
+
+ public DateTime? ExpiryDate { get; set; }
+
+ public string Title { get; set; }
+ public string Description { get; set; }
+ public string Email { get; set; }
+
+ public string EmbeddedCSS { get; set; }
+ public string CustomCSSLink { get; set; }
+ public bool AllowCustomPaymentAmounts { get; set; }
+ }
+
+ public enum PaymentRequestStatus
+ {
+ Pending = 0,
+ Completed = 1,
+ Expired = 2
+ }
+ }
+}
diff --git a/BTCPayServer/Data/PendingInvoiceData.cs b/BTCPayServer.Data/Data/PendingInvoiceData.cs
similarity index 100%
rename from BTCPayServer/Data/PendingInvoiceData.cs
rename to BTCPayServer.Data/Data/PendingInvoiceData.cs
diff --git a/BTCPayServer/Data/RefundData.cs b/BTCPayServer.Data/Data/RefundData.cs
similarity index 100%
rename from BTCPayServer/Data/RefundData.cs
rename to BTCPayServer.Data/Data/RefundData.cs
diff --git a/BTCPayServer/Data/SettingData.cs b/BTCPayServer.Data/Data/SettingData.cs
similarity index 100%
rename from BTCPayServer/Data/SettingData.cs
rename to BTCPayServer.Data/Data/SettingData.cs
diff --git a/BTCPayServer.Data/Data/StoreData.cs b/BTCPayServer.Data/Data/StoreData.cs
new file mode 100644
index 000000000..ca9941842
--- /dev/null
+++ b/BTCPayServer.Data/Data/StoreData.cs
@@ -0,0 +1,102 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using Newtonsoft.Json.Linq;
+using System.Security.Claims;
+
+namespace BTCPayServer.Data
+{
+ public enum SpeedPolicy
+ {
+ HighSpeed = 0,
+ MediumSpeed = 1,
+ LowSpeed = 2,
+ LowMediumSpeed = 3
+ }
+ public class StoreData
+ {
+ public string Id
+ {
+ get;
+ set;
+ }
+
+ public List UserStores
+ {
+ get; set;
+ }
+ public List Apps
+ {
+ get; set;
+ }
+
+ public List PaymentRequests
+ {
+ get; set;
+ }
+
+ public List Invoices { get; set; }
+
+ [Obsolete("Use GetDerivationStrategies instead")]
+ public string DerivationStrategy
+ {
+ get; set;
+ }
+
+ [Obsolete("Use GetDerivationStrategies instead")]
+ public string DerivationStrategies
+ {
+ get;
+ set;
+ }
+
+ public string StoreName
+ {
+ get; set;
+ }
+
+ public SpeedPolicy SpeedPolicy
+ {
+ get; set;
+ }
+
+ public string StoreWebsite
+ {
+ get; set;
+ }
+
+ public byte[] StoreCertificate
+ {
+ get; set;
+ }
+
+ [NotMapped]
+ [Obsolete]
+ public string Role
+ {
+ get; set;
+ }
+
+ public byte[] StoreBlob
+ {
+ get;
+ set;
+ }
+ [Obsolete("Use GetDefaultPaymentId instead")]
+ public string DefaultCrypto { get; set; }
+ public List PairedSINs { get; set; }
+ public IEnumerable APIKeys { get; set; }
+
+ [NotMapped]
+ public List AdditionalClaims { get; set; } = new List();
+ }
+
+ public enum NetworkFeeMode
+ {
+ MultiplePaymentsOnly,
+ Always,
+ Never
+ }
+}
diff --git a/BTCPayServer/Storage/Models/StoredFile.cs b/BTCPayServer.Data/Data/StoredFile.cs
similarity index 88%
rename from BTCPayServer/Storage/Models/StoredFile.cs
rename to BTCPayServer.Data/Data/StoredFile.cs
index 6e7e668cd..27d3918d9 100644
--- a/BTCPayServer/Storage/Models/StoredFile.cs
+++ b/BTCPayServer.Data/Data/StoredFile.cs
@@ -1,8 +1,7 @@
using System;
using System.ComponentModel.DataAnnotations.Schema;
-using BTCPayServer.Models;
-namespace BTCPayServer.Storage.Models
+namespace BTCPayServer.Data
{
public class StoredFile
{
diff --git a/BTCPayServer/U2F/Models/U2FDevice.cs b/BTCPayServer.Data/Data/U2FDevice.cs
similarity index 88%
rename from BTCPayServer/U2F/Models/U2FDevice.cs
rename to BTCPayServer.Data/Data/U2FDevice.cs
index 5debe133a..87b09679b 100644
--- a/BTCPayServer/U2F/Models/U2FDevice.cs
+++ b/BTCPayServer.Data/Data/U2FDevice.cs
@@ -1,8 +1,7 @@
using System;
using System.ComponentModel.DataAnnotations;
-using BTCPayServer.Models;
-namespace BTCPayServer.Services.U2F.Models
+namespace BTCPayServer.Data
{
public class U2FDevice
{
diff --git a/BTCPayServer/Data/UserStore.cs b/BTCPayServer.Data/Data/UserStore.cs
similarity index 92%
rename from BTCPayServer/Data/UserStore.cs
rename to BTCPayServer.Data/Data/UserStore.cs
index f410b6c2e..89e6fab7d 100644
--- a/BTCPayServer/Data/UserStore.cs
+++ b/BTCPayServer.Data/Data/UserStore.cs
@@ -1,5 +1,4 @@
-using BTCPayServer.Models;
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
diff --git a/BTCPayServer/Data/WalletData.cs b/BTCPayServer.Data/Data/WalletData.cs
similarity index 79%
rename from BTCPayServer/Data/WalletData.cs
rename to BTCPayServer.Data/Data/WalletData.cs
index a977b0542..b259c4f0f 100644
--- a/BTCPayServer/Data/WalletData.cs
+++ b/BTCPayServer.Data/Data/WalletData.cs
@@ -14,25 +14,6 @@ namespace BTCPayServer.Data
public List WalletTransactions { get; set; }
public byte[] Blob { get; set; }
-
- public WalletBlobInfo GetBlobInfo()
- {
- if (Blob == null || Blob.Length == 0)
- {
- return new WalletBlobInfo();
- }
- var blobInfo = JsonConvert.DeserializeObject(ZipUtils.Unzip(Blob));
- return blobInfo;
- }
- public void SetBlobInfo(WalletBlobInfo blobInfo)
- {
- if (blobInfo == null)
- {
- Blob = Array.Empty();
- return;
- }
- Blob = ZipUtils.Zip(JsonConvert.SerializeObject(blobInfo));
- }
}
public class Label
diff --git a/BTCPayServer.Data/Data/WalletTransactionData.cs b/BTCPayServer.Data/Data/WalletTransactionData.cs
new file mode 100644
index 000000000..bbfbe32ee
--- /dev/null
+++ b/BTCPayServer.Data/Data/WalletTransactionData.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Newtonsoft.Json;
+
+namespace BTCPayServer.Data
+{
+ public class WalletTransactionData
+ {
+ public string WalletDataId { get; set; }
+ public WalletData WalletData { get; set; }
+ public string TransactionId { get; set; }
+ public string Labels { get; set; }
+ public byte[] Blob { get; set; }
+ }
+
+ public class WalletTransactionInfo
+ {
+ public string Comment { get; set; } = string.Empty;
+ [JsonIgnore]
+ public HashSet Labels { get; set; } = new HashSet();
+ }
+}
diff --git a/BTCPayServer/Migrations/20170913143004_Init.cs b/BTCPayServer.Data/Migrations/20170913143004_Init.cs
similarity index 98%
rename from BTCPayServer/Migrations/20170913143004_Init.cs
rename to BTCPayServer.Data/Migrations/20170913143004_Init.cs
index 149900b1f..cb85dd7d4 100644
--- a/BTCPayServer/Migrations/20170913143004_Init.cs
+++ b/BTCPayServer.Data/Migrations/20170913143004_Init.cs
@@ -1,9 +1,13 @@
-using Microsoft.EntityFrameworkCore.Migrations;
+using BTCPayServer.Data;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
using System;
using System.Collections.Generic;
namespace BTCPayServer.Migrations
{
+ [DbContext(typeof(ApplicationDbContext))]
+ [Migration("20170913143004_Init")]
public partial class Init : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
diff --git a/BTCPayServer/Migrations/20170926073744_Settings.cs b/BTCPayServer.Data/Migrations/20170926073744_Settings.cs
similarity index 79%
rename from BTCPayServer/Migrations/20170926073744_Settings.cs
rename to BTCPayServer.Data/Migrations/20170926073744_Settings.cs
index efca94c61..11d74400d 100644
--- a/BTCPayServer/Migrations/20170926073744_Settings.cs
+++ b/BTCPayServer.Data/Migrations/20170926073744_Settings.cs
@@ -1,9 +1,13 @@
-using Microsoft.EntityFrameworkCore.Migrations;
+using BTCPayServer.Data;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
using System;
using System.Collections.Generic;
namespace BTCPayServer.Migrations
{
+ [DbContext(typeof(ApplicationDbContext))]
+ [Migration("20170926073744_Settings")]
public partial class Settings : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
diff --git a/BTCPayServer/Migrations/20170926084408_RequiresEmailConfirmation.cs b/BTCPayServer.Data/Migrations/20170926084408_RequiresEmailConfirmation.cs
similarity index 74%
rename from BTCPayServer/Migrations/20170926084408_RequiresEmailConfirmation.cs
rename to BTCPayServer.Data/Migrations/20170926084408_RequiresEmailConfirmation.cs
index 48f2cfe23..c7964ee75 100644
--- a/BTCPayServer/Migrations/20170926084408_RequiresEmailConfirmation.cs
+++ b/BTCPayServer.Data/Migrations/20170926084408_RequiresEmailConfirmation.cs
@@ -1,9 +1,13 @@
-using Microsoft.EntityFrameworkCore.Migrations;
+using BTCPayServer.Data;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
using System;
using System.Collections.Generic;
namespace BTCPayServer.Migrations
{
+ [DbContext(typeof(ApplicationDbContext))]
+ [Migration("20170926084408_RequiresEmailConfirmation")]
public partial class RequiresEmailConfirmation : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
diff --git a/BTCPayServer/Migrations/20171006013443_AddressMapping.cs b/BTCPayServer.Data/Migrations/20171006013443_AddressMapping.cs
similarity index 86%
rename from BTCPayServer/Migrations/20171006013443_AddressMapping.cs
rename to BTCPayServer.Data/Migrations/20171006013443_AddressMapping.cs
index 18a312349..dea0c8a37 100644
--- a/BTCPayServer/Migrations/20171006013443_AddressMapping.cs
+++ b/BTCPayServer.Data/Migrations/20171006013443_AddressMapping.cs
@@ -1,9 +1,13 @@
-using Microsoft.EntityFrameworkCore.Migrations;
+using BTCPayServer.Data;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
using System;
using System.Collections.Generic;
namespace BTCPayServer.Migrations
{
+ [DbContext(typeof(ApplicationDbContext))]
+ [Migration("20171006013443_AddressMapping")]
public partial class AddressMapping : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
diff --git a/BTCPayServer/Migrations/20171010082424_Tokens.cs b/BTCPayServer.Data/Migrations/20171010082424_Tokens.cs
similarity index 92%
rename from BTCPayServer/Migrations/20171010082424_Tokens.cs
rename to BTCPayServer.Data/Migrations/20171010082424_Tokens.cs
index 9847f8a15..83910a2f9 100644
--- a/BTCPayServer/Migrations/20171010082424_Tokens.cs
+++ b/BTCPayServer.Data/Migrations/20171010082424_Tokens.cs
@@ -1,9 +1,13 @@
-using Microsoft.EntityFrameworkCore.Migrations;
+using BTCPayServer.Data;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
using System;
using System.Collections.Generic;
namespace BTCPayServer.Migrations
{
+ [DbContext(typeof(ApplicationDbContext))]
+ [Migration("20171010082424_Tokens")]
public partial class Tokens : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
diff --git a/BTCPayServer/Migrations/20171012020112_PendingInvoices.cs b/BTCPayServer.Data/Migrations/20171012020112_PendingInvoices.cs
similarity index 86%
rename from BTCPayServer/Migrations/20171012020112_PendingInvoices.cs
rename to BTCPayServer.Data/Migrations/20171012020112_PendingInvoices.cs
index 1711c54e6..bc9780f98 100644
--- a/BTCPayServer/Migrations/20171012020112_PendingInvoices.cs
+++ b/BTCPayServer.Data/Migrations/20171012020112_PendingInvoices.cs
@@ -1,9 +1,13 @@
-using Microsoft.EntityFrameworkCore.Migrations;
+using BTCPayServer.Data;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
using System;
using System.Collections.Generic;
namespace BTCPayServer.Migrations
{
+ [DbContext(typeof(ApplicationDbContext))]
+ [Migration("20171012020112_PendingInvoices")]
public partial class PendingInvoices : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
diff --git a/BTCPayServer/Migrations/20171023101754_StoreBlob.cs b/BTCPayServer.Data/Migrations/20171023101754_StoreBlob.cs
similarity index 72%
rename from BTCPayServer/Migrations/20171023101754_StoreBlob.cs
rename to BTCPayServer.Data/Migrations/20171023101754_StoreBlob.cs
index 01a8299fe..a0b59c199 100644
--- a/BTCPayServer/Migrations/20171023101754_StoreBlob.cs
+++ b/BTCPayServer.Data/Migrations/20171023101754_StoreBlob.cs
@@ -1,9 +1,13 @@
-using Microsoft.EntityFrameworkCore.Migrations;
+using BTCPayServer.Data;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
using System;
using System.Collections.Generic;
namespace BTCPayServer.Migrations
{
+ [DbContext(typeof(ApplicationDbContext))]
+ [Migration("20171023101754_StoreBlob")]
public partial class StoreBlob : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
diff --git a/BTCPayServer/Migrations/20171024163354_RenewUsedAddresses.cs b/BTCPayServer.Data/Migrations/20171024163354_RenewUsedAddresses.cs
similarity index 88%
rename from BTCPayServer/Migrations/20171024163354_RenewUsedAddresses.cs
rename to BTCPayServer.Data/Migrations/20171024163354_RenewUsedAddresses.cs
index 83b785dc4..c3628c86c 100644
--- a/BTCPayServer/Migrations/20171024163354_RenewUsedAddresses.cs
+++ b/BTCPayServer.Data/Migrations/20171024163354_RenewUsedAddresses.cs
@@ -1,9 +1,13 @@
-using Microsoft.EntityFrameworkCore.Migrations;
+using BTCPayServer.Data;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
using System;
using System.Collections.Generic;
namespace BTCPayServer.Migrations
{
+ [DbContext(typeof(ApplicationDbContext))]
+ [Migration("20171024163354_RenewUsedAddresses")]
public partial class RenewUsedAddresses : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
diff --git a/BTCPayServer/Migrations/20171105235734_PaymentAccounted.cs b/BTCPayServer.Data/Migrations/20171105235734_PaymentAccounted.cs
similarity index 73%
rename from BTCPayServer/Migrations/20171105235734_PaymentAccounted.cs
rename to BTCPayServer.Data/Migrations/20171105235734_PaymentAccounted.cs
index 49d2c1e15..b300a7303 100644
--- a/BTCPayServer/Migrations/20171105235734_PaymentAccounted.cs
+++ b/BTCPayServer.Data/Migrations/20171105235734_PaymentAccounted.cs
@@ -1,9 +1,13 @@
-using Microsoft.EntityFrameworkCore.Migrations;
+using BTCPayServer.Data;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
using System;
using System.Collections.Generic;
namespace BTCPayServer.Migrations
{
+ [DbContext(typeof(ApplicationDbContext))]
+ [Migration("20171105235734_PaymentAccounted")]
public partial class PaymentAccounted : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
diff --git a/BTCPayServer/Migrations/20171221054550_AltcoinSupport.cs b/BTCPayServer.Data/Migrations/20171221054550_AltcoinSupport.cs
similarity index 73%
rename from BTCPayServer/Migrations/20171221054550_AltcoinSupport.cs
rename to BTCPayServer.Data/Migrations/20171221054550_AltcoinSupport.cs
index 46e56da6c..5b0e73960 100644
--- a/BTCPayServer/Migrations/20171221054550_AltcoinSupport.cs
+++ b/BTCPayServer.Data/Migrations/20171221054550_AltcoinSupport.cs
@@ -1,9 +1,13 @@
-using Microsoft.EntityFrameworkCore.Migrations;
+using BTCPayServer.Data;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
using System;
using System.Collections.Generic;
namespace BTCPayServer.Migrations
{
+ [DbContext(typeof(ApplicationDbContext))]
+ [Migration("20171221054550_AltcoinSupport")]
public partial class AltcoinSupport : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
diff --git a/BTCPayServer/Migrations/20180106095215_DerivationStrategies.cs b/BTCPayServer.Data/Migrations/20180106095215_DerivationStrategies.cs
similarity index 73%
rename from BTCPayServer/Migrations/20180106095215_DerivationStrategies.cs
rename to BTCPayServer.Data/Migrations/20180106095215_DerivationStrategies.cs
index e2d22edc3..8b2d278fb 100644
--- a/BTCPayServer/Migrations/20180106095215_DerivationStrategies.cs
+++ b/BTCPayServer.Data/Migrations/20180106095215_DerivationStrategies.cs
@@ -1,9 +1,13 @@
-using Microsoft.EntityFrameworkCore.Migrations;
+using BTCPayServer.Data;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
using System;
using System.Collections.Generic;
namespace BTCPayServer.Migrations
{
+ [DbContext(typeof(ApplicationDbContext))]
+ [Migration("20180106095215_DerivationStrategies")]
public partial class DerivationStrategies : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
diff --git a/BTCPayServer/Migrations/20180109021122_defaultcrypto.cs b/BTCPayServer.Data/Migrations/20180109021122_defaultcrypto.cs
similarity index 72%
rename from BTCPayServer/Migrations/20180109021122_defaultcrypto.cs
rename to BTCPayServer.Data/Migrations/20180109021122_defaultcrypto.cs
index 7bf4da66f..40900d93b 100644
--- a/BTCPayServer/Migrations/20180109021122_defaultcrypto.cs
+++ b/BTCPayServer.Data/Migrations/20180109021122_defaultcrypto.cs
@@ -1,9 +1,13 @@
-using Microsoft.EntityFrameworkCore.Migrations;
+using BTCPayServer.Data;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
using System;
using System.Collections.Generic;
namespace BTCPayServer.Migrations
{
+ [DbContext(typeof(ApplicationDbContext))]
+ [Migration("20180109021122_defaultcrypto")]
public partial class defaultcrypto : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
diff --git a/BTCPayServer/Migrations/20180114123253_events.cs b/BTCPayServer.Data/Migrations/20180114123253_events.cs
similarity index 86%
rename from BTCPayServer/Migrations/20180114123253_events.cs
rename to BTCPayServer.Data/Migrations/20180114123253_events.cs
index 10d39acd0..447dcd817 100644
--- a/BTCPayServer/Migrations/20180114123253_events.cs
+++ b/BTCPayServer.Data/Migrations/20180114123253_events.cs
@@ -1,9 +1,13 @@
-using Microsoft.EntityFrameworkCore.Migrations;
+using BTCPayServer.Data;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
using System;
using System.Collections.Generic;
namespace BTCPayServer.Migrations
{
+ [DbContext(typeof(ApplicationDbContext))]
+ [Migration("20180114123253_events")]
public partial class events : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
diff --git a/BTCPayServer/Migrations/20180402095640_appdata.cs b/BTCPayServer.Data/Migrations/20180402095640_appdata.cs
similarity index 87%
rename from BTCPayServer/Migrations/20180402095640_appdata.cs
rename to BTCPayServer.Data/Migrations/20180402095640_appdata.cs
index fade33986..c6af520d1 100644
--- a/BTCPayServer/Migrations/20180402095640_appdata.cs
+++ b/BTCPayServer.Data/Migrations/20180402095640_appdata.cs
@@ -1,9 +1,13 @@
-using Microsoft.EntityFrameworkCore.Migrations;
+using BTCPayServer.Data;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
using System;
using System.Collections.Generic;
namespace BTCPayServer.Migrations
{
+ [DbContext(typeof(ApplicationDbContext))]
+ [Migration("20180402095640_appdata")]
public partial class appdata : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
diff --git a/BTCPayServer/Migrations/20180429083930_legacyapikey.cs b/BTCPayServer.Data/Migrations/20180429083930_legacyapikey.cs
similarity index 82%
rename from BTCPayServer/Migrations/20180429083930_legacyapikey.cs
rename to BTCPayServer.Data/Migrations/20180429083930_legacyapikey.cs
index 0a1d21bb5..024cd60b3 100644
--- a/BTCPayServer/Migrations/20180429083930_legacyapikey.cs
+++ b/BTCPayServer.Data/Migrations/20180429083930_legacyapikey.cs
@@ -1,9 +1,13 @@
-using Microsoft.EntityFrameworkCore.Migrations;
+using BTCPayServer.Data;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
using System;
using System.Collections.Generic;
namespace BTCPayServer.Migrations
{
+ [DbContext(typeof(ApplicationDbContext))]
+ [Migration("20180429083930_legacyapikey")]
public partial class legacyapikey : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
diff --git a/BTCPayServer/Migrations/20180719095626_CanDeleteStores.cs b/BTCPayServer.Data/Migrations/20180719095626_CanDeleteStores.cs
similarity index 96%
rename from BTCPayServer/Migrations/20180719095626_CanDeleteStores.cs
rename to BTCPayServer.Data/Migrations/20180719095626_CanDeleteStores.cs
index f4dd95eff..bfa60ba83 100644
--- a/BTCPayServer/Migrations/20180719095626_CanDeleteStores.cs
+++ b/BTCPayServer.Data/Migrations/20180719095626_CanDeleteStores.cs
@@ -1,7 +1,11 @@
-using Microsoft.EntityFrameworkCore.Migrations;
+using BTCPayServer.Data;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
namespace BTCPayServer.Migrations
{
+ [DbContext(typeof(ApplicationDbContext))]
+ [Migration("20180719095626_CanDeleteStores")]
public partial class CanDeleteStores : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
diff --git a/BTCPayServer/Migrations/20190121133309_AddPaymentRequests.cs b/BTCPayServer.Data/Migrations/20190121133309_AddPaymentRequests.cs
similarity index 90%
rename from BTCPayServer/Migrations/20190121133309_AddPaymentRequests.cs
rename to BTCPayServer.Data/Migrations/20190121133309_AddPaymentRequests.cs
index 5c3ec7e84..c021fb361 100644
--- a/BTCPayServer/Migrations/20190121133309_AddPaymentRequests.cs
+++ b/BTCPayServer.Data/Migrations/20190121133309_AddPaymentRequests.cs
@@ -1,8 +1,12 @@
using System;
+using BTCPayServer.Data;
+using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
namespace BTCPayServer.Migrations
{
+ [DbContext(typeof(ApplicationDbContext))]
+ [Migration("20190121133309_AddPaymentRequests")]
public partial class AddPaymentRequests : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
diff --git a/BTCPayServer/Migrations/20190219032533_AppsTagging.cs b/BTCPayServer.Data/Migrations/20190219032533_AppsTagging.cs
similarity index 72%
rename from BTCPayServer/Migrations/20190219032533_AppsTagging.cs
rename to BTCPayServer.Data/Migrations/20190219032533_AppsTagging.cs
index fcbc47f14..2fb837af4 100644
--- a/BTCPayServer/Migrations/20190219032533_AppsTagging.cs
+++ b/BTCPayServer.Data/Migrations/20190219032533_AppsTagging.cs
@@ -1,7 +1,11 @@
-using Microsoft.EntityFrameworkCore.Migrations;
+using BTCPayServer.Data;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
namespace BTCPayServer.Migrations
{
+ [DbContext(typeof(ApplicationDbContext))]
+ [Migration("20190219032533_AppsTagging")]
public partial class AppsTagging : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
diff --git a/BTCPayServer/Migrations/20190225091644_AddOpenIddict.cs b/BTCPayServer.Data/Migrations/20190225091644_AddOpenIddict.cs
similarity index 97%
rename from BTCPayServer/Migrations/20190225091644_AddOpenIddict.cs
rename to BTCPayServer.Data/Migrations/20190225091644_AddOpenIddict.cs
index e2181ce56..326f3ca96 100644
--- a/BTCPayServer/Migrations/20190225091644_AddOpenIddict.cs
+++ b/BTCPayServer.Data/Migrations/20190225091644_AddOpenIddict.cs
@@ -1,8 +1,12 @@
using System;
+using BTCPayServer.Data;
+using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
namespace BTCPayServer.Migrations
{
+ [DbContext(typeof(ApplicationDbContext))]
+ [Migration("20190225091644_AddOpenIddict")]
public partial class AddOpenIddict : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
diff --git a/BTCPayServer/Migrations/20190324141717_AddFiles.cs b/BTCPayServer.Data/Migrations/20190324141717_AddFiles.cs
similarity index 90%
rename from BTCPayServer/Migrations/20190324141717_AddFiles.cs
rename to BTCPayServer.Data/Migrations/20190324141717_AddFiles.cs
index f7833ec6d..105d17eaa 100644
--- a/BTCPayServer/Migrations/20190324141717_AddFiles.cs
+++ b/BTCPayServer.Data/Migrations/20190324141717_AddFiles.cs
@@ -1,8 +1,12 @@
using System;
+using BTCPayServer.Data;
+using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
namespace BTCPayServer.Migrations
{
+ [DbContext(typeof(ApplicationDbContext))]
+ [Migration("20190324141717_AddFiles")]
public partial class AddFiles : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
diff --git a/BTCPayServer/Migrations/20190425081749_AddU2fDevices.cs b/BTCPayServer.Data/Migrations/20190425081749_AddU2fDevices.cs
similarity index 93%
rename from BTCPayServer/Migrations/20190425081749_AddU2fDevices.cs
rename to BTCPayServer.Data/Migrations/20190425081749_AddU2fDevices.cs
index 7b90d6cca..56df61156 100644
--- a/BTCPayServer/Migrations/20190425081749_AddU2fDevices.cs
+++ b/BTCPayServer.Data/Migrations/20190425081749_AddU2fDevices.cs
@@ -1,8 +1,12 @@
using System;
+using BTCPayServer.Data;
+using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
namespace BTCPayServer.Migrations
{
+ [DbContext(typeof(ApplicationDbContext))]
+ [Migration("20190425081749_AddU2fDevices")]
public partial class AddU2fDevices : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
diff --git a/BTCPayServer/Migrations/20190701082105_sort_paymentrequests.cs b/BTCPayServer.Data/Migrations/20190701082105_sort_paymentrequests.cs
similarity index 81%
rename from BTCPayServer/Migrations/20190701082105_sort_paymentrequests.cs
rename to BTCPayServer.Data/Migrations/20190701082105_sort_paymentrequests.cs
index f6b4ad1fe..acc290dd4 100644
--- a/BTCPayServer/Migrations/20190701082105_sort_paymentrequests.cs
+++ b/BTCPayServer.Data/Migrations/20190701082105_sort_paymentrequests.cs
@@ -1,8 +1,12 @@
using System;
+using BTCPayServer.Data;
+using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
namespace BTCPayServer.Migrations
{
+ [DbContext(typeof(ApplicationDbContext))]
+ [Migration("20190701082105_sort_paymentrequests")]
public partial class sort_paymentrequests : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
diff --git a/BTCPayServer/Migrations/20190802142637_WalletData.cs b/BTCPayServer.Data/Migrations/20190802142637_WalletData.cs
similarity index 91%
rename from BTCPayServer/Migrations/20190802142637_WalletData.cs
rename to BTCPayServer.Data/Migrations/20190802142637_WalletData.cs
index 86b213240..fa600e54c 100644
--- a/BTCPayServer/Migrations/20190802142637_WalletData.cs
+++ b/BTCPayServer.Data/Migrations/20190802142637_WalletData.cs
@@ -1,8 +1,12 @@
using System;
+using BTCPayServer.Data;
+using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
namespace BTCPayServer.Migrations
{
+ [DbContext(typeof(ApplicationDbContext))]
+ [Migration("20190802142637_WalletData")]
public partial class WalletData : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
diff --git a/BTCPayServer.Data/Migrations/ApplicationDbContextModelSnapshot.cs b/BTCPayServer.Data/Migrations/ApplicationDbContextModelSnapshot.cs
new file mode 100644
index 000000000..6aacb5462
--- /dev/null
+++ b/BTCPayServer.Data/Migrations/ApplicationDbContextModelSnapshot.cs
@@ -0,0 +1,883 @@
+//
+using System;
+using BTCPayServer.Data;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+namespace BTCPayServer.Migrations
+{
+ [DbContext(typeof(ApplicationDbContext))]
+ partial class ApplicationDbContextModelSnapshot : ModelSnapshot
+ {
+ protected override void BuildModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "2.1.11-servicing-32099");
+
+ modelBuilder.Entity("BTCPayServer.Data.AddressInvoiceData", b =>
+ {
+ b.Property("Address")
+ .ValueGeneratedOnAdd();
+
+ b.Property("CreatedTime");
+
+ b.Property("InvoiceDataId");
+
+ b.HasKey("Address");
+
+ b.HasIndex("InvoiceDataId");
+
+ b.ToTable("AddressInvoices");
+ });
+
+ modelBuilder.Entity("BTCPayServer.Data.APIKeyData", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasMaxLength(50);
+
+ b.Property("StoreId")
+ .HasMaxLength(50);
+
+ b.HasKey("Id");
+
+ b.HasIndex("StoreId");
+
+ b.ToTable("ApiKeys");
+ });
+
+ modelBuilder.Entity("BTCPayServer.Data.AppData", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("AppType");
+
+ b.Property("Created");
+
+ b.Property("Name");
+
+ b.Property("Settings");
+
+ b.Property("StoreDataId");
+
+ b.Property("TagAllInvoices");
+
+ b.HasKey("Id");
+
+ b.HasIndex("StoreDataId");
+
+ b.ToTable("Apps");
+ });
+
+ modelBuilder.Entity("BTCPayServer.Data.ApplicationUser", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("AccessFailedCount");
+
+ b.Property("ConcurrencyStamp")
+ .IsConcurrencyToken();
+
+ b.Property("Email")
+ .HasMaxLength(256);
+
+ b.Property("EmailConfirmed");
+
+ b.Property("LockoutEnabled");
+
+ b.Property("LockoutEnd");
+
+ b.Property("NormalizedEmail")
+ .HasMaxLength(256);
+
+ b.Property("NormalizedUserName")
+ .HasMaxLength(256);
+
+ b.Property("PasswordHash");
+
+ b.Property("PhoneNumber");
+
+ b.Property("PhoneNumberConfirmed");
+
+ b.Property("RequiresEmailConfirmation");
+
+ b.Property("SecurityStamp");
+
+ b.Property("TwoFactorEnabled");
+
+ b.Property("UserName")
+ .HasMaxLength(256);
+
+ b.HasKey("Id");
+
+ b.HasIndex("NormalizedEmail")
+ .HasName("EmailIndex");
+
+ b.HasIndex("NormalizedUserName")
+ .IsUnique()
+ .HasName("UserNameIndex");
+
+ b.ToTable("AspNetUsers");
+ });
+
+ modelBuilder.Entity("BTCPayServer.Data.BTCPayOpenIdAuthorization", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("ApplicationId");
+
+ b.Property("ConcurrencyToken")
+ .IsConcurrencyToken()
+ .HasMaxLength(50);
+
+ b.Property("Properties");
+
+ b.Property("Scopes");
+
+ b.Property("Status")
+ .IsRequired()
+ .HasMaxLength(25);
+
+ b.Property("Subject")
+ .IsRequired()
+ .HasMaxLength(450);
+
+ b.Property("Type")
+ .IsRequired()
+ .HasMaxLength(25);
+
+ b.HasKey("Id");
+
+ b.HasIndex("ApplicationId", "Status", "Subject", "Type");
+
+ b.ToTable("OpenIddictAuthorizations");
+ });
+
+ modelBuilder.Entity("BTCPayServer.Data.BTCPayOpenIdClient", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("ApplicationUserId");
+
+ b.Property("ClientId")
+ .IsRequired()
+ .HasMaxLength(100);
+
+ b.Property("ClientSecret");
+
+ b.Property("ConcurrencyToken")
+ .IsConcurrencyToken()
+ .HasMaxLength(50);
+
+ b.Property("ConsentType");
+
+ b.Property("DisplayName");
+
+ b.Property("Permissions");
+
+ b.Property("PostLogoutRedirectUris");
+
+ b.Property("Properties");
+
+ b.Property("RedirectUris");
+
+ b.Property("Type")
+ .IsRequired()
+ .HasMaxLength(25);
+
+ b.HasKey("Id");
+
+ b.HasIndex("ApplicationUserId");
+
+ b.HasIndex("ClientId")
+ .IsUnique();
+
+ b.ToTable("OpenIddictApplications");
+ });
+
+ modelBuilder.Entity("BTCPayServer.Data.BTCPayOpenIdToken", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("ApplicationId");
+
+ b.Property("AuthorizationId");
+
+ b.Property("ConcurrencyToken")
+ .IsConcurrencyToken()
+ .HasMaxLength(50);
+
+ b.Property("CreationDate");
+
+ b.Property("ExpirationDate");
+
+ b.Property("Payload");
+
+ b.Property("Properties");
+
+ b.Property("ReferenceId")
+ .HasMaxLength(100);
+
+ b.Property("Status")
+ .IsRequired()
+ .HasMaxLength(25);
+
+ b.Property("Subject")
+ .IsRequired()
+ .HasMaxLength(450);
+
+ b.Property("Type")
+ .IsRequired()
+ .HasMaxLength(25);
+
+ b.HasKey("Id");
+
+ b.HasIndex("AuthorizationId");
+
+ b.HasIndex("ReferenceId")
+ .IsUnique();
+
+ b.HasIndex("ApplicationId", "Status", "Subject", "Type");
+
+ b.ToTable("OpenIddictTokens");
+ });
+
+ modelBuilder.Entity("BTCPayServer.Data.HistoricalAddressInvoiceData", b =>
+ {
+ b.Property("InvoiceDataId");
+
+ b.Property("Address");
+
+ b.Property("Assigned");
+
+ b.Property("CryptoCode");
+
+ b.Property("UnAssigned");
+
+ b.HasKey("InvoiceDataId", "Address");
+
+ b.ToTable("HistoricalAddressInvoices");
+ });
+
+ modelBuilder.Entity("BTCPayServer.Data.InvoiceData", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("Blob");
+
+ b.Property("Created");
+
+ b.Property("CustomerEmail");
+
+ b.Property("ExceptionStatus");
+
+ b.Property("ItemCode");
+
+ b.Property("OrderId");
+
+ b.Property("Status");
+
+ b.Property("StoreDataId");
+
+ b.HasKey("Id");
+
+ b.HasIndex("StoreDataId");
+
+ b.ToTable("Invoices");
+ });
+
+ modelBuilder.Entity("BTCPayServer.Data.InvoiceEventData", b =>
+ {
+ b.Property("InvoiceDataId");
+
+ b.Property("UniqueId");
+
+ b.Property("Message");
+
+ b.Property("Timestamp");
+
+ b.HasKey("InvoiceDataId", "UniqueId");
+
+ b.ToTable("InvoiceEvents");
+ });
+
+ modelBuilder.Entity("BTCPayServer.Data.PairedSINData", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("Label");
+
+ b.Property("PairingTime");
+
+ b.Property("SIN");
+
+ b.Property("StoreDataId");
+
+ b.HasKey("Id");
+
+ b.HasIndex("SIN");
+
+ b.HasIndex("StoreDataId");
+
+ b.ToTable("PairedSINData");
+ });
+
+ modelBuilder.Entity("BTCPayServer.Data.PairingCodeData", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("DateCreated");
+
+ b.Property("Expiration");
+
+ b.Property("Facade");
+
+ b.Property("Label");
+
+ b.Property("SIN");
+
+ b.Property("StoreDataId");
+
+ b.Property("TokenValue");
+
+ b.HasKey("Id");
+
+ b.ToTable("PairingCodes");
+ });
+
+ modelBuilder.Entity("BTCPayServer.Data.PaymentData", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("Accounted");
+
+ b.Property("Blob");
+
+ b.Property("InvoiceDataId");
+
+ b.HasKey("Id");
+
+ b.HasIndex("InvoiceDataId");
+
+ b.ToTable("Payments");
+ });
+
+ modelBuilder.Entity("BTCPayServer.Data.PaymentRequestData", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("Blob");
+
+ b.Property("Created")
+ .ValueGeneratedOnAdd()
+ .HasDefaultValue(new DateTimeOffset(new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)));
+
+ b.Property("Status");
+
+ b.Property("StoreDataId");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Status");
+
+ b.HasIndex("StoreDataId");
+
+ b.ToTable("PaymentRequests");
+ });
+
+ modelBuilder.Entity("BTCPayServer.Data.PendingInvoiceData", b =>
+ {
+ b.Property("Id");
+
+ b.HasKey("Id");
+
+ b.ToTable("PendingInvoices");
+ });
+
+ modelBuilder.Entity("BTCPayServer.Data.RefundAddressesData", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("Blob");
+
+ b.Property("InvoiceDataId");
+
+ b.HasKey("Id");
+
+ b.HasIndex("InvoiceDataId");
+
+ b.ToTable("RefundAddresses");
+ });
+
+ modelBuilder.Entity("BTCPayServer.Data.SettingData", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("Value");
+
+ b.HasKey("Id");
+
+ b.ToTable("Settings");
+ });
+
+ modelBuilder.Entity("BTCPayServer.Data.StoreData", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("DefaultCrypto");
+
+ b.Property("DerivationStrategies");
+
+ b.Property("DerivationStrategy");
+
+ b.Property("SpeedPolicy");
+
+ b.Property("StoreBlob");
+
+ b.Property("StoreCertificate");
+
+ b.Property("StoreName");
+
+ b.Property("StoreWebsite");
+
+ b.HasKey("Id");
+
+ b.ToTable("Stores");
+ });
+
+ modelBuilder.Entity("BTCPayServer.Data.StoredFile", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("ApplicationUserId");
+
+ b.Property("FileName");
+
+ b.Property("StorageFileName");
+
+ b.Property("Timestamp");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ApplicationUserId");
+
+ b.ToTable("Files");
+ });
+
+ modelBuilder.Entity("BTCPayServer.Data.U2FDevice", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("ApplicationUserId");
+
+ b.Property("AttestationCert")
+ .IsRequired();
+
+ b.Property("Counter");
+
+ b.Property("KeyHandle")
+ .IsRequired();
+
+ b.Property("Name");
+
+ b.Property("PublicKey")
+ .IsRequired();
+
+ b.HasKey("Id");
+
+ b.HasIndex("ApplicationUserId");
+
+ b.ToTable("U2FDevices");
+ });
+
+ modelBuilder.Entity("BTCPayServer.Data.UserStore", b =>
+ {
+ b.Property("ApplicationUserId");
+
+ b.Property("StoreDataId");
+
+ b.Property("Role");
+
+ b.HasKey("ApplicationUserId", "StoreDataId");
+
+ b.HasIndex("StoreDataId");
+
+ b.ToTable("UserStore");
+ });
+
+ modelBuilder.Entity("BTCPayServer.Data.WalletData", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("Blob");
+
+ b.HasKey("Id");
+
+ b.ToTable("Wallets");
+ });
+
+ modelBuilder.Entity("BTCPayServer.Data.WalletTransactionData", b =>
+ {
+ b.Property("WalletDataId");
+
+ b.Property("TransactionId");
+
+ b.Property("Blob");
+
+ b.Property("Labels");
+
+ b.HasKey("WalletDataId", "TransactionId");
+
+ b.ToTable("WalletTransactions");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("ConcurrencyStamp")
+ .IsConcurrencyToken();
+
+ b.Property("Name")
+ .HasMaxLength(256);
+
+ b.Property("NormalizedName")
+ .HasMaxLength(256);
+
+ b.HasKey("Id");
+
+ b.HasIndex("NormalizedName")
+ .IsUnique()
+ .HasName("RoleNameIndex");
+
+ b.ToTable("AspNetRoles");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("ClaimType");
+
+ b.Property("ClaimValue");
+
+ b.Property("RoleId")
+ .IsRequired();
+
+ b.HasKey("Id");
+
+ b.HasIndex("RoleId");
+
+ b.ToTable("AspNetRoleClaims");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("ClaimType");
+
+ b.Property("ClaimValue");
+
+ b.Property("UserId")
+ .IsRequired();
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("AspNetUserClaims");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b =>
+ {
+ b.Property("LoginProvider");
+
+ b.Property("ProviderKey");
+
+ b.Property("ProviderDisplayName");
+
+ b.Property("UserId")
+ .IsRequired();
+
+ b.HasKey("LoginProvider", "ProviderKey");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("AspNetUserLogins");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b =>
+ {
+ b.Property("UserId");
+
+ b.Property("RoleId");
+
+ b.HasKey("UserId", "RoleId");
+
+ b.HasIndex("RoleId");
+
+ b.ToTable("AspNetUserRoles");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b =>
+ {
+ b.Property("UserId");
+
+ b.Property("LoginProvider");
+
+ b.Property("Name");
+
+ b.Property("Value");
+
+ b.HasKey("UserId", "LoginProvider", "Name");
+
+ b.ToTable("AspNetUserTokens");
+ });
+
+ modelBuilder.Entity("OpenIddict.EntityFrameworkCore.Models.OpenIddictScope", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("ConcurrencyToken")
+ .IsConcurrencyToken()
+ .HasMaxLength(50);
+
+ b.Property("Description");
+
+ b.Property("DisplayName");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(200);
+
+ b.Property("Properties");
+
+ b.Property("Resources");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Name")
+ .IsUnique();
+
+ b.ToTable("OpenIddictScopes");
+ });
+
+ modelBuilder.Entity("BTCPayServer.Data.AddressInvoiceData", b =>
+ {
+ b.HasOne("BTCPayServer.Data.InvoiceData", "InvoiceData")
+ .WithMany("AddressInvoices")
+ .HasForeignKey("InvoiceDataId")
+ .OnDelete(DeleteBehavior.Cascade);
+ });
+
+ modelBuilder.Entity("BTCPayServer.Data.APIKeyData", b =>
+ {
+ b.HasOne("BTCPayServer.Data.StoreData", "StoreData")
+ .WithMany("APIKeys")
+ .HasForeignKey("StoreId")
+ .OnDelete(DeleteBehavior.Cascade);
+ });
+
+ modelBuilder.Entity("BTCPayServer.Data.AppData", b =>
+ {
+ b.HasOne("BTCPayServer.Data.StoreData", "StoreData")
+ .WithMany("Apps")
+ .HasForeignKey("StoreDataId")
+ .OnDelete(DeleteBehavior.Cascade);
+ });
+
+ modelBuilder.Entity("BTCPayServer.Data.BTCPayOpenIdAuthorization", b =>
+ {
+ b.HasOne("BTCPayServer.Data.BTCPayOpenIdClient", "Application")
+ .WithMany("Authorizations")
+ .HasForeignKey("ApplicationId");
+ });
+
+ modelBuilder.Entity("BTCPayServer.Data.BTCPayOpenIdClient", b =>
+ {
+ b.HasOne("BTCPayServer.Data.ApplicationUser", "ApplicationUser")
+ .WithMany("OpenIdClients")
+ .HasForeignKey("ApplicationUserId");
+ });
+
+ modelBuilder.Entity("BTCPayServer.Data.BTCPayOpenIdToken", b =>
+ {
+ b.HasOne("BTCPayServer.Data.BTCPayOpenIdClient", "Application")
+ .WithMany("Tokens")
+ .HasForeignKey("ApplicationId");
+
+ b.HasOne("BTCPayServer.Data.BTCPayOpenIdAuthorization", "Authorization")
+ .WithMany("Tokens")
+ .HasForeignKey("AuthorizationId");
+ });
+
+ modelBuilder.Entity("BTCPayServer.Data.HistoricalAddressInvoiceData", b =>
+ {
+ b.HasOne("BTCPayServer.Data.InvoiceData", "InvoiceData")
+ .WithMany("HistoricalAddressInvoices")
+ .HasForeignKey("InvoiceDataId")
+ .OnDelete(DeleteBehavior.Cascade);
+ });
+
+ modelBuilder.Entity("BTCPayServer.Data.InvoiceData", b =>
+ {
+ b.HasOne("BTCPayServer.Data.StoreData", "StoreData")
+ .WithMany("Invoices")
+ .HasForeignKey("StoreDataId")
+ .OnDelete(DeleteBehavior.Cascade);
+ });
+
+ modelBuilder.Entity("BTCPayServer.Data.InvoiceEventData", b =>
+ {
+ b.HasOne("BTCPayServer.Data.InvoiceData", "InvoiceData")
+ .WithMany("Events")
+ .HasForeignKey("InvoiceDataId")
+ .OnDelete(DeleteBehavior.Cascade);
+ });
+
+ modelBuilder.Entity("BTCPayServer.Data.PairedSINData", b =>
+ {
+ b.HasOne("BTCPayServer.Data.StoreData", "StoreData")
+ .WithMany("PairedSINs")
+ .HasForeignKey("StoreDataId")
+ .OnDelete(DeleteBehavior.Cascade);
+ });
+
+ modelBuilder.Entity("BTCPayServer.Data.PaymentData", b =>
+ {
+ b.HasOne("BTCPayServer.Data.InvoiceData", "InvoiceData")
+ .WithMany("Payments")
+ .HasForeignKey("InvoiceDataId")
+ .OnDelete(DeleteBehavior.Cascade);
+ });
+
+ modelBuilder.Entity("BTCPayServer.Data.PaymentRequestData", b =>
+ {
+ b.HasOne("BTCPayServer.Data.StoreData", "StoreData")
+ .WithMany("PaymentRequests")
+ .HasForeignKey("StoreDataId")
+ .OnDelete(DeleteBehavior.Cascade);
+ });
+
+ modelBuilder.Entity("BTCPayServer.Data.PendingInvoiceData", b =>
+ {
+ b.HasOne("BTCPayServer.Data.InvoiceData", "InvoiceData")
+ .WithMany("PendingInvoices")
+ .HasForeignKey("Id")
+ .OnDelete(DeleteBehavior.Cascade);
+ });
+
+ modelBuilder.Entity("BTCPayServer.Data.RefundAddressesData", b =>
+ {
+ b.HasOne("BTCPayServer.Data.InvoiceData", "InvoiceData")
+ .WithMany("RefundAddresses")
+ .HasForeignKey("InvoiceDataId")
+ .OnDelete(DeleteBehavior.Cascade);
+ });
+
+ modelBuilder.Entity("BTCPayServer.Data.StoredFile", b =>
+ {
+ b.HasOne("BTCPayServer.Data.ApplicationUser", "ApplicationUser")
+ .WithMany("StoredFiles")
+ .HasForeignKey("ApplicationUserId");
+ });
+
+ modelBuilder.Entity("BTCPayServer.Data.U2FDevice", b =>
+ {
+ b.HasOne("BTCPayServer.Data.ApplicationUser", "ApplicationUser")
+ .WithMany("U2FDevices")
+ .HasForeignKey("ApplicationUserId");
+ });
+
+ modelBuilder.Entity("BTCPayServer.Data.UserStore", b =>
+ {
+ b.HasOne("BTCPayServer.Data.ApplicationUser", "ApplicationUser")
+ .WithMany("UserStores")
+ .HasForeignKey("ApplicationUserId")
+ .OnDelete(DeleteBehavior.Cascade);
+
+ b.HasOne("BTCPayServer.Data.StoreData", "StoreData")
+ .WithMany("UserStores")
+ .HasForeignKey("StoreDataId")
+ .OnDelete(DeleteBehavior.Cascade);
+ });
+
+ modelBuilder.Entity("BTCPayServer.Data.WalletTransactionData", b =>
+ {
+ b.HasOne("BTCPayServer.Data.WalletData", "WalletData")
+ .WithMany("WalletTransactions")
+ .HasForeignKey("WalletDataId")
+ .OnDelete(DeleteBehavior.Cascade);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b =>
+ {
+ b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole")
+ .WithMany()
+ .HasForeignKey("RoleId")
+ .OnDelete(DeleteBehavior.Cascade);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b =>
+ {
+ b.HasOne("BTCPayServer.Data.ApplicationUser")
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b =>
+ {
+ b.HasOne("BTCPayServer.Data.ApplicationUser")
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b =>
+ {
+ b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole")
+ .WithMany()
+ .HasForeignKey("RoleId")
+ .OnDelete(DeleteBehavior.Cascade);
+
+ b.HasOne("BTCPayServer.Data.ApplicationUser")
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b =>
+ {
+ b.HasOne("BTCPayServer.Data.ApplicationUser")
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade);
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/BTCPayServer.Data/MigrationsExtensions.cs b/BTCPayServer.Data/MigrationsExtensions.cs
new file mode 100644
index 000000000..4a55466c0
--- /dev/null
+++ b/BTCPayServer.Data/MigrationsExtensions.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+
+namespace BTCPayServer.Migrations
+{
+ public static class MigrationsExtensions
+ {
+ public static bool SupportDropColumn(this Microsoft.EntityFrameworkCore.Migrations.Migration migration, string activeProvider)
+ {
+ return activeProvider != "Microsoft.EntityFrameworkCore.Sqlite";
+ }
+
+ public static bool SupportDropForeignKey(this Microsoft.EntityFrameworkCore.Migrations.Migration migration, string activeProvider)
+ {
+ return activeProvider != "Microsoft.EntityFrameworkCore.Sqlite";
+ }
+ public static bool SupportDropForeignKey(this DatabaseFacade facade)
+ {
+ return facade.ProviderName != "Microsoft.EntityFrameworkCore.Sqlite";
+ }
+ }
+}
diff --git a/BTCPayServer.Tests/CoinSwitchTests.cs b/BTCPayServer.Tests/CoinSwitchTests.cs
index cfecfb678..53c348163 100644
--- a/BTCPayServer.Tests/CoinSwitchTests.cs
+++ b/BTCPayServer.Tests/CoinSwitchTests.cs
@@ -5,6 +5,7 @@ using BTCPayServer.Tests.Logging;
using Microsoft.AspNetCore.Mvc;
using Xunit;
using Xunit.Abstractions;
+using BTCPayServer.Data;
namespace BTCPayServer.Tests
{
diff --git a/BTCPayServer.Tests/TestAccount.cs b/BTCPayServer.Tests/TestAccount.cs
index 555583f78..93dd9ef2d 100644
--- a/BTCPayServer.Tests/TestAccount.cs
+++ b/BTCPayServer.Tests/TestAccount.cs
@@ -10,7 +10,6 @@ using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
-using BTCPayServer.Authentication.OpenId.Models;
using Xunit;
using NBXplorer.DerivationStrategy;
using BTCPayServer.Payments;
diff --git a/BTCPayServer/Authentication/OpenId/AuthorizationCodeGrantTypeEventHandler.cs b/BTCPayServer/Authentication/OpenId/AuthorizationCodeGrantTypeEventHandler.cs
index 91eed8966..0352139e1 100644
--- a/BTCPayServer/Authentication/OpenId/AuthorizationCodeGrantTypeEventHandler.cs
+++ b/BTCPayServer/Authentication/OpenId/AuthorizationCodeGrantTypeEventHandler.cs
@@ -1,5 +1,5 @@
using AspNet.Security.OpenIdConnect.Primitives;
-using BTCPayServer.Authentication.OpenId.Models;
+using BTCPayServer.Data;
using BTCPayServer.Models;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Options;
diff --git a/BTCPayServer/Authentication/OpenId/BaseOpenIdGrantHandler.cs b/BTCPayServer/Authentication/OpenId/BaseOpenIdGrantHandler.cs
index 59c885ed9..213461be8 100644
--- a/BTCPayServer/Authentication/OpenId/BaseOpenIdGrantHandler.cs
+++ b/BTCPayServer/Authentication/OpenId/BaseOpenIdGrantHandler.cs
@@ -1,6 +1,6 @@
using System.Threading.Tasks;
using AspNet.Security.OpenIdConnect.Primitives;
-using BTCPayServer.Authentication.OpenId.Models;
+using BTCPayServer.Data;
using BTCPayServer.Models;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Identity;
diff --git a/BTCPayServer/Authentication/OpenId/ClientCredentialsGrantTypeEventHandler.cs b/BTCPayServer/Authentication/OpenId/ClientCredentialsGrantTypeEventHandler.cs
index 4708380f6..a47cf9c43 100644
--- a/BTCPayServer/Authentication/OpenId/ClientCredentialsGrantTypeEventHandler.cs
+++ b/BTCPayServer/Authentication/OpenId/ClientCredentialsGrantTypeEventHandler.cs
@@ -2,7 +2,7 @@ using System.Security.Claims;
using System.Threading.Tasks;
using AspNet.Security.OpenIdConnect.Extensions;
using AspNet.Security.OpenIdConnect.Primitives;
-using BTCPayServer.Authentication.OpenId.Models;
+using BTCPayServer.Data;
using BTCPayServer.Models;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Identity;
diff --git a/BTCPayServer/Authentication/OpenId/LogoutEventHandler.cs b/BTCPayServer/Authentication/OpenId/LogoutEventHandler.cs
index 62c5107b8..d348d91c1 100644
--- a/BTCPayServer/Authentication/OpenId/LogoutEventHandler.cs
+++ b/BTCPayServer/Authentication/OpenId/LogoutEventHandler.cs
@@ -1,6 +1,6 @@
using System;
using System.Threading.Tasks;
-using BTCPayServer.Authentication.OpenId.Models;
+using BTCPayServer.Data;
using BTCPayServer.Models;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Identity;
diff --git a/BTCPayServer/Authentication/OpenId/OpenIdExtensions.cs b/BTCPayServer/Authentication/OpenId/OpenIdExtensions.cs
index 5b8b755b5..c9d3ccf7f 100644
--- a/BTCPayServer/Authentication/OpenId/OpenIdExtensions.cs
+++ b/BTCPayServer/Authentication/OpenId/OpenIdExtensions.cs
@@ -5,7 +5,7 @@ using System.Security.Claims;
using System.Threading.Tasks;
using AspNet.Security.OpenIdConnect.Extensions;
using AspNet.Security.OpenIdConnect.Primitives;
-using BTCPayServer.Authentication.OpenId.Models;
+using BTCPayServer.Data;
using BTCPayServer.Models;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Identity;
diff --git a/BTCPayServer/Authentication/OpenId/OpenIdGrantHandlerCheckCanSignIn.cs b/BTCPayServer/Authentication/OpenId/OpenIdGrantHandlerCheckCanSignIn.cs
index 413a45229..08cf3c5e7 100644
--- a/BTCPayServer/Authentication/OpenId/OpenIdGrantHandlerCheckCanSignIn.cs
+++ b/BTCPayServer/Authentication/OpenId/OpenIdGrantHandlerCheckCanSignIn.cs
@@ -1,6 +1,6 @@
using System.Threading.Tasks;
using AspNet.Security.OpenIdConnect.Primitives;
-using BTCPayServer.Authentication.OpenId.Models;
+using BTCPayServer.Data;
using BTCPayServer.Models;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Identity;
diff --git a/BTCPayServer/Authentication/OpenId/PasswordGrantTypeEventHandler.cs b/BTCPayServer/Authentication/OpenId/PasswordGrantTypeEventHandler.cs
index 742782c95..0930f97a7 100644
--- a/BTCPayServer/Authentication/OpenId/PasswordGrantTypeEventHandler.cs
+++ b/BTCPayServer/Authentication/OpenId/PasswordGrantTypeEventHandler.cs
@@ -1,6 +1,6 @@
using System.Threading.Tasks;
using AspNet.Security.OpenIdConnect.Primitives;
-using BTCPayServer.Authentication.OpenId.Models;
+using BTCPayServer.Data;
using BTCPayServer.Models;
using BTCPayServer.Services.U2F;
using Microsoft.AspNetCore.Identity;
diff --git a/BTCPayServer/Authentication/OpenId/RefreshTokenGrantTypeEventHandler.cs b/BTCPayServer/Authentication/OpenId/RefreshTokenGrantTypeEventHandler.cs
index 30e8b45e0..b15420c4a 100644
--- a/BTCPayServer/Authentication/OpenId/RefreshTokenGrantTypeEventHandler.cs
+++ b/BTCPayServer/Authentication/OpenId/RefreshTokenGrantTypeEventHandler.cs
@@ -1,5 +1,5 @@
using AspNet.Security.OpenIdConnect.Primitives;
-using BTCPayServer.Authentication.OpenId.Models;
+using BTCPayServer.Data;
using BTCPayServer.Models;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Options;
diff --git a/BTCPayServer/BTCPayServer.csproj b/BTCPayServer/BTCPayServer.csproj
index a048d5c0c..ec4bc0c07 100644
--- a/BTCPayServer/BTCPayServer.csproj
+++ b/BTCPayServer/BTCPayServer.csproj
@@ -36,7 +36,6 @@
-
all
@@ -49,10 +48,7 @@
-
-
-
@@ -124,6 +120,7 @@
+
@@ -133,6 +130,7 @@
+
diff --git a/BTCPayServer/Controllers/AccountController.cs b/BTCPayServer/Controllers/AccountController.cs
index a8e2fbfd1..2e83b528d 100644
--- a/BTCPayServer/Controllers/AccountController.cs
+++ b/BTCPayServer/Controllers/AccountController.cs
@@ -22,6 +22,7 @@ using BTCPayServer.Services.U2F;
using BTCPayServer.Services.U2F.Models;
using Newtonsoft.Json;
using NicolasDorier.RateLimits;
+using BTCPayServer.Data;
namespace BTCPayServer.Controllers
{
diff --git a/BTCPayServer/Controllers/AuthorizationController.cs b/BTCPayServer/Controllers/AuthorizationController.cs
index 6f5747555..50511fdb3 100644
--- a/BTCPayServer/Controllers/AuthorizationController.cs
+++ b/BTCPayServer/Controllers/AuthorizationController.cs
@@ -11,7 +11,7 @@ using System.Threading.Tasks;
using AspNet.Security.OpenIdConnect.Extensions;
using AspNet.Security.OpenIdConnect.Primitives;
using BTCPayServer.Authentication.OpenId;
-using BTCPayServer.Authentication.OpenId.Models;
+using BTCPayServer.Data;
using BTCPayServer.Models;
using BTCPayServer.Models.Authorization;
using BTCPayServer.Security;
diff --git a/BTCPayServer/Controllers/ChangellyController.cs b/BTCPayServer/Controllers/ChangellyController.cs
index 845728cf1..f6d5d5303 100644
--- a/BTCPayServer/Controllers/ChangellyController.cs
+++ b/BTCPayServer/Controllers/ChangellyController.cs
@@ -6,6 +6,7 @@ using BTCPayServer.Payments.Changelly;
using BTCPayServer.Rating;
using BTCPayServer.Services.Rates;
using Microsoft.AspNetCore.Mvc;
+using BTCPayServer.Data;
namespace BTCPayServer.Controllers
{
diff --git a/BTCPayServer/Controllers/ManageController.2FA.cs b/BTCPayServer/Controllers/ManageController.2FA.cs
index bf92763a9..47945f169 100644
--- a/BTCPayServer/Controllers/ManageController.2FA.cs
+++ b/BTCPayServer/Controllers/ManageController.2FA.cs
@@ -3,6 +3,7 @@ using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using BTCPayServer.Data;
using BTCPayServer.Models;
using BTCPayServer.Models.ManageViewModels;
using Microsoft.AspNetCore.Mvc;
diff --git a/BTCPayServer/Controllers/ManageController.cs b/BTCPayServer/Controllers/ManageController.cs
index ee69eee44..4bc9186bd 100644
--- a/BTCPayServer/Controllers/ManageController.cs
+++ b/BTCPayServer/Controllers/ManageController.cs
@@ -19,6 +19,7 @@ using BTCPayServer.Services.Mails;
using System.Globalization;
using BTCPayServer.Security;
using BTCPayServer.Services.U2F;
+using BTCPayServer.Data;
namespace BTCPayServer.Controllers
{
diff --git a/BTCPayServer/Controllers/PublicController.cs b/BTCPayServer/Controllers/PublicController.cs
index 2d458f5f5..a939735c1 100644
--- a/BTCPayServer/Controllers/PublicController.cs
+++ b/BTCPayServer/Controllers/PublicController.cs
@@ -10,6 +10,7 @@ using BTCPayServer.Models.StoreViewModels;
using BTCPayServer.Services.Stores;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
+using BTCPayServer.Data;
namespace BTCPayServer.Controllers
{
diff --git a/BTCPayServer/Controllers/RateController.cs b/BTCPayServer/Controllers/RateController.cs
index e235c097a..760dbfd94 100644
--- a/BTCPayServer/Controllers/RateController.cs
+++ b/BTCPayServer/Controllers/RateController.cs
@@ -14,6 +14,7 @@ using Microsoft.AspNetCore.Authorization;
using BTCPayServer.Authentication;
using Microsoft.AspNetCore.Cors;
using System.Threading;
+using BTCPayServer.Data;
namespace BTCPayServer.Controllers
{
diff --git a/BTCPayServer/Controllers/UserStoresController.cs b/BTCPayServer/Controllers/UserStoresController.cs
index 7e5a91789..d5cbb86da 100644
--- a/BTCPayServer/Controllers/UserStoresController.cs
+++ b/BTCPayServer/Controllers/UserStoresController.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using BTCPayServer.Data;
using BTCPayServer.Models;
using BTCPayServer.Models.StoreViewModels;
using BTCPayServer.Security;
diff --git a/BTCPayServer/Data/AddressInvoiceData.cs b/BTCPayServer/Data/AddressInvoiceData.cs
deleted file mode 100644
index 65e482367..000000000
--- a/BTCPayServer/Data/AddressInvoiceData.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-using BTCPayServer.Payments;
-using BTCPayServer.Services.Invoices;
-using NBitcoin;
-
-namespace BTCPayServer.Data
-{
- public class AddressInvoiceData
- {
- ///
- /// Some crypto currencies share same address prefix
- /// For not having exceptions thrown by two address on different network, we suffix by "#CRYPTOCODE"
- ///
- [Obsolete("Use GetHash instead")]
- public string Address
- {
- get; set;
- }
-
-
-#pragma warning disable CS0618
- public string GetAddress()
- {
- if (Address == null)
- return null;
- var index = Address.LastIndexOf("#", StringComparison.InvariantCulture);
- if (index == -1)
- return Address;
- return Address.Substring(0, index);
- }
- public AddressInvoiceData Set(string address, PaymentMethodId paymentMethodId)
- {
- Address = address + "#" + paymentMethodId.ToString();
- return this;
- }
- public PaymentMethodId GetpaymentMethodId()
- {
- if (Address == null)
- return null;
- var index = Address.LastIndexOf("#", StringComparison.InvariantCulture);
- // Legacy AddressInvoiceData does not have the paymentMethodId attached to the Address
- if (index == -1)
- return PaymentMethodId.Parse("BTC");
- /////////////////////////
- return PaymentMethodId.Parse(Address.Substring(index + 1));
- }
-#pragma warning restore CS0618
-
- public InvoiceData InvoiceData
- {
- get; set;
- }
-
- public string InvoiceDataId
- {
- get; set;
- }
-
- public DateTimeOffset? CreatedTime
- {
- get; set;
- }
-
- }
-}
diff --git a/BTCPayServer/Data/AddressInvoiceDataExtensions.cs b/BTCPayServer/Data/AddressInvoiceDataExtensions.cs
new file mode 100644
index 000000000..07a42c899
--- /dev/null
+++ b/BTCPayServer/Data/AddressInvoiceDataExtensions.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using BTCPayServer.Payments;
+
+namespace BTCPayServer.Data
+{
+ public static class AddressInvoiceDataExtensions
+ {
+#pragma warning disable CS0618
+ public static string GetAddress(this AddressInvoiceData addressInvoiceData)
+ {
+ if (addressInvoiceData.Address == null)
+ return null;
+ var index = addressInvoiceData.Address.LastIndexOf("#", StringComparison.InvariantCulture);
+ if (index == -1)
+ return addressInvoiceData.Address;
+ return addressInvoiceData.Address.Substring(0, index);
+ }
+ public static AddressInvoiceData Set(this AddressInvoiceData addressInvoiceData, string address, PaymentMethodId paymentMethodId)
+ {
+ addressInvoiceData.Address = address + "#" + paymentMethodId.ToString();
+ return addressInvoiceData;
+ }
+ public static PaymentMethodId GetpaymentMethodId(this AddressInvoiceData addressInvoiceData)
+ {
+ if (addressInvoiceData.Address == null)
+ return null;
+ var index = addressInvoiceData.Address.LastIndexOf("#", StringComparison.InvariantCulture);
+ // Legacy AddressInvoiceData does not have the paymentMethodId attached to the Address
+ if (index == -1)
+ return PaymentMethodId.Parse("BTC");
+ /////////////////////////
+ return PaymentMethodId.Parse(addressInvoiceData.Address.Substring(index + 1));
+ }
+#pragma warning restore CS0618
+ }
+}
diff --git a/BTCPayServer/Data/HistoricalAddressInvoiceDataExtensions.cs b/BTCPayServer/Data/HistoricalAddressInvoiceDataExtensions.cs
new file mode 100644
index 000000000..bd43aa832
--- /dev/null
+++ b/BTCPayServer/Data/HistoricalAddressInvoiceDataExtensions.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace BTCPayServer.Data
+{
+ public static class HistoricalAddressInvoiceDataExtensions
+ {
+#pragma warning disable CS0618
+ public static Payments.PaymentMethodId GetPaymentMethodId(this HistoricalAddressInvoiceData historicalAddressInvoiceData)
+ {
+ return string.IsNullOrEmpty(historicalAddressInvoiceData.CryptoCode) ? new Payments.PaymentMethodId("BTC", Payments.PaymentTypes.BTCLike)
+ : Payments.PaymentMethodId.Parse(historicalAddressInvoiceData.CryptoCode);
+ }
+ public static string GetAddress(this HistoricalAddressInvoiceData historicalAddressInvoiceData)
+ {
+ if (historicalAddressInvoiceData.Address == null)
+ return null;
+ var index = historicalAddressInvoiceData.Address.IndexOf("#", StringComparison.InvariantCulture);
+ if (index == -1)
+ return historicalAddressInvoiceData.Address;
+ return historicalAddressInvoiceData.Address.Substring(0, index);
+ }
+ public static HistoricalAddressInvoiceData SetAddress(this HistoricalAddressInvoiceData historicalAddressInvoiceData, string depositAddress, string cryptoCode)
+ {
+ historicalAddressInvoiceData.Address = depositAddress + "#" + cryptoCode;
+ historicalAddressInvoiceData.CryptoCode = cryptoCode;
+ return historicalAddressInvoiceData;
+ }
+#pragma warning restore CS0618
+ }
+}
diff --git a/BTCPayServer/Data/InvoiceDataExtensions.cs b/BTCPayServer/Data/InvoiceDataExtensions.cs
new file mode 100644
index 000000000..dfefdf645
--- /dev/null
+++ b/BTCPayServer/Data/InvoiceDataExtensions.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using BTCPayServer.Services.Invoices;
+
+namespace BTCPayServer.Data
+{
+ public static class InvoiceDataExtensions
+ {
+ public static InvoiceState GetInvoiceState(this InvoiceData invoiceData)
+ {
+ return new InvoiceState(invoiceData.Status, invoiceData.ExceptionStatus);
+ }
+ }
+}
diff --git a/BTCPayServer/Data/PaymentRequestDataExtensions.cs b/BTCPayServer/Data/PaymentRequestDataExtensions.cs
new file mode 100644
index 000000000..a5933fea5
--- /dev/null
+++ b/BTCPayServer/Data/PaymentRequestDataExtensions.cs
@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using NBitcoin;
+using NBXplorer;
+using Newtonsoft.Json.Linq;
+using static BTCPayServer.Data.PaymentRequestData;
+
+namespace BTCPayServer.Data
+{
+ public static class PaymentRequestDataExtensions
+ {
+ public static PaymentRequestBlob GetBlob(this PaymentRequestData paymentRequestData)
+ {
+ var result = paymentRequestData.Blob == null
+ ? new PaymentRequestBlob()
+ : JObject.Parse(ZipUtils.Unzip(paymentRequestData.Blob)).ToObject();
+ return result;
+ }
+
+ public static bool SetBlob(this PaymentRequestData paymentRequestData, PaymentRequestBlob blob)
+ {
+ var original = new Serializer(Network.Main).ToString(paymentRequestData.GetBlob());
+ var newBlob = new Serializer(Network.Main).ToString(blob);
+ if (original == newBlob)
+ return false;
+ paymentRequestData.Blob = ZipUtils.Zip(newBlob);
+ return true;
+ }
+ }
+}
diff --git a/BTCPayServer/Data/StoreBlob.cs b/BTCPayServer/Data/StoreBlob.cs
new file mode 100644
index 000000000..038302457
--- /dev/null
+++ b/BTCPayServer/Data/StoreBlob.cs
@@ -0,0 +1,213 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using BTCPayServer.Payments;
+using BTCPayServer.JsonConverters;
+using BTCPayServer.Payments.Changelly;
+using BTCPayServer.Payments.CoinSwitch;
+using BTCPayServer.Rating;
+using BTCPayServer.Services.Mails;
+using Newtonsoft.Json;
+using System.Text;
+
+namespace BTCPayServer.Data
+{
+ public class StoreBlob
+ {
+ public StoreBlob()
+ {
+ InvoiceExpiration = 15;
+ MonitoringExpiration = 1440;
+ PaymentTolerance = 0;
+ RequiresRefundEmail = true;
+ }
+
+ [Obsolete("Use NetworkFeeMode instead")]
+ [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
+ public bool? NetworkFeeDisabled
+ {
+ get; set;
+ }
+
+ [JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
+ public NetworkFeeMode NetworkFeeMode
+ {
+ get;
+ set;
+ }
+
+ public bool RequiresRefundEmail { get; set; }
+
+ CurrencyPair[] _DefaultCurrencyPairs;
+ [JsonProperty("defaultCurrencyPairs", ItemConverterType = typeof(CurrencyPairJsonConverter))]
+ public CurrencyPair[] DefaultCurrencyPairs
+ {
+ get
+ {
+ return _DefaultCurrencyPairs ?? Array.Empty();
+ }
+ set
+ {
+ _DefaultCurrencyPairs = value;
+ }
+ }
+
+ public string GetDefaultCurrencyPairString()
+ {
+ return string.Join(',', DefaultCurrencyPairs.Select(c => c.ToString()));
+ }
+
+ public string DefaultLang { get; set; }
+ [DefaultValue(60)]
+ [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
+ public int MonitoringExpiration
+ {
+ get;
+ set;
+ }
+
+ [DefaultValue(15)]
+ [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
+ public int InvoiceExpiration
+ {
+ get;
+ set;
+ }
+
+ public decimal Spread { get; set; } = 0.0m;
+
+ [Obsolete]
+ public List RateRules { get; set; } = new List();
+ public string PreferredExchange { get; set; }
+
+ [JsonConverter(typeof(CurrencyValueJsonConverter))]
+ public CurrencyValue OnChainMinValue { get; set; }
+ [JsonConverter(typeof(CurrencyValueJsonConverter))]
+ public CurrencyValue LightningMaxValue { get; set; }
+ public bool LightningAmountInSatoshi { get; set; }
+
+ [JsonConverter(typeof(UriJsonConverter))]
+ public Uri CustomLogo { get; set; }
+ [JsonConverter(typeof(UriJsonConverter))]
+ public Uri CustomCSS { get; set; }
+ public string HtmlTitle { get; set; }
+
+ public bool RateScripting { get; set; }
+
+ public string RateScript { get; set; }
+
+ public bool AnyoneCanInvoice { get; set; }
+
+ public ChangellySettings ChangellySettings { get; set; }
+ public CoinSwitchSettings CoinSwitchSettings { get; set; }
+
+
+ string _LightningDescriptionTemplate;
+ public string LightningDescriptionTemplate
+ {
+ get
+ {
+ return _LightningDescriptionTemplate ?? "Paid to {StoreName} (Order ID: {OrderId})";
+ }
+ set
+ {
+ _LightningDescriptionTemplate = value;
+ }
+ }
+
+ [DefaultValue(0)]
+ [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
+ public double PaymentTolerance { get; set; }
+
+ public BTCPayServer.Rating.RateRules GetRateRules(BTCPayNetworkProvider networkProvider)
+ {
+ if (!RateScripting ||
+ string.IsNullOrEmpty(RateScript) ||
+ !BTCPayServer.Rating.RateRules.TryParse(RateScript, out var rules))
+ {
+ return GetDefaultRateRules(networkProvider);
+ }
+ else
+ {
+ rules.Spread = Spread;
+ return rules;
+ }
+ }
+
+ public RateRules GetDefaultRateRules(BTCPayNetworkProvider networkProvider)
+ {
+ StringBuilder builder = new StringBuilder();
+ foreach (var network in networkProvider.GetAll())
+ {
+ if (network.DefaultRateRules.Length != 0)
+ {
+ builder.AppendLine($"// Default rate rules for {network.CryptoCode}");
+ foreach (var line in network.DefaultRateRules)
+ {
+ builder.AppendLine(line);
+ }
+ builder.AppendLine($"////////");
+ builder.AppendLine();
+ }
+ }
+
+ var preferredExchange = string.IsNullOrEmpty(PreferredExchange) ? "coinaverage" : PreferredExchange;
+ builder.AppendLine($"X_X = {preferredExchange}(X_X);");
+
+ BTCPayServer.Rating.RateRules.TryParse(builder.ToString(), out var rules);
+ rules.Spread = Spread;
+ return rules;
+ }
+
+ [Obsolete("Use GetExcludedPaymentMethods instead")]
+ public string[] ExcludedPaymentMethods { get; set; }
+
+ [Obsolete("Use DerivationSchemeSettings instead")]
+ public Dictionary WalletKeyPathRoots { get; set; }
+
+ public EmailSettings EmailSettings { get; set; }
+ public bool RedirectAutomatically { get; set; }
+
+ public IPaymentFilter GetExcludedPaymentMethods()
+ {
+#pragma warning disable CS0618 // Type or member is obsolete
+ if (ExcludedPaymentMethods == null || ExcludedPaymentMethods.Length == 0)
+ return PaymentFilter.Never();
+ return PaymentFilter.Any(ExcludedPaymentMethods.Select(p => PaymentFilter.WhereIs(PaymentMethodId.Parse(p))).ToArray());
+#pragma warning restore CS0618 // Type or member is obsolete
+ }
+
+ public bool IsExcluded(PaymentMethodId paymentMethodId)
+ {
+ return GetExcludedPaymentMethods().Match(paymentMethodId);
+ }
+
+ public void SetExcluded(PaymentMethodId paymentMethodId, bool value)
+ {
+#pragma warning disable CS0618 // Type or member is obsolete
+ var methods = new HashSet(ExcludedPaymentMethods ?? Array.Empty());
+ if (value)
+ methods.Add(paymentMethodId.ToString());
+ else
+ methods.Remove(paymentMethodId.ToString());
+ ExcludedPaymentMethods = methods.ToArray();
+#pragma warning restore CS0618 // Type or member is obsolete
+ }
+ }
+ public class RateRule_Obsolete
+ {
+ public RateRule_Obsolete()
+ {
+ RuleName = "Multiplier";
+ }
+ public string RuleName { get; set; }
+
+ public double Multiplier { get; set; }
+
+ public decimal Apply(BTCPayNetworkBase network, decimal rate)
+ {
+ return rate * (decimal)Multiplier;
+ }
+ }
+}
diff --git a/BTCPayServer/Data/StoreData.cs b/BTCPayServer/Data/StoreData.cs
deleted file mode 100644
index 57f226696..000000000
--- a/BTCPayServer/Data/StoreData.cs
+++ /dev/null
@@ -1,478 +0,0 @@
-using BTCPayServer.Models;
-using BTCPayServer.Services.Invoices;
-using NBitcoin;
-using NBXplorer;
-using System;
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations.Schema;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.ComponentModel;
-using Newtonsoft.Json;
-using Newtonsoft.Json.Linq;
-using BTCPayServer.Services.Rates;
-using BTCPayServer.Payments;
-using BTCPayServer.JsonConverters;
-using System.ComponentModel.DataAnnotations;
-using BTCPayServer.Services;
-using System.Security.Claims;
-using BTCPayServer.Payments.Changelly;
-using BTCPayServer.Payments.CoinSwitch;
-using BTCPayServer.Security;
-using BTCPayServer.Rating;
-using BTCPayServer.Services.PaymentRequests;
-using BTCPayServer.Services.Mails;
-
-namespace BTCPayServer.Data
-{
- public class StoreData
- {
- public string Id
- {
- get;
- set;
- }
-
- public List UserStores
- {
- get; set;
- }
- public List Apps
- {
- get; set;
- }
-
- public List PaymentRequests
- {
- get; set;
- }
-
- public List Invoices { get; set; }
-
- [Obsolete("Use GetDerivationStrategies instead")]
- public string DerivationStrategy
- {
- get; set;
- }
-
- [Obsolete("Use GetDerivationStrategies instead")]
- public string DerivationStrategies
- {
- get;
- set;
- }
- public IEnumerable GetSupportedPaymentMethods(BTCPayNetworkProvider networks)
- {
- networks = networks.UnfilteredNetworks;
-#pragma warning disable CS0618
- bool btcReturned = false;
-
- // Legacy stuff which should go away
- if (!string.IsNullOrEmpty(DerivationStrategy))
- {
- btcReturned = true;
- yield return DerivationSchemeSettings.Parse(DerivationStrategy, networks.BTC);
- }
-
-
- if (!string.IsNullOrEmpty(DerivationStrategies))
- {
- JObject strategies = JObject.Parse(DerivationStrategies);
- foreach (var strat in strategies.Properties())
- {
- var paymentMethodId = PaymentMethodId.Parse(strat.Name);
- var network = networks.GetNetwork(paymentMethodId.CryptoCode);
- if (network != null)
- {
- if (network == networks.BTC && paymentMethodId.PaymentType == PaymentTypes.BTCLike && btcReturned)
- continue;
- if (strat.Value.Type == JTokenType.Null)
- continue;
- yield return
- paymentMethodId.PaymentType.DeserializeSupportedPaymentMethod(network, strat.Value);
- }
- }
- }
-#pragma warning restore CS0618
- }
-
- public void SetSupportedPaymentMethod(ISupportedPaymentMethod supportedPaymentMethod)
- {
- SetSupportedPaymentMethod(null, supportedPaymentMethod);
- }
-
- ///
- /// Set or remove a new supported payment method for the store
- ///
- /// The paymentMethodId
- /// The payment method, or null to remove
- public void SetSupportedPaymentMethod(PaymentMethodId paymentMethodId, ISupportedPaymentMethod supportedPaymentMethod)
- {
- if (supportedPaymentMethod != null && paymentMethodId != null && paymentMethodId != supportedPaymentMethod.PaymentId)
- {
- throw new InvalidOperationException("Incoherent arguments, this should never happen");
- }
- if (supportedPaymentMethod == null && paymentMethodId == null)
- throw new ArgumentException($"{nameof(supportedPaymentMethod)} or {nameof(paymentMethodId)} should be specified");
- if (supportedPaymentMethod != null && paymentMethodId == null)
- {
- paymentMethodId = supportedPaymentMethod.PaymentId;
- }
-
-#pragma warning disable CS0618
- JObject strategies = string.IsNullOrEmpty(DerivationStrategies) ? new JObject() : JObject.Parse(DerivationStrategies);
- bool existing = false;
- foreach (var strat in strategies.Properties().ToList())
- {
- var stratId = PaymentMethodId.Parse(strat.Name);
- if (stratId.IsBTCOnChain)
- {
- // Legacy stuff which should go away
- DerivationStrategy = null;
- }
- if (stratId == paymentMethodId)
- {
- if (supportedPaymentMethod == null)
- {
- strat.Remove();
- }
- else
- {
- strat.Value = PaymentMethodExtensions.Serialize(supportedPaymentMethod);
- }
- existing = true;
- break;
- }
- }
-
- if (!existing && supportedPaymentMethod == null && paymentMethodId.IsBTCOnChain)
- {
- DerivationStrategy = null;
- }
- else if (!existing && supportedPaymentMethod != null)
- strategies.Add(new JProperty(supportedPaymentMethod.PaymentId.ToString(), PaymentMethodExtensions.Serialize(supportedPaymentMethod)));
- DerivationStrategies = strategies.ToString();
-#pragma warning restore CS0618
- }
-
- public string StoreName
- {
- get; set;
- }
-
- public SpeedPolicy SpeedPolicy
- {
- get; set;
- }
-
- public string StoreWebsite
- {
- get; set;
- }
-
- public byte[] StoreCertificate
- {
- get; set;
- }
-
- [NotMapped]
- [Obsolete]
- public string Role
- {
- get; set;
- }
-
- public Claim[] GetClaims()
- {
- List claims = new List();
- claims.AddRange(AdditionalClaims);
-#pragma warning disable CS0612 // Type or member is obsolete
- var role = Role;
-#pragma warning restore CS0612 // Type or member is obsolete
- if (role == StoreRoles.Owner)
- {
- claims.Add(new Claim(Policies.CanModifyStoreSettings.Key, Id));
- }
-
- if(role == StoreRoles.Owner || role == StoreRoles.Guest || GetStoreBlob().AnyoneCanInvoice)
- {
- claims.Add(new Claim(Policies.CanCreateInvoice.Key, Id));
- }
- return claims.ToArray();
- }
-
- public bool HasClaim(string claim)
- {
- return GetClaims().Any(c => c.Type == claim && c.Value == Id);
- }
-
- public byte[] StoreBlob
- {
- get;
- set;
- }
- [Obsolete("Use GetDefaultPaymentId instead")]
- public string DefaultCrypto { get; set; }
- public List PairedSINs { get; set; }
- public IEnumerable APIKeys { get; set; }
-
- [NotMapped]
- public List AdditionalClaims { get; set; } = new List();
-
-#pragma warning disable CS0618
- public PaymentMethodId GetDefaultPaymentId(BTCPayNetworkProvider networks)
- {
- PaymentMethodId[] paymentMethodIds = GetEnabledPaymentIds(networks);
-
- var defaultPaymentId = string.IsNullOrEmpty(DefaultCrypto) ? null : PaymentMethodId.Parse(DefaultCrypto);
- var chosen = paymentMethodIds.FirstOrDefault(f => f == defaultPaymentId) ??
- paymentMethodIds.FirstOrDefault(f => f.CryptoCode == defaultPaymentId?.CryptoCode) ??
- paymentMethodIds.FirstOrDefault();
- return chosen;
- }
-
- public PaymentMethodId[] GetEnabledPaymentIds(BTCPayNetworkProvider networks)
- {
- var excludeFilter = GetStoreBlob().GetExcludedPaymentMethods();
- var paymentMethodIds = GetSupportedPaymentMethods(networks).Select(p => p.PaymentId)
- .Where(a => !excludeFilter.Match(a))
- .OrderByDescending(a => a.CryptoCode == "BTC")
- .ThenBy(a => a.CryptoCode)
- .ThenBy(a => a.PaymentType == PaymentTypes.LightningLike ? 1 : 0)
- .ToArray();
- return paymentMethodIds;
- }
-
- public void SetDefaultPaymentId(PaymentMethodId defaultPaymentId)
- {
- DefaultCrypto = defaultPaymentId.ToString();
- }
-#pragma warning restore CS0618
-
- static Network Dummy = Network.Main;
-
- public StoreBlob GetStoreBlob()
- {
- var result = StoreBlob == null ? new StoreBlob() : new Serializer(Dummy).ToObject(Encoding.UTF8.GetString(StoreBlob));
- if (result.PreferredExchange == null)
- result.PreferredExchange = CoinAverageRateProvider.CoinAverageName;
- return result;
- }
-
- public bool SetStoreBlob(StoreBlob storeBlob)
- {
- var original = new Serializer(Dummy).ToString(GetStoreBlob());
- var newBlob = new Serializer(Dummy).ToString(storeBlob);
- if (original == newBlob)
- return false;
- StoreBlob = Encoding.UTF8.GetBytes(newBlob);
- return true;
- }
- }
-
- public class RateRule_Obsolete
- {
- public RateRule_Obsolete()
- {
- RuleName = "Multiplier";
- }
- public string RuleName { get; set; }
-
- public double Multiplier { get; set; }
-
- public decimal Apply(BTCPayNetworkBase network, decimal rate)
- {
- return rate * (decimal)Multiplier;
- }
- }
-
- public enum NetworkFeeMode
- {
- MultiplePaymentsOnly,
- Always,
- Never
- }
- public class StoreBlob
- {
- public StoreBlob()
- {
- InvoiceExpiration = 15;
- MonitoringExpiration = 1440;
- PaymentTolerance = 0;
- RequiresRefundEmail = true;
- }
-
- [Obsolete("Use NetworkFeeMode instead")]
- [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public bool? NetworkFeeDisabled
- {
- get; set;
- }
-
- [JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
- public NetworkFeeMode NetworkFeeMode
- {
- get;
- set;
- }
-
- public bool RequiresRefundEmail { get; set; }
-
- CurrencyPair[] _DefaultCurrencyPairs;
- [JsonProperty("defaultCurrencyPairs", ItemConverterType = typeof(CurrencyPairJsonConverter))]
- public CurrencyPair[] DefaultCurrencyPairs
- {
- get
- {
- return _DefaultCurrencyPairs ?? Array.Empty();
- }
- set
- {
- _DefaultCurrencyPairs = value;
- }
- }
-
- public string GetDefaultCurrencyPairString()
- {
- return string.Join(',', DefaultCurrencyPairs.Select(c => c.ToString()));
- }
-
- public string DefaultLang { get; set; }
- [DefaultValue(60)]
- [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
- public int MonitoringExpiration
- {
- get;
- set;
- }
-
- [DefaultValue(15)]
- [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
- public int InvoiceExpiration
- {
- get;
- set;
- }
-
- public decimal Spread { get; set; } = 0.0m;
-
- [Obsolete]
- public List RateRules { get; set; } = new List();
- public string PreferredExchange { get; set; }
-
- [JsonConverter(typeof(CurrencyValueJsonConverter))]
- public CurrencyValue OnChainMinValue { get; set; }
- [JsonConverter(typeof(CurrencyValueJsonConverter))]
- public CurrencyValue LightningMaxValue { get; set; }
- public bool LightningAmountInSatoshi { get; set; }
-
- [JsonConverter(typeof(UriJsonConverter))]
- public Uri CustomLogo { get; set; }
- [JsonConverter(typeof(UriJsonConverter))]
- public Uri CustomCSS { get; set; }
- public string HtmlTitle { get; set; }
-
- public bool RateScripting { get; set; }
-
- public string RateScript { get; set; }
-
- public bool AnyoneCanInvoice { get; set; }
-
- public ChangellySettings ChangellySettings { get; set; }
- public CoinSwitchSettings CoinSwitchSettings { get; set; }
-
-
- string _LightningDescriptionTemplate;
- public string LightningDescriptionTemplate
- {
- get
- {
- return _LightningDescriptionTemplate ?? "Paid to {StoreName} (Order ID: {OrderId})";
- }
- set
- {
- _LightningDescriptionTemplate = value;
- }
- }
-
- [DefaultValue(0)]
- [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
- public double PaymentTolerance { get; set; }
-
- public BTCPayServer.Rating.RateRules GetRateRules(BTCPayNetworkProvider networkProvider)
- {
- if (!RateScripting ||
- string.IsNullOrEmpty(RateScript) ||
- !BTCPayServer.Rating.RateRules.TryParse(RateScript, out var rules))
- {
- return GetDefaultRateRules(networkProvider);
- }
- else
- {
- rules.Spread = Spread;
- return rules;
- }
- }
-
- public RateRules GetDefaultRateRules(BTCPayNetworkProvider networkProvider)
- {
- StringBuilder builder = new StringBuilder();
- foreach (var network in networkProvider.GetAll())
- {
- if (network.DefaultRateRules.Length != 0)
- {
- builder.AppendLine($"// Default rate rules for {network.CryptoCode}");
- foreach (var line in network.DefaultRateRules)
- {
- builder.AppendLine(line);
- }
- builder.AppendLine($"////////");
- builder.AppendLine();
- }
- }
-
- var preferredExchange = string.IsNullOrEmpty(PreferredExchange) ? "coinaverage" : PreferredExchange;
- builder.AppendLine($"X_X = {preferredExchange}(X_X);");
-
- BTCPayServer.Rating.RateRules.TryParse(builder.ToString(), out var rules);
- rules.Spread = Spread;
- return rules;
- }
-
- [Obsolete("Use GetExcludedPaymentMethods instead")]
- public string[] ExcludedPaymentMethods { get; set; }
-
- [Obsolete("Use DerivationSchemeSettings instead")]
- public Dictionary WalletKeyPathRoots { get; set; }
-
- public EmailSettings EmailSettings { get; set; }
- public bool RedirectAutomatically { get; set; }
-
- public IPaymentFilter GetExcludedPaymentMethods()
- {
-#pragma warning disable CS0618 // Type or member is obsolete
- if (ExcludedPaymentMethods == null || ExcludedPaymentMethods.Length == 0)
- return PaymentFilter.Never();
- return PaymentFilter.Any(ExcludedPaymentMethods.Select(p => PaymentFilter.WhereIs(PaymentMethodId.Parse(p))).ToArray());
-#pragma warning restore CS0618 // Type or member is obsolete
- }
-
- public bool IsExcluded(PaymentMethodId paymentMethodId)
- {
- return GetExcludedPaymentMethods().Match(paymentMethodId);
- }
-
- public void SetExcluded(PaymentMethodId paymentMethodId, bool value)
- {
-#pragma warning disable CS0618 // Type or member is obsolete
- var methods = new HashSet(ExcludedPaymentMethods ?? Array.Empty());
- if (value)
- methods.Add(paymentMethodId.ToString());
- else
- methods.Remove(paymentMethodId.ToString());
- ExcludedPaymentMethods = methods.ToArray();
-#pragma warning restore CS0618 // Type or member is obsolete
- }
- }
-}
diff --git a/BTCPayServer/Data/StoreDataExtensions.cs b/BTCPayServer/Data/StoreDataExtensions.cs
new file mode 100644
index 000000000..7614752f3
--- /dev/null
+++ b/BTCPayServer/Data/StoreDataExtensions.cs
@@ -0,0 +1,185 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Security.Claims;
+using System.Text;
+using System.Threading.Tasks;
+using BTCPayServer.Payments;
+using BTCPayServer.Security;
+using BTCPayServer.Services.Rates;
+using NBitcoin;
+using NBXplorer;
+using Newtonsoft.Json.Linq;
+
+namespace BTCPayServer.Data
+{
+ public static class StoreDataExtensions
+ {
+ public static bool HasClaim(this StoreData storeData, string claim)
+ {
+ return storeData.GetClaims().Any(c => c.Type == claim && c.Value == storeData.Id);
+ }
+ public static Claim[] GetClaims(this StoreData storeData)
+ {
+ List claims = new List();
+ claims.AddRange(storeData.AdditionalClaims);
+#pragma warning disable CS0612 // Type or member is obsolete
+ var role = storeData.Role;
+#pragma warning restore CS0612 // Type or member is obsolete
+ if (role == StoreRoles.Owner)
+ {
+ claims.Add(new Claim(Policies.CanModifyStoreSettings.Key, storeData.Id));
+ }
+
+ if (role == StoreRoles.Owner || role == StoreRoles.Guest || storeData.GetStoreBlob().AnyoneCanInvoice)
+ {
+ claims.Add(new Claim(Policies.CanCreateInvoice.Key, storeData.Id));
+ }
+ return claims.ToArray();
+ }
+
+#pragma warning disable CS0618
+ public static PaymentMethodId GetDefaultPaymentId(this StoreData storeData, BTCPayNetworkProvider networks)
+ {
+ PaymentMethodId[] paymentMethodIds = storeData.GetEnabledPaymentIds(networks);
+
+ var defaultPaymentId = string.IsNullOrEmpty(storeData.DefaultCrypto) ? null : PaymentMethodId.Parse(storeData.DefaultCrypto);
+ var chosen = paymentMethodIds.FirstOrDefault(f => f == defaultPaymentId) ??
+ paymentMethodIds.FirstOrDefault(f => f.CryptoCode == defaultPaymentId?.CryptoCode) ??
+ paymentMethodIds.FirstOrDefault();
+ return chosen;
+ }
+
+ public static PaymentMethodId[] GetEnabledPaymentIds(this StoreData storeData, BTCPayNetworkProvider networks)
+ {
+ var excludeFilter = storeData.GetStoreBlob().GetExcludedPaymentMethods();
+ var paymentMethodIds = storeData.GetSupportedPaymentMethods(networks).Select(p => p.PaymentId)
+ .Where(a => !excludeFilter.Match(a))
+ .OrderByDescending(a => a.CryptoCode == "BTC")
+ .ThenBy(a => a.CryptoCode)
+ .ThenBy(a => a.PaymentType == PaymentTypes.LightningLike ? 1 : 0)
+ .ToArray();
+ return paymentMethodIds;
+ }
+
+ public static void SetDefaultPaymentId(this StoreData storeData, PaymentMethodId defaultPaymentId)
+ {
+ storeData.DefaultCrypto = defaultPaymentId.ToString();
+ }
+#pragma warning restore CS0618
+
+ static Network Dummy = Network.Main;
+
+ public static StoreBlob GetStoreBlob(this StoreData storeData)
+ {
+ var result = storeData.StoreBlob == null ? new StoreBlob() : new Serializer(Dummy).ToObject(Encoding.UTF8.GetString(storeData.StoreBlob));
+ if (result.PreferredExchange == null)
+ result.PreferredExchange = CoinAverageRateProvider.CoinAverageName;
+ return result;
+ }
+
+ public static bool SetStoreBlob(this StoreData storeData, StoreBlob storeBlob)
+ {
+ var original = new Serializer(Dummy).ToString(storeData.GetStoreBlob());
+ var newBlob = new Serializer(Dummy).ToString(storeBlob);
+ if (original == newBlob)
+ return false;
+ storeData.StoreBlob = Encoding.UTF8.GetBytes(newBlob);
+ return true;
+ }
+
+ public static IEnumerable GetSupportedPaymentMethods(this StoreData storeData, BTCPayNetworkProvider networks)
+ {
+ networks = networks.UnfilteredNetworks;
+#pragma warning disable CS0618
+ bool btcReturned = false;
+
+ // Legacy stuff which should go away
+ if (!string.IsNullOrEmpty(storeData.DerivationStrategy))
+ {
+ btcReturned = true;
+ yield return DerivationSchemeSettings.Parse(storeData.DerivationStrategy, networks.BTC);
+ }
+
+
+ if (!string.IsNullOrEmpty(storeData.DerivationStrategies))
+ {
+ JObject strategies = JObject.Parse(storeData.DerivationStrategies);
+ foreach (var strat in strategies.Properties())
+ {
+ var paymentMethodId = PaymentMethodId.Parse(strat.Name);
+ var network = networks.GetNetwork(paymentMethodId.CryptoCode);
+ if (network != null)
+ {
+ if (network == networks.BTC && paymentMethodId.PaymentType == PaymentTypes.BTCLike && btcReturned)
+ continue;
+ if (strat.Value.Type == JTokenType.Null)
+ continue;
+ yield return
+ paymentMethodId.PaymentType.DeserializeSupportedPaymentMethod(network, strat.Value);
+ }
+ }
+ }
+#pragma warning restore CS0618
+ }
+
+ public static void SetSupportedPaymentMethod(this StoreData storeData, ISupportedPaymentMethod supportedPaymentMethod)
+ {
+ storeData.SetSupportedPaymentMethod(null, supportedPaymentMethod);
+ }
+
+ ///
+ /// Set or remove a new supported payment method for the store
+ ///
+ /// The paymentMethodId
+ /// The payment method, or null to remove
+ public static void SetSupportedPaymentMethod(this StoreData storeData, PaymentMethodId paymentMethodId, ISupportedPaymentMethod supportedPaymentMethod)
+ {
+ if (supportedPaymentMethod != null && paymentMethodId != null && paymentMethodId != supportedPaymentMethod.PaymentId)
+ {
+ throw new InvalidOperationException("Incoherent arguments, this should never happen");
+ }
+ if (supportedPaymentMethod == null && paymentMethodId == null)
+ throw new ArgumentException($"{nameof(supportedPaymentMethod)} or {nameof(paymentMethodId)} should be specified");
+ if (supportedPaymentMethod != null && paymentMethodId == null)
+ {
+ paymentMethodId = supportedPaymentMethod.PaymentId;
+ }
+
+#pragma warning disable CS0618
+ JObject strategies = string.IsNullOrEmpty(storeData.DerivationStrategies) ? new JObject() : JObject.Parse(storeData.DerivationStrategies);
+ bool existing = false;
+ foreach (var strat in strategies.Properties().ToList())
+ {
+ var stratId = PaymentMethodId.Parse(strat.Name);
+ if (stratId.IsBTCOnChain)
+ {
+ // Legacy stuff which should go away
+ storeData.DerivationStrategy = null;
+ }
+ if (stratId == paymentMethodId)
+ {
+ if (supportedPaymentMethod == null)
+ {
+ strat.Remove();
+ }
+ else
+ {
+ strat.Value = PaymentMethodExtensions.Serialize(supportedPaymentMethod);
+ }
+ existing = true;
+ break;
+ }
+ }
+
+ if (!existing && supportedPaymentMethod == null && paymentMethodId.IsBTCOnChain)
+ {
+ storeData.DerivationStrategy = null;
+ }
+ else if (!existing && supportedPaymentMethod != null)
+ strategies.Add(new JProperty(supportedPaymentMethod.PaymentId.ToString(), PaymentMethodExtensions.Serialize(supportedPaymentMethod)));
+ storeData.DerivationStrategies = strategies.ToString();
+#pragma warning restore CS0618
+ }
+ }
+}
diff --git a/BTCPayServer/Data/WalletDataExtensions.cs b/BTCPayServer/Data/WalletDataExtensions.cs
new file mode 100644
index 000000000..8deed331a
--- /dev/null
+++ b/BTCPayServer/Data/WalletDataExtensions.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Newtonsoft.Json;
+
+namespace BTCPayServer.Data
+{
+ public static class WalletDataExtensions
+ {
+ public static WalletBlobInfo GetBlobInfo(this WalletData walletData)
+ {
+ if (walletData.Blob == null || walletData.Blob.Length == 0)
+ {
+ return new WalletBlobInfo();
+ }
+ var blobInfo = JsonConvert.DeserializeObject(ZipUtils.Unzip(walletData.Blob));
+ return blobInfo;
+ }
+ public static void SetBlobInfo(this WalletData walletData, WalletBlobInfo blobInfo)
+ {
+ if (blobInfo == null)
+ {
+ walletData.Blob = Array.Empty();
+ return;
+ }
+ walletData.Blob = ZipUtils.Zip(JsonConvert.SerializeObject(blobInfo));
+ }
+ }
+}
diff --git a/BTCPayServer/Data/WalletTransactionData.cs b/BTCPayServer/Data/WalletTransactionData.cs
deleted file mode 100644
index 45a54ed9f..000000000
--- a/BTCPayServer/Data/WalletTransactionData.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-using Newtonsoft.Json;
-
-namespace BTCPayServer.Data
-{
- public class WalletTransactionData
- {
- public string WalletDataId { get; set; }
- public WalletData WalletData { get; set; }
- public string TransactionId { get; set; }
- public string Labels { get; set; }
- public byte[] Blob { get; set; }
-
- public WalletTransactionInfo GetBlobInfo()
- {
- if (Blob == null || Blob.Length == 0)
- {
- return new WalletTransactionInfo();
- }
- var blobInfo = JsonConvert.DeserializeObject(ZipUtils.Unzip(Blob));
- if (!string.IsNullOrEmpty(Labels))
- {
- blobInfo.Labels.AddRange(Labels.Split(',', StringSplitOptions.RemoveEmptyEntries));
- }
- return blobInfo;
- }
- public void SetBlobInfo(WalletTransactionInfo blobInfo)
- {
- if (blobInfo == null)
- {
- Labels = string.Empty;
- Blob = Array.Empty();
- return;
- }
- if (blobInfo.Labels.Any(l => l.Contains(',', StringComparison.OrdinalIgnoreCase)))
- throw new ArgumentException(paramName: nameof(blobInfo), message: "Labels must not contains ','");
- Labels = String.Join(',', blobInfo.Labels);
- Blob = ZipUtils.Zip(JsonConvert.SerializeObject(blobInfo));
- }
- }
-
- public class WalletTransactionInfo
- {
- public string Comment { get; set; } = string.Empty;
- [JsonIgnore]
- public HashSet Labels { get; set; } = new HashSet();
- }
-}
diff --git a/BTCPayServer/Data/WalletTransactionDataExtensions.cs b/BTCPayServer/Data/WalletTransactionDataExtensions.cs
new file mode 100644
index 000000000..79f30601f
--- /dev/null
+++ b/BTCPayServer/Data/WalletTransactionDataExtensions.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Newtonsoft.Json;
+
+namespace BTCPayServer.Data
+{
+ public static class WalletTransactionDataExtensions
+ {
+ public static WalletTransactionInfo GetBlobInfo(this WalletTransactionData walletTransactionData)
+ {
+ if (walletTransactionData.Blob == null || walletTransactionData.Blob.Length == 0)
+ {
+ return new WalletTransactionInfo();
+ }
+ var blobInfo = JsonConvert.DeserializeObject(ZipUtils.Unzip(walletTransactionData.Blob));
+ if (!string.IsNullOrEmpty(walletTransactionData.Labels))
+ {
+ blobInfo.Labels.AddRange(walletTransactionData.Labels.Split(',', StringSplitOptions.RemoveEmptyEntries));
+ }
+ return blobInfo;
+ }
+ public static void SetBlobInfo(this WalletTransactionData walletTransactionData, WalletTransactionInfo blobInfo)
+ {
+ if (blobInfo == null)
+ {
+ walletTransactionData.Labels = string.Empty;
+ walletTransactionData.Blob = Array.Empty();
+ return;
+ }
+ if (blobInfo.Labels.Any(l => l.Contains(',', StringComparison.OrdinalIgnoreCase)))
+ throw new ArgumentException(paramName: nameof(blobInfo), message: "Labels must not contains ','");
+ walletTransactionData.Labels = String.Join(',', blobInfo.Labels);
+ walletTransactionData.Blob = ZipUtils.Zip(JsonConvert.SerializeObject(blobInfo));
+ }
+ }
+}
diff --git a/BTCPayServer/Extensions.cs b/BTCPayServer/Extensions.cs
index 4dc0f2c55..ec42a18c9 100644
--- a/BTCPayServer/Extensions.cs
+++ b/BTCPayServer/Extensions.cs
@@ -121,20 +121,6 @@ namespace BTCPayServer
catch { }
finally { try { webSocket.Dispose(); } catch { } }
}
- public static bool SupportDropColumn(this Microsoft.EntityFrameworkCore.Migrations.Migration migration, string activeProvider)
- {
- return activeProvider != "Microsoft.EntityFrameworkCore.Sqlite";
- }
-
- public static bool SupportDropForeignKey(this Microsoft.EntityFrameworkCore.Migrations.Migration migration, string activeProvider)
- {
- return activeProvider != "Microsoft.EntityFrameworkCore.Sqlite";
- }
- public static bool SupportDropForeignKey(this DatabaseFacade facade)
- {
- return facade.ProviderName != "Microsoft.EntityFrameworkCore.Sqlite";
- }
-
public static async Task> GetTransactions(this BTCPayWallet client, uint256[] hashes, CancellationToken cts = default(CancellationToken))
{
hashes = hashes.Distinct().ToArray();
diff --git a/BTCPayServer/Hosting/BTCPayServerServices.cs b/BTCPayServer/Hosting/BTCPayServerServices.cs
index 68a73b118..57f5c0d90 100644
--- a/BTCPayServer/Hosting/BTCPayServerServices.cs
+++ b/BTCPayServer/Hosting/BTCPayServerServices.cs
@@ -25,7 +25,6 @@ using BTCPayServer.Services.Mails;
using System.Threading;
using BTCPayServer.Services.Wallets;
using BTCPayServer.Authentication;
-using BTCPayServer.Authentication.OpenId.Models;
using BTCPayServer.Logging;
using BTCPayServer.HostedServices;
using BTCPayServer.PaymentRequest;
diff --git a/BTCPayServer/Hosting/Startup.cs b/BTCPayServer/Hosting/Startup.cs
index 728871753..fa87e1e14 100644
--- a/BTCPayServer/Hosting/Startup.cs
+++ b/BTCPayServer/Hosting/Startup.cs
@@ -14,7 +14,6 @@ using BTCPayServer.Configuration;
using System.IO;
using Microsoft.Extensions.DependencyInjection.Extensions;
using AspNet.Security.OpenIdConnect.Primitives;
-using BTCPayServer.Authentication.OpenId.Models;
using BTCPayServer.Security;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using OpenIddict.Abstractions;
diff --git a/BTCPayServer/Migrations/20170913143004_Init.Designer.cs b/BTCPayServer/Migrations/20170913143004_Init.Designer.cs
deleted file mode 100644
index 9f74a3158..000000000
--- a/BTCPayServer/Migrations/20170913143004_Init.Designer.cs
+++ /dev/null
@@ -1,356 +0,0 @@
-//
-using BTCPayServer.Data;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Metadata;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage;
-using Microsoft.EntityFrameworkCore.Storage.Internal;
-using System;
-
-namespace BTCPayServer.Migrations
-{
- [DbContext(typeof(ApplicationDbContext))]
- [Migration("20170913143004_Init")]
- partial class Init
- {
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .HasAnnotation("ProductVersion", "2.0.0-rtm-26452");
-
- modelBuilder.Entity("BTCPayServer.Data.InvoiceData", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd();
-
- b.Property("Blob");
-
- b.Property("Created");
-
- b.Property("CustomerEmail");
-
- b.Property("ExceptionStatus");
-
- b.Property("ItemCode");
-
- b.Property("OrderId");
-
- b.Property("Status");
-
- b.Property("StoreDataId");
-
- b.HasKey("Id");
-
- b.HasIndex("StoreDataId");
-
- b.ToTable("Invoices");
- });
-
- modelBuilder.Entity("BTCPayServer.Data.PaymentData", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd();
-
- b.Property("Blob");
-
- b.Property("InvoiceDataId");
-
- b.HasKey("Id");
-
- b.HasIndex("InvoiceDataId");
-
- b.ToTable("Payments");
- });
-
- modelBuilder.Entity("BTCPayServer.Data.RefundAddressesData", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd();
-
- b.Property("Blob");
-
- b.Property("InvoiceDataId");
-
- b.HasKey("Id");
-
- b.HasIndex("InvoiceDataId");
-
- b.ToTable("RefundAddresses");
- });
-
- modelBuilder.Entity("BTCPayServer.Data.StoreData", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd();
-
- b.Property("DerivationStrategy");
-
- b.Property