diff --git a/.github/workflows/codacy.yml b/.github/workflows/codacy.yml index 2275c27..291b6f3 100644 --- a/.github/workflows/codacy.yml +++ b/.github/workflows/codacy.yml @@ -13,7 +13,7 @@ permissions: jobs: report-coverage: - if: github.repository == 'btcpay-zano/btcpayserver-zano-plugin' + if: github.repository == 'btcpay-lethean/btcpayserver-lethean-plugin' runs-on: ubuntu-latest steps: - name: Download coverage report diff --git a/.github/workflows/dotnet-format.yml b/.github/workflows/dotnet-format.yml index 5670f2e..ea78575 100644 --- a/.github/workflows/dotnet-format.yml +++ b/.github/workflows/dotnet-format.yml @@ -29,4 +29,4 @@ jobs: - name: Code format check run: | dotnet tool install -g dotnet-format - dotnet format btcpay-zano-plugin.sln --no-restore --verify-no-changes --exclude submodules/* --verbosity diagnostic \ No newline at end of file + dotnet format btcpay-lethean-plugin.sln --no-restore --verify-no-changes --exclude submodules/* --verbosity diagnostic \ No newline at end of file diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index f300eaf..9cde20d 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -36,8 +36,8 @@ jobs: - name: Deterministic build check run: | dotnet tool install --global dotnet-validate --version 0.0.1-preview.537 - dotnet pack Plugins/Zano/BTCPayServer.Plugins.Zano.csproj -c Release /p:PackageVersion=1 --no-build -o nuget-packages - dotnet validate package local nuget-packages/BTCPayServer.Plugins.Zano.1.0.0.nupkg + dotnet pack Plugins/Lethean/BTCPayServer.Plugins.Lethean.csproj -c Release /p:PackageVersion=1 --no-build -o nuget-packages + dotnet validate package local nuget-packages/BTCPayServer.Plugins.Lethean.1.0.0.nupkg - name: Run unit tests run: | @@ -61,4 +61,4 @@ jobs: uses: actions/upload-artifact@v4 with: name: nuget-package-${{ github.sha }} - path: nuget-packages/BTCPayServer.Plugins.Zano.1.0.0.nupkg \ No newline at end of file + path: nuget-packages/BTCPayServer.Plugins.Lethean.1.0.0.nupkg \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c315c41..04e331e 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -25,4 +25,4 @@ jobs: "GitRef": "${{ env.GIT_REF }}" }' env: - pluginSlug: "zano-plugin" \ No newline at end of file + pluginSlug: "lethean-plugin" \ No newline at end of file diff --git a/BTCPayServer.Plugins.IntegrationTests/BTCPayServer.Plugins.IntegrationTests.csproj b/BTCPayServer.Plugins.IntegrationTests/BTCPayServer.Plugins.IntegrationTests.csproj index bf6d5be..7e92dab 100644 --- a/BTCPayServer.Plugins.IntegrationTests/BTCPayServer.Plugins.IntegrationTests.csproj +++ b/BTCPayServer.Plugins.IntegrationTests/BTCPayServer.Plugins.IntegrationTests.csproj @@ -30,7 +30,7 @@ - + diff --git a/BTCPayServer.Plugins.IntegrationTests/Dockerfile b/BTCPayServer.Plugins.IntegrationTests/Dockerfile index d9b2252..8486ce6 100644 --- a/BTCPayServer.Plugins.IntegrationTests/Dockerfile +++ b/BTCPayServer.Plugins.IntegrationTests/Dockerfile @@ -27,9 +27,9 @@ ENV SCREEN_HEIGHT 600 \ COPY . . ARG CONFIGURATION_NAME=Release -ARG MONERO_PLUGIN_FOLDER=/root/.btcpayserver/Plugins/BTCPayServer.Plugins.Zano/ +ARG MONERO_PLUGIN_FOLDER=/root/.btcpayserver/Plugins/BTCPayServer.Plugins.Lethean/ RUN mkdir -p ${MONERO_PLUGIN_FOLDER} -RUN cd Plugins/Zano && dotnet build BTCPayServer.Plugins.Zano.sln --configuration ${CONFIGURATION_NAME} /p:RazorCompileOnBuild=true --output ${MONERO_PLUGIN_FOLDER} +RUN cd Plugins/Lethean && dotnet build BTCPayServer.Plugins.Lethean.sln --configuration ${CONFIGURATION_NAME} /p:RazorCompileOnBuild=true --output ${MONERO_PLUGIN_FOLDER} RUN cd BTCPayServer.Plugins.IntegrationTests && dotnet build --configuration ${CONFIGURATION_NAME} /p:CI_TESTS=true /p:RazorCompileOnBuild=true RUN dotnet tool install --global JetBrains.DotCover.CommandLineTools --version 2025.1.6 ENV PATH="$PATH:/root/.dotnet/tools" diff --git a/BTCPayServer.Plugins.IntegrationTests/Zano/IntegrationTestUtils.cs b/BTCPayServer.Plugins.IntegrationTests/Lethean/IntegrationTestUtils.cs similarity index 91% rename from BTCPayServer.Plugins.IntegrationTests/Zano/IntegrationTestUtils.cs rename to BTCPayServer.Plugins.IntegrationTests/Lethean/IntegrationTestUtils.cs index bdaa370..b78e62c 100644 --- a/BTCPayServer.Plugins.IntegrationTests/Zano/IntegrationTestUtils.cs +++ b/BTCPayServer.Plugins.IntegrationTests/Lethean/IntegrationTestUtils.cs @@ -10,7 +10,7 @@ using Npgsql; using static Mono.Unix.Native.Syscall; -namespace BTCPayServer.Plugins.IntegrationTests.Zano; +namespace BTCPayServer.Plugins.IntegrationTests.Lethean; public static class IntegrationTestUtils { @@ -19,7 +19,7 @@ public static class IntegrationTestUtils .CreateLogger("IntegrationTestUtils"); private static readonly string ContainerWalletDir = - Environment.GetEnvironmentVariable("BTCPAY_ZANO_WALLET_DAEMON_WALLETDIR") ?? "/wallet"; + Environment.GetEnvironmentVariable("BTCPAY_LTHN_WALLET_DAEMON_WALLETDIR") ?? "/wallet"; public static async Task CleanUpAsync(PlaywrightTester playwrightTester) { @@ -61,7 +61,7 @@ public static class IntegrationTestUtils } } - public static async Task CopyWalletFilesToZanoRpcDirAsync(PlaywrightTester playwrightTester, String walletDir) + public static async Task CopyWalletFilesToLetheanRpcDirAsync(PlaywrightTester playwrightTester, String walletDir) { Logger.LogInformation("Starting to copy wallet files"); if (playwrightTester.Server.PayTester.InContainer) @@ -84,7 +84,7 @@ public static class IntegrationTestUtils } catch (Exception ex) { - Logger.LogError(ex, "Failed to copy wallet files to the Zano directory."); + Logger.LogError(ex, "Failed to copy wallet files to the Lethean directory."); } } @@ -102,7 +102,7 @@ public static class IntegrationTestUtils File.Copy(src, dst, overwrite: true); - // zano ownership + // lethean ownership if (chown(dst, 980, 980) == 0) { return; @@ -119,20 +119,20 @@ public static class IntegrationTestUtils var fullWalletDir = Path.Combine(AppContext.BaseDirectory, "Resources", walletDir); await RunProcessAsync("docker", - $"cp \"{Path.Combine(fullWalletDir, "wallet")}\" zano_wallet:/wallet/wallet"); + $"cp \"{Path.Combine(fullWalletDir, "wallet")}\" lethean_wallet:/wallet/wallet"); await RunProcessAsync("docker", - $"cp \"{Path.Combine(fullWalletDir, "wallet.keys")}\" zano_wallet:/wallet/wallet.keys"); + $"cp \"{Path.Combine(fullWalletDir, "wallet.keys")}\" lethean_wallet:/wallet/wallet.keys"); await RunProcessAsync("docker", - $"cp \"{Path.Combine(fullWalletDir, "password")}\" zano_wallet:/wallet/password"); + $"cp \"{Path.Combine(fullWalletDir, "password")}\" lethean_wallet:/wallet/password"); await RunProcessAsync("docker", - "exec zano_wallet chown zano:zano /wallet/wallet /wallet/wallet.keys /wallet/password"); + "exec lethean_wallet chown lethean:lethean /wallet/wallet /wallet/wallet.keys /wallet/password"); } catch (Exception ex) { - Logger.LogError(ex, "Failed to copy wallet files to the Zano directory."); + Logger.LogError(ex, "Failed to copy wallet files to the Lethean directory."); } } @@ -163,7 +163,7 @@ public static class IntegrationTestUtils var removeWalletFromDocker = new ProcessStartInfo { FileName = "docker", - Arguments = "exec zano_wallet sh -c \"rm -rf /wallet/*\"", + Arguments = "exec lethean_wallet sh -c \"rm -rf /wallet/*\"", RedirectStandardOutput = true, RedirectStandardError = true }; diff --git a/BTCPayServer.Plugins.IntegrationTests/Lethean/LetheanAndBitcoinIntegrationTestBase.cs b/BTCPayServer.Plugins.IntegrationTests/Lethean/LetheanAndBitcoinIntegrationTestBase.cs new file mode 100644 index 0000000..da82441 --- /dev/null +++ b/BTCPayServer.Plugins.IntegrationTests/Lethean/LetheanAndBitcoinIntegrationTestBase.cs @@ -0,0 +1,25 @@ +using BTCPayServer.Tests; + +using Xunit.Abstractions; + +namespace BTCPayServer.Plugins.IntegrationTests.Lethean +{ + public class LetheanAndBitcoinIntegrationTestBase : UnitTestBase + { + + public LetheanAndBitcoinIntegrationTestBase(ITestOutputHelper helper) : base(helper) + { + SetDefaultEnv("BTCPAY_LTHN_DAEMON_URI", "http://127.0.0.1:46941"); + SetDefaultEnv("BTCPAY_LTHN_WALLET_DAEMON_URI", "http://127.0.0.1:46944"); + SetDefaultEnv("BTCPAY_LTHN_WALLET_DAEMON_WALLETDIR", "/wallet"); + } + + private static void SetDefaultEnv(string key, string defaultValue) + { + if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable(key))) + { + Environment.SetEnvironmentVariable(key, defaultValue); + } + } + } +} \ No newline at end of file diff --git a/BTCPayServer.Plugins.IntegrationTests/Zano/ZanoPluginIntegrationTest.cs b/BTCPayServer.Plugins.IntegrationTests/Lethean/LetheanPluginIntegrationTest.cs similarity index 79% rename from BTCPayServer.Plugins.IntegrationTests/Zano/ZanoPluginIntegrationTest.cs rename to BTCPayServer.Plugins.IntegrationTests/Lethean/LetheanPluginIntegrationTest.cs index 418d6f8..77ff4f0 100644 --- a/BTCPayServer.Plugins.IntegrationTests/Zano/ZanoPluginIntegrationTest.cs +++ b/BTCPayServer.Plugins.IntegrationTests/Lethean/LetheanPluginIntegrationTest.cs @@ -1,4 +1,4 @@ -using BTCPayServer.Plugins.Zano.Services; +using BTCPayServer.Plugins.Lethean.Services; using BTCPayServer.Rating; using BTCPayServer.Services.Rates; using BTCPayServer.Tests.Mocks; @@ -6,12 +6,12 @@ using BTCPayServer.Tests.Mocks; using Xunit; using Xunit.Abstractions; -namespace BTCPayServer.Plugins.IntegrationTests.Zano; +namespace BTCPayServer.Plugins.IntegrationTests.Lethean; -public class ZanoPluginIntegrationTest(ITestOutputHelper helper) : ZanoAndBitcoinIntegrationTestBase(helper) +public class LetheanPluginIntegrationTest(ITestOutputHelper helper) : LetheanAndBitcoinIntegrationTestBase(helper) { [Fact] - public async Task ShouldEnableZanoPluginSuccessfully() + public async Task ShouldEnableLetheanPluginSuccessfully() { await using var s = CreatePlaywrightTester(); await s.StartAsync(); @@ -24,21 +24,21 @@ public class ZanoPluginIntegrationTest(ITestOutputHelper helper) : ZanoAndBitcoi var coinAverageMock = new MockRateProvider(); coinAverageMock.ExchangeRates.Add(new PairRate(CurrencyPair.Parse("BTC_USD"), new BidAsk(5000m))); coinAverageMock.ExchangeRates.Add(new PairRate(CurrencyPair.Parse("BTC_EUR"), new BidAsk(4000m))); - coinAverageMock.ExchangeRates.Add(new PairRate(CurrencyPair.Parse("ZANO_BTC"), new BidAsk(4500m))); + coinAverageMock.ExchangeRates.Add(new PairRate(CurrencyPair.Parse("LTHN_BTC"), new BidAsk(4500m))); rateProviderFactory.Providers.Add("coingecko", coinAverageMock); var kraken = new MockRateProvider(); kraken.ExchangeRates.Add(new PairRate(CurrencyPair.Parse("BTC_USD"), new BidAsk(0.1m))); - kraken.ExchangeRates.Add(new PairRate(CurrencyPair.Parse("ZANO_USD"), new BidAsk(0.1m))); - kraken.ExchangeRates.Add(new PairRate(CurrencyPair.Parse("ZANO_BTC"), new BidAsk(0.1m))); + kraken.ExchangeRates.Add(new PairRate(CurrencyPair.Parse("LTHN_USD"), new BidAsk(0.1m))); + kraken.ExchangeRates.Add(new PairRate(CurrencyPair.Parse("LTHN_BTC"), new BidAsk(0.1m))); rateProviderFactory.Providers.Add("kraken", kraken); } await s.RegisterNewUser(true); await s.CreateNewStore(preferredExchange: "Kraken"); - await s.Page.Locator("a.nav-link[href*='zano/ZANO']").ClickAsync(); + await s.Page.Locator("a.nav-link[href*='lethean/LTHN']").ClickAsync(); - // Enable Zano and configure settlement threshold + // Enable Lethean and configure settlement threshold await s.Page.CheckAsync("#Enabled"); await s.Page.SelectOptionAsync("#SettlementConfirmationThresholdChoice", "2"); await s.Page.ClickAsync("#SaveButton"); @@ -46,7 +46,7 @@ public class ZanoPluginIntegrationTest(ITestOutputHelper helper) : ZanoAndBitcoi // Set rate provider await s.Page.Locator("#menu-item-General").ClickAsync(); await s.Page.Locator("#menu-item-Rates").ClickAsync(); - await s.Page.FillAsync("#DefaultCurrencyPairs", "BTC_USD,ZANO_USD,ZANO_BTC"); + await s.Page.FillAsync("#DefaultCurrencyPairs", "BTC_USD,LTHN_USD,LTHN_BTC"); await s.Page.SelectOptionAsync("#PrimarySource_PreferredExchange", "kraken"); await s.Page.Locator("#page-primary").ClickAsync(); @@ -54,7 +54,7 @@ public class ZanoPluginIntegrationTest(ITestOutputHelper helper) : ZanoAndBitcoi await s.Page.Locator("a.nav-link[href*='invoices']").ClickAsync(); await s.Page.Locator("#page-primary").ClickAsync(); await s.Page.FillAsync("#Amount", "4.20"); - await s.Page.FillAsync("#BuyerEmail", "zano@zano.org"); + await s.Page.FillAsync("#BuyerEmail", "lethean@lethean.org"); await Task.Delay(TimeSpan.FromSeconds(25)); // wallet-rpc needs some time to sync await s.Page.Locator("#page-primary").ClickAsync(); @@ -72,7 +72,7 @@ public class ZanoPluginIntegrationTest(ITestOutputHelper helper) : ZanoAndBitcoi // Select confirmation time to 0 await s.Page.GoBackAsync(); - await s.Page.Locator("a.nav-link[href*='zano/ZANO']").ClickAsync(); + await s.Page.Locator("a.nav-link[href*='lethean/LTHN']").ClickAsync(); await s.Page.SelectOptionAsync("#SettlementConfirmationThresholdChoice", "3"); await s.Page.ClickAsync("#SaveButton"); @@ -83,11 +83,11 @@ public class ZanoPluginIntegrationTest(ITestOutputHelper helper) : ZanoAndBitcoi public async Task ShouldLoadWalletOnStartUpIfExists() { await using var s = CreatePlaywrightTester(); - await IntegrationTestUtils.CopyWalletFilesToZanoRpcDirAsync(s, "wallet"); + await IntegrationTestUtils.CopyWalletFilesToLetheanRpcDirAsync(s, "wallet"); await s.StartAsync(); await s.RegisterNewUser(true); await s.CreateNewStore(); - await s.Page.Locator("a.nav-link[href*='zano/ZANO']").ClickAsync(); + await s.Page.Locator("a.nav-link[href*='lethean/LTHN']").ClickAsync(); var walletRpcIsAvailable = await s.Page .Locator("li.list-group-item:text('Wallet RPC available: True')") @@ -102,11 +102,11 @@ public class ZanoPluginIntegrationTest(ITestOutputHelper helper) : ZanoAndBitcoi public async Task ShouldLoadWalletWithPasswordOnStartUpIfExists() { await using var s = CreatePlaywrightTester(); - await IntegrationTestUtils.CopyWalletFilesToZanoRpcDirAsync(s, "wallet_password"); + await IntegrationTestUtils.CopyWalletFilesToLetheanRpcDirAsync(s, "wallet_password"); await s.StartAsync(); await s.RegisterNewUser(true); await s.CreateNewStore(); - await s.Page.Locator("a.nav-link[href*='zano/ZANO']").ClickAsync(); + await s.Page.Locator("a.nav-link[href*='lethean/LTHN']").ClickAsync(); var walletRpcIsAvailable = await s.Page .Locator("li.list-group-item:text('Wallet RPC available: True')") diff --git a/BTCPayServer.Plugins.IntegrationTests/Zano/ZanoAndBitcoinIntegrationTestBase.cs b/BTCPayServer.Plugins.IntegrationTests/Zano/ZanoAndBitcoinIntegrationTestBase.cs deleted file mode 100644 index 7b50061..0000000 --- a/BTCPayServer.Plugins.IntegrationTests/Zano/ZanoAndBitcoinIntegrationTestBase.cs +++ /dev/null @@ -1,25 +0,0 @@ -using BTCPayServer.Tests; - -using Xunit.Abstractions; - -namespace BTCPayServer.Plugins.IntegrationTests.Zano -{ - public class ZanoAndBitcoinIntegrationTestBase : UnitTestBase - { - - public ZanoAndBitcoinIntegrationTestBase(ITestOutputHelper helper) : base(helper) - { - SetDefaultEnv("BTCPAY_ZANO_DAEMON_URI", "http://127.0.0.1:11211"); - SetDefaultEnv("BTCPAY_ZANO_WALLET_DAEMON_URI", "http://127.0.0.1:11212"); - SetDefaultEnv("BTCPAY_ZANO_WALLET_DAEMON_WALLETDIR", "/wallet"); - } - - private static void SetDefaultEnv(string key, string defaultValue) - { - if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable(key))) - { - Environment.SetEnvironmentVariable(key, defaultValue); - } - } - } -} \ No newline at end of file diff --git a/BTCPayServer.Plugins.IntegrationTests/docker-compose.yml b/BTCPayServer.Plugins.IntegrationTests/docker-compose.yml index d2279e0..68ae1c7 100644 --- a/BTCPayServer.Plugins.IntegrationTests/docker-compose.yml +++ b/BTCPayServer.Plugins.IntegrationTests/docker-compose.yml @@ -11,18 +11,18 @@ services: TESTS_EXPLORER_POSTGRES: User ID=postgres;Include Error Detail=true;Host=postgres;Port=5432;Database=nbxplorer TESTS_HOSTNAME: tests TESTS_INCONTAINER: "true" - BTCPAY_ZANO_DAEMON_URI: http://37.27.100.59:10505 - BTCPAY_ZANO_WALLET_DAEMON_URI: http://zano_wallet:11212 - BTCPAY_ZANO_WALLET_DAEMON_WALLETDIR: /wallet + BTCPAY_LTHN_DAEMON_URI: http://127.0.0.1:46941 + BTCPAY_LTHN_WALLET_DAEMON_URI: http://lethean_wallet:46944 + BTCPAY_LTHN_WALLET_DAEMON_WALLETDIR: /wallet depends_on: - nbxplorer - postgres - - zano_wallet + - lethean_wallet extra_hosts: - "tests:127.0.0.1" volumes: - ../coverage:/coverage - - zano_wallet:/wallet + - lethean_wallet:/wallet # The dev container is not used, it is just handy to run `docker-compose up dev` to start all services dev: @@ -32,7 +32,7 @@ services: depends_on: - nbxplorer - postgres - - zano_wallet + - lethean_wallet nbxplorer: image: nicolasdorier/nbxplorer:2.5.25 @@ -89,40 +89,40 @@ services: volumes: - "bitcoin_datadir:/data" - zanod: - image: pavelravaga/zano:2.2.0.455 + letheand: + image: letheanio/letheand:latest restart: unless-stopped - container_name: zanod - entrypoint: zanod + container_name: letheand + entrypoint: letheand command: > --rpc-bind-ip=0.0.0.0 - --rpc-bind-port=11211 + --rpc-bind-port=46941 --log-level=2 --data-dir=/data volumes: - - zano_data:/data + - lethean_data:/data ports: - - "11211:11211" + - "46941:46941" - zano_wallet: - image: pavelravaga/zano:2.2.0.455 + lethean_wallet: + image: letheanio/letheand:latest restart: unless-stopped - container_name: zano_wallet + container_name: lethean_wallet entrypoint: /bin/bash command: - -c - | if [ ! -f /wallet/wallet.keys ]; then echo "Generating new wallet..." - echo "exit" | simplewallet --generate-new-wallet=/wallet/wallet --password pass --daemon-address=37.27.100.59:10505 + echo "exit" | simplewallet --generate-new-wallet=/wallet/wallet --password pass --daemon-address=127.0.0.1:46941 fi - simplewallet --wallet-file=/wallet/wallet --password pass --daemon-address=37.27.100.59:10505 --rpc-bind-ip=0.0.0.0 --rpc-bind-port=11212 + simplewallet --wallet-file=/wallet/wallet --password pass --daemon-address=127.0.0.1:46941 --rpc-bind-ip=0.0.0.0 --rpc-bind-port=46944 ports: - - "11212:11212" + - "46944:46944" volumes: - - zano_wallet:/wallet + - lethean_wallet:/wallet depends_on: - - zanod + - letheand postgres: image: postgres:17.4 @@ -136,8 +136,8 @@ services: volumes: bitcoin_datadir: - zano_data: - zano_wallet: + lethean_data: + lethean_wallet: networks: default: diff --git a/BTCPayServer.Plugins.UnitTests/BTCPayServer.Plugins.UnitTests.csproj b/BTCPayServer.Plugins.UnitTests/BTCPayServer.Plugins.UnitTests.csproj index 9c7ff68..94bd491 100644 --- a/BTCPayServer.Plugins.UnitTests/BTCPayServer.Plugins.UnitTests.csproj +++ b/BTCPayServer.Plugins.UnitTests/BTCPayServer.Plugins.UnitTests.csproj @@ -29,7 +29,7 @@ - + diff --git a/BTCPayServer.Plugins.UnitTests/Lethean/Configuration/LetheanConfigurationTests.cs b/BTCPayServer.Plugins.UnitTests/Lethean/Configuration/LetheanConfigurationTests.cs new file mode 100644 index 0000000..245c3a5 --- /dev/null +++ b/BTCPayServer.Plugins.UnitTests/Lethean/Configuration/LetheanConfigurationTests.cs @@ -0,0 +1,76 @@ +using System; + +using BTCPayServer.Plugins.Lethean.Configuration; + +using Xunit; + +namespace BTCPayServer.Plugins.UnitTests.Lethean.Configuration +{ + public class LetheanConfigurationTests + { + [Trait("Category", "Unit")] + [Fact] + public void LetheanConfiguration_ShouldInitializeWithEmptyDictionary() + { + var config = new LetheanConfiguration(); + + Assert.NotNull(config.LetheanConfigurationItems); + Assert.Empty(config.LetheanConfigurationItems); + } + + [Trait("Category", "Unit")] + [Fact] + public void LetheanConfigurationItem_ShouldSetAndGetProperties() + { + var configItem = new LetheanConfigurationItem + { + DaemonRpcUri = new Uri("http://localhost:36941"), + InternalWalletRpcUri = new Uri("http://localhost:36944"), + WalletDirectory = "/wallets" + }; + + Assert.Equal("http://localhost:36941/", configItem.DaemonRpcUri.ToString()); + Assert.Equal("http://localhost:36944/", configItem.InternalWalletRpcUri.ToString()); + Assert.Equal("/wallets", configItem.WalletDirectory); + } + + [Trait("Category", "Unit")] + [Fact] + public void LetheanConfiguration_ShouldAddAndRetrieveItems() + { + var config = new LetheanConfiguration(); + var configItem = new LetheanConfigurationItem + { + DaemonRpcUri = new Uri("http://localhost:36941"), + InternalWalletRpcUri = new Uri("http://localhost:36944"), + WalletDirectory = "/wallets" + }; + + config.LetheanConfigurationItems.Add("LTHN", configItem); + + Assert.Single(config.LetheanConfigurationItems); + Assert.True(config.LetheanConfigurationItems.ContainsKey("LTHN")); + Assert.Equal(configItem, config.LetheanConfigurationItems["LTHN"]); + } + + [Trait("Category", "Unit")] + [Fact] + public void LetheanConfiguration_ShouldHandleDuplicateKeys() + { + var config = new LetheanConfiguration(); + var configItem1 = new LetheanConfigurationItem + { + DaemonRpcUri = new Uri("http://localhost:36941") + }; + var configItem2 = new LetheanConfigurationItem + { + DaemonRpcUri = new Uri("http://localhost:36944") + }; + + config.LetheanConfigurationItems.Add("LTHN", configItem1); + + Assert.Throws(() => + config.LetheanConfigurationItems.Add("LTHN", configItem2)); + } + } +} diff --git a/BTCPayServer.Plugins.UnitTests/Zano/Payments/ZanoPaymentDataTests.cs b/BTCPayServer.Plugins.UnitTests/Lethean/Payments/LetheanPaymentDataTests.cs similarity index 83% rename from BTCPayServer.Plugins.UnitTests/Zano/Payments/ZanoPaymentDataTests.cs rename to BTCPayServer.Plugins.UnitTests/Lethean/Payments/LetheanPaymentDataTests.cs index 92ff646..fbcf7ec 100644 --- a/BTCPayServer.Plugins.UnitTests/Zano/Payments/ZanoPaymentDataTests.cs +++ b/BTCPayServer.Plugins.UnitTests/Lethean/Payments/LetheanPaymentDataTests.cs @@ -1,16 +1,16 @@ -using BTCPayServer.Plugins.Zano.Payments; +using BTCPayServer.Plugins.Lethean.Payments; using Xunit; -namespace BTCPayServer.Plugins.UnitTests.Zano.Payments +namespace BTCPayServer.Plugins.UnitTests.Lethean.Payments { - public class ZanoPaymentDataTests + public class LetheanPaymentDataTests { [Trait("Category", "Unit")] [Fact] public void DefaultValues_ShouldBeCorrect() { - var paymentData = new ZanoPaymentData(); + var paymentData = new LetheanPaymentData(); Assert.Null(paymentData.PaymentId); Assert.Equal(0, paymentData.BlockHeight); @@ -24,7 +24,7 @@ namespace BTCPayServer.Plugins.UnitTests.Zano.Payments [Fact] public void Properties_ShouldBeSettable() { - var paymentData = new ZanoPaymentData(); + var paymentData = new LetheanPaymentData(); paymentData.PaymentId = "abcdef0123456789"; paymentData.BlockHeight = 100; diff --git a/BTCPayServer.Plugins.UnitTests/Lethean/RPC/LetheanEventTests.cs b/BTCPayServer.Plugins.UnitTests/Lethean/RPC/LetheanEventTests.cs new file mode 100644 index 0000000..a737068 --- /dev/null +++ b/BTCPayServer.Plugins.UnitTests/Lethean/RPC/LetheanEventTests.cs @@ -0,0 +1,28 @@ +using BTCPayServer.Plugins.Lethean.RPC; + +using Xunit; + +namespace BTCPayServer.Plugins.UnitTests.Lethean.RPC +{ + public class LetheanPollEventTest + { + [Fact] + public void DefaultInitialization_ShouldHaveNullCryptoCode() + { + var pollEvent = new LetheanPollEvent(); + + Assert.Null(pollEvent.CryptoCode); + } + + [Fact] + public void PropertyAssignment_ShouldSetAndRetrieveValues() + { + var pollEvent = new LetheanPollEvent + { + CryptoCode = "LTHN" + }; + + Assert.Equal("LTHN", pollEvent.CryptoCode); + } + } +} diff --git a/BTCPayServer.Plugins.UnitTests/Zano/RPC/Models/ParseStringConverterTest.cs b/BTCPayServer.Plugins.UnitTests/Lethean/RPC/Models/ParseStringConverterTest.cs similarity index 96% rename from BTCPayServer.Plugins.UnitTests/Zano/RPC/Models/ParseStringConverterTest.cs rename to BTCPayServer.Plugins.UnitTests/Lethean/RPC/Models/ParseStringConverterTest.cs index bb354c6..9beee04 100644 --- a/BTCPayServer.Plugins.UnitTests/Zano/RPC/Models/ParseStringConverterTest.cs +++ b/BTCPayServer.Plugins.UnitTests/Lethean/RPC/Models/ParseStringConverterTest.cs @@ -1,10 +1,10 @@ -using BTCPayServer.Plugins.Zano.RPC.Models; +using BTCPayServer.Plugins.Lethean.RPC.Models; using Newtonsoft.Json; using Xunit; -namespace BTCPayServer.Plugins.UnitTests.Zano.RPC.Models +namespace BTCPayServer.Plugins.UnitTests.Lethean.RPC.Models { public class ParseStringConverterTests { diff --git a/BTCPayServer.Plugins.UnitTests/Zano/Utils/ZanoMoneyTests.cs b/BTCPayServer.Plugins.UnitTests/Lethean/Utils/LetheanMoneyTests.cs similarity index 69% rename from BTCPayServer.Plugins.UnitTests/Zano/Utils/ZanoMoneyTests.cs rename to BTCPayServer.Plugins.UnitTests/Lethean/Utils/LetheanMoneyTests.cs index c4cf9f1..090e64a 100644 --- a/BTCPayServer.Plugins.UnitTests/Zano/Utils/ZanoMoneyTests.cs +++ b/BTCPayServer.Plugins.UnitTests/Lethean/Utils/LetheanMoneyTests.cs @@ -1,12 +1,12 @@ using System.Globalization; -using BTCPayServer.Plugins.Zano.Utils; +using BTCPayServer.Plugins.Lethean.Utils; using Xunit; -namespace BTCPayServer.Plugins.UnitTests.Zano.Utils +namespace BTCPayServer.Plugins.UnitTests.Lethean.Utils { - public class ZanoMoneyTests + public class LetheanMoneyTests { [Trait("Category", "Unit")] [Theory] @@ -16,7 +16,7 @@ namespace BTCPayServer.Plugins.UnitTests.Zano.Utils public void Convert_LongToDecimal_ReturnsExpectedValue(long atomicUnits, string expectedString) { decimal expected = decimal.Parse(expectedString, CultureInfo.InvariantCulture); - decimal result = ZanoMoney.Convert(atomicUnits); + decimal result = LetheanMoney.Convert(atomicUnits); Assert.Equal(expected, result); } @@ -25,10 +25,10 @@ namespace BTCPayServer.Plugins.UnitTests.Zano.Utils [InlineData("0.000000000001", 1)] [InlineData("0.123456789012", 123456789012)] [InlineData("1.000000000000", 1000000000000)] - public void Convert_DecimalToLong_ReturnsExpectedValue(string zanoString, long expectedAtomicUnits) + public void Convert_DecimalToLong_ReturnsExpectedValue(string letheanString, long expectedAtomicUnits) { - decimal zano = decimal.Parse(zanoString, CultureInfo.InvariantCulture); - long result = ZanoMoney.Convert(zano); + decimal lethean = decimal.Parse(letheanString, CultureInfo.InvariantCulture); + long result = LetheanMoney.Convert(lethean); Assert.Equal(expectedAtomicUnits, result); } @@ -39,8 +39,8 @@ namespace BTCPayServer.Plugins.UnitTests.Zano.Utils [InlineData(1000000000000)] public void RoundTripConversion_LongToDecimalToLong_ReturnsOriginalValue(long atomicUnits) { - decimal zano = ZanoMoney.Convert(atomicUnits); - long convertedBack = ZanoMoney.Convert(zano); + decimal lethean = LetheanMoney.Convert(atomicUnits); + long convertedBack = LetheanMoney.Convert(lethean); Assert.Equal(atomicUnits, convertedBack); } } diff --git a/BTCPayServer.Plugins.UnitTests/Zano/ViewModels/ZanoPaymentViewModelTests.cs b/BTCPayServer.Plugins.UnitTests/Lethean/ViewModels/LetheanPaymentViewModelTests.cs similarity index 70% rename from BTCPayServer.Plugins.UnitTests/Zano/ViewModels/ZanoPaymentViewModelTests.cs rename to BTCPayServer.Plugins.UnitTests/Lethean/ViewModels/LetheanPaymentViewModelTests.cs index e6ff95b..94b76c2 100644 --- a/BTCPayServer.Plugins.UnitTests/Zano/ViewModels/ZanoPaymentViewModelTests.cs +++ b/BTCPayServer.Plugins.UnitTests/Lethean/ViewModels/LetheanPaymentViewModelTests.cs @@ -1,27 +1,27 @@ using BTCPayServer.Payments; -using BTCPayServer.Plugins.Zano.ViewModels; +using BTCPayServer.Plugins.Lethean.ViewModels; using Xunit; -namespace BTCPayServer.Plugins.UnitTests.Zano.ViewModels +namespace BTCPayServer.Plugins.UnitTests.Lethean.ViewModels { - public class ZanoPaymentViewModelTests + public class LetheanPaymentViewModelTests { [Trait("Category", "Unit")] [Fact] - public void ZanoPaymentViewModel_SetGetProperties_ReturnsCorrectValues() + public void LetheanPaymentViewModel_SetGetProperties_ReturnsCorrectValues() { - var viewModel = new ZanoPaymentViewModel(); + var viewModel = new LetheanPaymentViewModel(); - var paymentMethodId = new PaymentMethodId("ZANO"); + var paymentMethodId = new PaymentMethodId("LTHN"); var confirmations = "3"; - var depositAddress = "zanoaddress"; + var depositAddress = "letheanaddress"; var amount = "100.5"; var transactionId = "tx123"; var receivedTime = DateTimeOffset.UtcNow; - var transactionLink = "https://explorer.zano.com/tx/tx123"; - var currency = "ZANO"; + var transactionLink = "https://explorer.lethean.com/tx/tx123"; + var currency = "LTHN"; viewModel.PaymentMethodId = paymentMethodId; viewModel.Confirmations = confirmations; diff --git a/BTCPayServer.Plugins.UnitTests/Zano/Configuration/ZanoConfigurationTests.cs b/BTCPayServer.Plugins.UnitTests/Zano/Configuration/ZanoConfigurationTests.cs deleted file mode 100644 index bbdae89..0000000 --- a/BTCPayServer.Plugins.UnitTests/Zano/Configuration/ZanoConfigurationTests.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System; - -using BTCPayServer.Plugins.Zano.Configuration; - -using Xunit; - -namespace BTCPayServer.Plugins.UnitTests.Zano.Configuration -{ - public class ZanoConfigurationTests - { - [Trait("Category", "Unit")] - [Fact] - public void ZanoConfiguration_ShouldInitializeWithEmptyDictionary() - { - var config = new ZanoConfiguration(); - - Assert.NotNull(config.ZanoConfigurationItems); - Assert.Empty(config.ZanoConfigurationItems); - } - - [Trait("Category", "Unit")] - [Fact] - public void ZanoConfigurationItem_ShouldSetAndGetProperties() - { - var configItem = new ZanoConfigurationItem - { - DaemonRpcUri = new Uri("http://localhost:11211"), - InternalWalletRpcUri = new Uri("http://localhost:11212"), - WalletDirectory = "/wallets" - }; - - Assert.Equal("http://localhost:11211/", configItem.DaemonRpcUri.ToString()); - Assert.Equal("http://localhost:11212/", configItem.InternalWalletRpcUri.ToString()); - Assert.Equal("/wallets", configItem.WalletDirectory); - } - - [Trait("Category", "Unit")] - [Fact] - public void ZanoConfiguration_ShouldAddAndRetrieveItems() - { - var config = new ZanoConfiguration(); - var configItem = new ZanoConfigurationItem - { - DaemonRpcUri = new Uri("http://localhost:11211"), - InternalWalletRpcUri = new Uri("http://localhost:11212"), - WalletDirectory = "/wallets" - }; - - config.ZanoConfigurationItems.Add("ZANO", configItem); - - Assert.Single(config.ZanoConfigurationItems); - Assert.True(config.ZanoConfigurationItems.ContainsKey("ZANO")); - Assert.Equal(configItem, config.ZanoConfigurationItems["ZANO"]); - } - - [Trait("Category", "Unit")] - [Fact] - public void ZanoConfiguration_ShouldHandleDuplicateKeys() - { - var config = new ZanoConfiguration(); - var configItem1 = new ZanoConfigurationItem - { - DaemonRpcUri = new Uri("http://localhost:11211") - }; - var configItem2 = new ZanoConfigurationItem - { - DaemonRpcUri = new Uri("http://localhost:11212") - }; - - config.ZanoConfigurationItems.Add("ZANO", configItem1); - - Assert.Throws(() => - config.ZanoConfigurationItems.Add("ZANO", configItem2)); - } - } -} diff --git a/BTCPayServer.Plugins.UnitTests/Zano/RPC/ZanoEventTests.cs b/BTCPayServer.Plugins.UnitTests/Zano/RPC/ZanoEventTests.cs deleted file mode 100644 index 751674a..0000000 --- a/BTCPayServer.Plugins.UnitTests/Zano/RPC/ZanoEventTests.cs +++ /dev/null @@ -1,28 +0,0 @@ -using BTCPayServer.Plugins.Zano.RPC; - -using Xunit; - -namespace BTCPayServer.Plugins.UnitTests.Zano.RPC -{ - public class ZanoPollEventTest - { - [Fact] - public void DefaultInitialization_ShouldHaveNullCryptoCode() - { - var pollEvent = new ZanoPollEvent(); - - Assert.Null(pollEvent.CryptoCode); - } - - [Fact] - public void PropertyAssignment_ShouldSetAndRetrieveValues() - { - var pollEvent = new ZanoPollEvent - { - CryptoCode = "ZANO" - }; - - Assert.Equal("ZANO", pollEvent.CryptoCode); - } - } -} diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 20981be..7f3df42 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -3,4 +3,4 @@ We follow the [Ruby Community's Code of Conduct](https://www.ruby-lang.org/en/conduct/) to ensure a safe, respectful, and productive environment for all participants. -If you experience or witness any violations of this Code of Conduct, please reach out to us in our [Matrix room](https://matrix.to/#/#btcpay-zano:matrix.org) so we can address the issue promptly. \ No newline at end of file +If you experience or witness any violations of this Code of Conduct, please reach out to us in our [Matrix room](https://matrix.to/#/#btcpay-lethean:matrix.org) so we can address the issue promptly. \ No newline at end of file diff --git a/Plugins/Zano/BTCPayServer.Plugins.Zano.csproj b/Plugins/Lethean/BTCPayServer.Plugins.Lethean.csproj similarity index 94% rename from Plugins/Zano/BTCPayServer.Plugins.Zano.csproj rename to Plugins/Lethean/BTCPayServer.Plugins.Lethean.csproj index b3fa72b..849f7b4 100644 --- a/Plugins/Zano/BTCPayServer.Plugins.Zano.csproj +++ b/Plugins/Lethean/BTCPayServer.Plugins.Lethean.csproj @@ -6,8 +6,8 @@ - Zano - This plugin extends BTCPay Server to enable users to receive payments via Zano. + Lethean + This plugin extends BTCPay Server to enable users to receive payments via Lethean. 1.0.0 true @@ -66,7 +66,7 @@ --> - + PreserveNewest @@ -75,6 +75,6 @@ - + diff --git a/Plugins/Lethean/BTCPayServer.Plugins.Lethean.json b/Plugins/Lethean/BTCPayServer.Plugins.Lethean.json new file mode 100644 index 0000000..488c31f --- /dev/null +++ b/Plugins/Lethean/BTCPayServer.Plugins.Lethean.json @@ -0,0 +1,17 @@ +{ + "Identifier": "BTCPayServer.Plugins.Lethean", + "Name": "Lethean", + "Version": "1.0.0", + "Description": "Accept Lethean (LTHN) payments in BTCPay Server. Privacy-focused cryptocurrency with confidential transactions.", + "SystemPlugin": false, + "Dependencies": [ + { + "Identifier": "BTCPayServer", + "Condition": ">=2.1.0" + } + ], + "Documentation": "https://github.com/lethean-io/btcpayserver-lethean-plugin", + "Source": "https://github.com/lethean-io/btcpayserver-lethean-plugin", + "Author": "Lethean", + "AuthorLink": "https://lethean.io" +} diff --git a/Plugins/Zano/BTCPayServer.Plugins.Zano.sln b/Plugins/Lethean/BTCPayServer.Plugins.Lethean.sln similarity index 90% rename from Plugins/Zano/BTCPayServer.Plugins.Zano.sln rename to Plugins/Lethean/BTCPayServer.Plugins.Lethean.sln index a934be0..0c6bf54 100644 --- a/Plugins/Zano/BTCPayServer.Plugins.Zano.sln +++ b/Plugins/Lethean/BTCPayServer.Plugins.Lethean.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31903.59 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BTCPayServer.Plugins.Zano", "BTCPayServer.Plugins.Zano.csproj", "{440E70AD-BA40-449C-8315-6A13D95B6ED7}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BTCPayServer.Plugins.Lethean", "BTCPayServer.Plugins.Lethean.csproj", "{440E70AD-BA40-449C-8315-6A13D95B6ED7}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/Plugins/Lethean/Configuration/LetheanConfiguration.cs b/Plugins/Lethean/Configuration/LetheanConfiguration.cs new file mode 100644 index 0000000..f97ed64 --- /dev/null +++ b/Plugins/Lethean/Configuration/LetheanConfiguration.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; + +namespace BTCPayServer.Plugins.Lethean.Configuration +{ + public class LetheanConfiguration + { + public Dictionary LetheanConfigurationItems { get; set; } = []; + } + + public class LetheanConfigurationItem + { + public Uri DaemonRpcUri { get; set; } + public Uri InternalWalletRpcUri { get; set; } + public string WalletDirectory { get; set; } + } +} diff --git a/Plugins/Zano/Controllers/UIZanoStoreController.cs b/Plugins/Lethean/Controllers/UILetheanStoreController.cs similarity index 60% rename from Plugins/Zano/Controllers/UIZanoStoreController.cs rename to Plugins/Lethean/Controllers/UILetheanStoreController.cs index b2a74eb..f153677 100644 --- a/Plugins/Zano/Controllers/UIZanoStoreController.cs +++ b/Plugins/Lethean/Controllers/UILetheanStoreController.cs @@ -8,9 +8,9 @@ using BTCPayServer.Abstractions.Constants; using BTCPayServer.Client; using BTCPayServer.Data; using BTCPayServer.Payments; -using BTCPayServer.Plugins.Zano.Configuration; -using BTCPayServer.Plugins.Zano.Payments; -using BTCPayServer.Plugins.Zano.Services; +using BTCPayServer.Plugins.Lethean.Configuration; +using BTCPayServer.Plugins.Lethean.Payments; +using BTCPayServer.Plugins.Lethean.Services; using BTCPayServer.Services.Invoices; using BTCPayServer.Services.Stores; @@ -18,58 +18,58 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Localization; -namespace BTCPayServer.Plugins.Zano.Controllers +namespace BTCPayServer.Plugins.Lethean.Controllers { - [Route("stores/{storeId}/zano")] + [Route("stores/{storeId}/lethean")] [Authorize(AuthenticationSchemes = AuthenticationSchemes.Cookie)] [Authorize(Policy = Policies.CanModifyStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Cookie)] [Authorize(Policy = Policies.CanModifyServerSettings, AuthenticationSchemes = AuthenticationSchemes.Cookie)] - public class UIZanoStoreController : Controller + public class UILetheanStoreController : Controller { - private readonly ZanoConfiguration _zanoConfiguration; + private readonly LetheanConfiguration _letheanConfiguration; private readonly StoreRepository _storeRepository; - private readonly ZanoRpcProvider _zanoRpcProvider; + private readonly LetheanRpcProvider _letheanRpcProvider; private readonly PaymentMethodHandlerDictionary _handlers; private IStringLocalizer StringLocalizer { get; } - public UIZanoStoreController(ZanoConfiguration zanoConfiguration, - StoreRepository storeRepository, ZanoRpcProvider zanoRpcProvider, + public UILetheanStoreController(LetheanConfiguration letheanConfiguration, + StoreRepository storeRepository, LetheanRpcProvider letheanRpcProvider, PaymentMethodHandlerDictionary handlers, IStringLocalizer stringLocalizer) { - _zanoConfiguration = zanoConfiguration; + _letheanConfiguration = letheanConfiguration; _storeRepository = storeRepository; - _zanoRpcProvider = zanoRpcProvider; + _letheanRpcProvider = letheanRpcProvider; _handlers = handlers; StringLocalizer = stringLocalizer; } public StoreData StoreData => HttpContext.GetStoreData(); - private ZanoPaymentMethodViewModel GetZanoPaymentMethodViewModel( + private LetheanPaymentMethodViewModel GetLetheanPaymentMethodViewModel( StoreData storeData, string cryptoCode, IPaymentFilter excludeFilters) { - var zano = storeData.GetPaymentMethodConfigs(_handlers) - .Where(s => s.Value is ZanoPaymentPromptDetails) - .Select(s => (PaymentMethodId: s.Key, Details: (ZanoPaymentPromptDetails)s.Value)); + var lethean = storeData.GetPaymentMethodConfigs(_handlers) + .Where(s => s.Value is LetheanPaymentPromptDetails) + .Select(s => (PaymentMethodId: s.Key, Details: (LetheanPaymentPromptDetails)s.Value)); var pmi = PaymentTypes.CHAIN.GetPaymentMethodId(cryptoCode); - var settings = zano.Where(method => method.PaymentMethodId == pmi).Select(m => m.Details).SingleOrDefault(); - _zanoRpcProvider.Summaries.TryGetValue(cryptoCode, out var summary); + var settings = lethean.Where(method => method.PaymentMethodId == pmi).Select(m => m.Details).SingleOrDefault(); + _letheanRpcProvider.Summaries.TryGetValue(cryptoCode, out var summary); - var settlementThresholdChoice = ZanoSettlementThresholdChoice.StoreSpeedPolicy; + var settlementThresholdChoice = LetheanSettlementThresholdChoice.StoreSpeedPolicy; if (settings != null && settings.InvoiceSettledConfirmationThreshold is { } confirmations) { settlementThresholdChoice = confirmations switch { - 0 => ZanoSettlementThresholdChoice.ZeroConfirmation, - 1 => ZanoSettlementThresholdChoice.AtLeastOne, - 10 => ZanoSettlementThresholdChoice.AtLeastTen, - _ => ZanoSettlementThresholdChoice.Custom + 0 => LetheanSettlementThresholdChoice.ZeroConfirmation, + 1 => LetheanSettlementThresholdChoice.AtLeastOne, + 10 => LetheanSettlementThresholdChoice.AtLeastTen, + _ => LetheanSettlementThresholdChoice.Custom }; } - return new ZanoPaymentMethodViewModel() + return new LetheanPaymentMethodViewModel() { Enabled = settings != null && @@ -79,32 +79,32 @@ namespace BTCPayServer.Plugins.Zano.Controllers SettlementConfirmationThresholdChoice = settlementThresholdChoice, CustomSettlementConfirmationThreshold = settings != null && - settlementThresholdChoice is ZanoSettlementThresholdChoice.Custom + settlementThresholdChoice is LetheanSettlementThresholdChoice.Custom ? settings.InvoiceSettledConfirmationThreshold : null }; } [HttpGet("{cryptoCode}")] - public IActionResult GetStoreZanoPaymentMethod(string cryptoCode) + public IActionResult GetStoreLetheanPaymentMethod(string cryptoCode) { cryptoCode = cryptoCode.ToUpperInvariant(); - if (!_zanoConfiguration.ZanoConfigurationItems.ContainsKey(cryptoCode)) + if (!_letheanConfiguration.LetheanConfigurationItems.ContainsKey(cryptoCode)) { return NotFound(); } - var vm = GetZanoPaymentMethodViewModel(StoreData, cryptoCode, + var vm = GetLetheanPaymentMethodViewModel(StoreData, cryptoCode, StoreData.GetStoreBlob().GetExcludedPaymentMethods()); - return View("/Views/Zano/GetStoreZanoPaymentMethod.cshtml", vm); + return View("/Views/Lethean/GetStoreLetheanPaymentMethod.cshtml", vm); } [HttpPost("{cryptoCode}")] [DisableRequestSizeLimit] - public async Task GetStoreZanoPaymentMethod(ZanoPaymentMethodViewModel viewModel, string cryptoCode) + public async Task GetStoreLetheanPaymentMethod(LetheanPaymentMethodViewModel viewModel, string cryptoCode) { cryptoCode = cryptoCode.ToUpperInvariant(); - if (!_zanoConfiguration.ZanoConfigurationItems.TryGetValue(cryptoCode, + if (!_letheanConfiguration.LetheanConfigurationItems.TryGetValue(cryptoCode, out _)) { return NotFound(); @@ -112,24 +112,24 @@ namespace BTCPayServer.Plugins.Zano.Controllers if (!ModelState.IsValid) { - var vm = GetZanoPaymentMethodViewModel(StoreData, cryptoCode, + var vm = GetLetheanPaymentMethodViewModel(StoreData, cryptoCode, StoreData.GetStoreBlob().GetExcludedPaymentMethods()); vm.Enabled = viewModel.Enabled; vm.SettlementConfirmationThresholdChoice = viewModel.SettlementConfirmationThresholdChoice; vm.CustomSettlementConfirmationThreshold = viewModel.CustomSettlementConfirmationThreshold; - return View("/Views/Zano/GetStoreZanoPaymentMethod.cshtml", vm); + return View("/Views/Lethean/GetStoreLetheanPaymentMethod.cshtml", vm); } var storeData = StoreData; var blob = storeData.GetStoreBlob(); - storeData.SetPaymentMethodConfig(_handlers[PaymentTypes.CHAIN.GetPaymentMethodId(cryptoCode)], new ZanoPaymentPromptDetails() + storeData.SetPaymentMethodConfig(_handlers[PaymentTypes.CHAIN.GetPaymentMethodId(cryptoCode)], new LetheanPaymentPromptDetails() { InvoiceSettledConfirmationThreshold = viewModel.SettlementConfirmationThresholdChoice switch { - ZanoSettlementThresholdChoice.ZeroConfirmation => 0, - ZanoSettlementThresholdChoice.AtLeastOne => 1, - ZanoSettlementThresholdChoice.AtLeastTen => 10, - ZanoSettlementThresholdChoice.Custom when viewModel.CustomSettlementConfirmationThreshold is { } custom => custom, + LetheanSettlementThresholdChoice.ZeroConfirmation => 0, + LetheanSettlementThresholdChoice.AtLeastOne => 1, + LetheanSettlementThresholdChoice.AtLeastTen => 10, + LetheanSettlementThresholdChoice.Custom when viewModel.CustomSettlementConfirmationThreshold is { } custom => custom, _ => null } }); @@ -137,23 +137,23 @@ namespace BTCPayServer.Plugins.Zano.Controllers blob.SetExcluded(PaymentTypes.CHAIN.GetPaymentMethodId(viewModel.CryptoCode), !viewModel.Enabled); storeData.SetStoreBlob(blob); await _storeRepository.UpdateStore(storeData); - return RedirectToAction("GetStoreZanoPaymentMethod", new { cryptoCode }); + return RedirectToAction("GetStoreLetheanPaymentMethod", new { cryptoCode }); } - public class ZanoPaymentMethodViewModel : IValidatableObject + public class LetheanPaymentMethodViewModel : IValidatableObject { - public ZanoRpcProvider.ZanoSummary Summary { get; set; } + public LetheanRpcProvider.LetheanSummary Summary { get; set; } public string CryptoCode { get; set; } public bool Enabled { get; set; } [Display(Name = "Consider the invoice settled when the payment transaction ...")] - public ZanoSettlementThresholdChoice SettlementConfirmationThresholdChoice { get; set; } + public LetheanSettlementThresholdChoice SettlementConfirmationThresholdChoice { get; set; } [Display(Name = "Required Confirmations"), Range(0, 100)] public long? CustomSettlementConfirmationThreshold { get; set; } public IEnumerable Validate(ValidationContext validationContext) { - if (SettlementConfirmationThresholdChoice is ZanoSettlementThresholdChoice.Custom + if (SettlementConfirmationThresholdChoice is LetheanSettlementThresholdChoice.Custom && CustomSettlementConfirmationThreshold is null) { yield return new ValidationResult( @@ -163,7 +163,7 @@ namespace BTCPayServer.Plugins.Zano.Controllers } } - public enum ZanoSettlementThresholdChoice + public enum LetheanSettlementThresholdChoice { [Display(Name = "Store Speed Policy", Description = "Use the store's speed policy")] StoreSpeedPolicy, diff --git a/Plugins/Zano/ZanoPlugin.cs b/Plugins/Lethean/LetheanPlugin.cs similarity index 61% rename from Plugins/Zano/ZanoPlugin.cs rename to Plugins/Lethean/LetheanPlugin.cs index 7e60839..42af8ef 100644 --- a/Plugins/Zano/ZanoPlugin.cs +++ b/Plugins/Lethean/LetheanPlugin.cs @@ -7,9 +7,9 @@ using BTCPayServer.Abstractions.Models; using BTCPayServer.Configuration; using BTCPayServer.Hosting; using BTCPayServer.Payments; -using BTCPayServer.Plugins.Zano.Configuration; -using BTCPayServer.Plugins.Zano.Payments; -using BTCPayServer.Plugins.Zano.Services; +using BTCPayServer.Plugins.Lethean.Configuration; +using BTCPayServer.Plugins.Lethean.Payments; +using BTCPayServer.Plugins.Lethean.Services; using BTCPayServer.Services; using Microsoft.Extensions.Configuration; @@ -20,9 +20,9 @@ using NBitcoin; using NBXplorer; -namespace BTCPayServer.Plugins.Zano; +namespace BTCPayServer.Plugins.Lethean; -public class ZanoPlugin : BaseBTCPayServerPlugin +public class LetheanPlugin : BaseBTCPayServerPlugin { public override IBTCPayServerPlugin.PluginDependency[] Dependencies { get; } = { @@ -35,44 +35,44 @@ public class ZanoPlugin : BaseBTCPayServerPlugin var prov = pluginServices.BootstrapServices.GetRequiredService(); var chainName = prov.NetworkType; - var network = new ZanoSpecificBtcPayNetwork() + var network = new LetheanSpecificBtcPayNetwork() { - CryptoCode = "ZANO", - DisplayName = "Zano", + CryptoCode = "LTHN", + DisplayName = "Lethean", Divisibility = 12, DefaultRateRules = new[] { - "ZANO_X = ZANO_BTC * BTC_X", - "ZANO_BTC = coingecko(ZANO_BTC)" + "LTHN_X = LTHN_BTC * BTC_X", + "LTHN_BTC = coingecko(LTHN_BTC)" }, - CryptoImagePath = "zano.svg", - UriScheme = "zano" + CryptoImagePath = "lethean.svg", + UriScheme = "lethean" }; var blockExplorerLink = chainName == ChainName.Mainnet - ? "https://explorer.zano.org/transaction/{0}" - : "https://testnet-explorer.zano.org/transaction/{0}"; - var pmi = PaymentTypes.CHAIN.GetPaymentMethodId("ZANO"); + ? "https://explorer.lethean.org/transaction/{0}" + : "https://testnet-explorer.lethean.org/transaction/{0}"; + var pmi = PaymentTypes.CHAIN.GetPaymentMethodId("LTHN"); services.AddDefaultPrettyName(pmi, network.DisplayName); services.AddBTCPayNetwork(network) .AddTransactionLinkProvider(pmi, new SimpleTransactionLinkProvider(blockExplorerLink)); services.AddSingleton(provider => - ConfigureZanoConfiguration(provider)); - services.AddHttpClient("ZanoClient"); - services.AddSingleton(); - services.AddHostedService(); - services.AddHostedService(); - services.AddHostedService(); + ConfigureLetheanConfiguration(provider)); + services.AddHttpClient("LetheanClient"); + services.AddSingleton(); + services.AddHostedService(); + services.AddHostedService(); + services.AddHostedService(); services.AddSingleton(provider => - (IPaymentMethodHandler)ActivatorUtilities.CreateInstance(provider, typeof(ZanoPaymentMethodHandler), network)); + (IPaymentMethodHandler)ActivatorUtilities.CreateInstance(provider, typeof(LetheanPaymentMethodHandler), network)); services.AddSingleton(provider => -(IPaymentLinkExtension)ActivatorUtilities.CreateInstance(provider, typeof(ZanoPaymentLinkExtension), network, pmi)); +(IPaymentLinkExtension)ActivatorUtilities.CreateInstance(provider, typeof(LetheanPaymentLinkExtension), network, pmi)); services.AddSingleton(provider => -(ICheckoutModelExtension)ActivatorUtilities.CreateInstance(provider, typeof(ZanoCheckoutModelExtension), network, pmi)); +(ICheckoutModelExtension)ActivatorUtilities.CreateInstance(provider, typeof(LetheanCheckoutModelExtension), network, pmi)); - services.AddUIExtension("store-wallets-nav", "/Views/Zano/StoreWalletsNavZanoExtension.cshtml"); - services.AddUIExtension("store-invoices-payments", "/Views/Zano/ViewZanoPaymentData.cshtml"); - services.AddSingleton(); + services.AddUIExtension("store-wallets-nav", "/Views/Lethean/StoreWalletsNavLetheanExtension.cshtml"); + services.AddUIExtension("store-invoices-payments", "/Views/Lethean/ViewLetheanPaymentData.cshtml"); + services.AddSingleton(); } class SimpleTransactionLinkProvider : DefaultTransactionLinkProvider { @@ -90,30 +90,30 @@ public class ZanoPlugin : BaseBTCPayServerPlugin } } - private static ZanoConfiguration ConfigureZanoConfiguration(IServiceProvider serviceProvider) + private static LetheanConfiguration ConfigureLetheanConfiguration(IServiceProvider serviceProvider) { var configuration = serviceProvider.GetService(); var btcPayNetworkProvider = serviceProvider.GetService(); - var result = new ZanoConfiguration(); + var result = new LetheanConfiguration(); var supportedNetworks = btcPayNetworkProvider.GetAll() - .OfType(); + .OfType(); - foreach (var zanoNetwork in supportedNetworks) + foreach (var letheanNetwork in supportedNetworks) { var daemonUri = - configuration.GetOrDefault($"{zanoNetwork.CryptoCode}_daemon_uri", + configuration.GetOrDefault($"{letheanNetwork.CryptoCode}_daemon_uri", null); var walletDaemonUri = configuration.GetOrDefault( - $"{zanoNetwork.CryptoCode}_wallet_daemon_uri", null); + $"{letheanNetwork.CryptoCode}_wallet_daemon_uri", null); var walletDaemonWalletDirectory = configuration.GetOrDefault( - $"{zanoNetwork.CryptoCode}_wallet_daemon_walletdir", null); + $"{letheanNetwork.CryptoCode}_wallet_daemon_walletdir", null); if (daemonUri == null || walletDaemonUri == null) { - var logger = serviceProvider.GetRequiredService>(); - var cryptoCode = zanoNetwork.CryptoCode.ToUpperInvariant(); + var logger = serviceProvider.GetRequiredService>(); + var cryptoCode = letheanNetwork.CryptoCode.ToUpperInvariant(); if (daemonUri is null) { logger.LogWarning("BTCPAY_{CryptoCode}_DAEMON_URI is not configured", cryptoCode); @@ -126,7 +126,7 @@ public class ZanoPlugin : BaseBTCPayServerPlugin } else { - result.ZanoConfigurationItems.Add(zanoNetwork.CryptoCode, new ZanoConfigurationItem + result.LetheanConfigurationItems.Add(letheanNetwork.CryptoCode, new LetheanConfigurationItem { DaemonRpcUri = daemonUri, InternalWalletRpcUri = walletDaemonUri, diff --git a/Plugins/Lethean/LetheanSpecificBtcPayNetwork.cs b/Plugins/Lethean/LetheanSpecificBtcPayNetwork.cs new file mode 100644 index 0000000..2d3037e --- /dev/null +++ b/Plugins/Lethean/LetheanSpecificBtcPayNetwork.cs @@ -0,0 +1,7 @@ +namespace BTCPayServer.Plugins.Lethean; + +public class LetheanSpecificBtcPayNetwork : BTCPayNetworkBase +{ + public int MaxTrackedConfirmation = 10; + public string UriScheme { get; set; } +} \ No newline at end of file diff --git a/Plugins/Zano/Payments/ZanoCheckoutModelExtension.cs b/Plugins/Lethean/Payments/LetheanCheckoutModelExtension.cs similarity index 77% rename from Plugins/Zano/Payments/ZanoCheckoutModelExtension.cs rename to Plugins/Lethean/Payments/LetheanCheckoutModelExtension.cs index fe0f9cf..1f06c8f 100644 --- a/Plugins/Zano/Payments/ZanoCheckoutModelExtension.cs +++ b/Plugins/Lethean/Payments/LetheanCheckoutModelExtension.cs @@ -3,18 +3,18 @@ using System.Linq; using BTCPayServer.Payments; using BTCPayServer.Payments.Bitcoin; -using BTCPayServer.Plugins.Zano.Services; +using BTCPayServer.Plugins.Lethean.Services; using BTCPayServer.Services.Invoices; -namespace BTCPayServer.Plugins.Zano.Payments +namespace BTCPayServer.Plugins.Lethean.Payments { - public class ZanoCheckoutModelExtension : ICheckoutModelExtension + public class LetheanCheckoutModelExtension : ICheckoutModelExtension { private readonly BTCPayNetworkBase _network; private readonly PaymentMethodHandlerDictionary _handlers; private readonly IPaymentLinkExtension paymentLinkExtension; - public ZanoCheckoutModelExtension( + public LetheanCheckoutModelExtension( PaymentMethodId paymentMethodId, IEnumerable paymentLinkExtensions, BTCPayNetworkBase network, @@ -32,19 +32,19 @@ namespace BTCPayServer.Plugins.Zano.Payments public void ModifyCheckoutModel(CheckoutModelContext context) { - if (context is not { Handler: ZanoPaymentMethodHandler handler }) + if (context is not { Handler: LetheanPaymentMethodHandler handler }) { return; } context.Model.CheckoutBodyComponentName = BitcoinCheckoutModelExtension.CheckoutBodyComponentName; var details = context.InvoiceEntity.GetPayments(true) - .Select(p => p.GetDetails(handler)) + .Select(p => p.GetDetails(handler)) .Where(p => p is not null) .FirstOrDefault(); if (details is not null) { context.Model.ReceivedConfirmations = details.ConfirmationCount; - context.Model.RequiredConfirmations = (int)ZanoListener.ConfirmationsRequired(details, context.InvoiceEntity.SpeedPolicy); + context.Model.RequiredConfirmations = (int)LetheanListener.ConfirmationsRequired(details, context.InvoiceEntity.SpeedPolicy); } context.Model.InvoiceBitcoinUrl = paymentLinkExtension.GetPaymentLink(context.Prompt, context.UrlHelper); diff --git a/Plugins/Zano/Payments/ZanoOnChainPaymentMethodDetails.cs b/Plugins/Lethean/Payments/LetheanOnChainPaymentMethodDetails.cs similarity index 57% rename from Plugins/Zano/Payments/ZanoOnChainPaymentMethodDetails.cs rename to Plugins/Lethean/Payments/LetheanOnChainPaymentMethodDetails.cs index c2e86fa..0411b27 100644 --- a/Plugins/Zano/Payments/ZanoOnChainPaymentMethodDetails.cs +++ b/Plugins/Lethean/Payments/LetheanOnChainPaymentMethodDetails.cs @@ -1,6 +1,6 @@ -namespace BTCPayServer.Plugins.Zano.Payments +namespace BTCPayServer.Plugins.Lethean.Payments { - public class ZanoOnChainPaymentMethodDetails + public class LetheanOnChainPaymentMethodDetails { public string PaymentId { get; set; } public long? InvoiceSettledConfirmationThreshold { get; set; } diff --git a/Plugins/Zano/Payments/ZanoPaymentData.cs b/Plugins/Lethean/Payments/LetheanPaymentData.cs similarity index 79% rename from Plugins/Zano/Payments/ZanoPaymentData.cs rename to Plugins/Lethean/Payments/LetheanPaymentData.cs index aff48f9..d1440ef 100644 --- a/Plugins/Zano/Payments/ZanoPaymentData.cs +++ b/Plugins/Lethean/Payments/LetheanPaymentData.cs @@ -1,6 +1,6 @@ -namespace BTCPayServer.Plugins.Zano.Payments +namespace BTCPayServer.Plugins.Lethean.Payments { - public class ZanoPaymentData + public class LetheanPaymentData { public string PaymentId { get; set; } public long BlockHeight { get; set; } diff --git a/Plugins/Zano/Payments/ZanoPaymentLinkExtension.cs b/Plugins/Lethean/Payments/LetheanPaymentLinkExtension.cs similarity index 66% rename from Plugins/Zano/Payments/ZanoPaymentLinkExtension.cs rename to Plugins/Lethean/Payments/LetheanPaymentLinkExtension.cs index 3cabee6..fb88b3e 100644 --- a/Plugins/Zano/Payments/ZanoPaymentLinkExtension.cs +++ b/Plugins/Lethean/Payments/LetheanPaymentLinkExtension.cs @@ -6,13 +6,13 @@ using BTCPayServer.Services.Invoices; using Microsoft.AspNetCore.Mvc; -namespace BTCPayServer.Plugins.Zano.Payments +namespace BTCPayServer.Plugins.Lethean.Payments { - public class ZanoPaymentLinkExtension : IPaymentLinkExtension + public class LetheanPaymentLinkExtension : IPaymentLinkExtension { - private readonly ZanoSpecificBtcPayNetwork _network; + private readonly LetheanSpecificBtcPayNetwork _network; - public ZanoPaymentLinkExtension(PaymentMethodId paymentMethodId, ZanoSpecificBtcPayNetwork network) + public LetheanPaymentLinkExtension(PaymentMethodId paymentMethodId, LetheanSpecificBtcPayNetwork network) { PaymentMethodId = paymentMethodId; _network = network; diff --git a/Plugins/Zano/Payments/ZanoPaymentMethodHandler.cs b/Plugins/Lethean/Payments/LetheanPaymentMethodHandler.cs similarity index 60% rename from Plugins/Zano/Payments/ZanoPaymentMethodHandler.cs rename to Plugins/Lethean/Payments/LetheanPaymentMethodHandler.cs index 6053030..5521f3f 100644 --- a/Plugins/Zano/Payments/ZanoPaymentMethodHandler.cs +++ b/Plugins/Lethean/Payments/LetheanPaymentMethodHandler.cs @@ -4,36 +4,36 @@ using System.Threading.Tasks; using BTCPayServer.Data; using BTCPayServer.Payments; -using BTCPayServer.Plugins.Zano.RPC.Models; -using BTCPayServer.Plugins.Zano.Services; -using BTCPayServer.Plugins.Zano.Utils; +using BTCPayServer.Plugins.Lethean.RPC.Models; +using BTCPayServer.Plugins.Lethean.Services; +using BTCPayServer.Plugins.Lethean.Utils; using Newtonsoft.Json; using Newtonsoft.Json.Linq; -namespace BTCPayServer.Plugins.Zano.Payments +namespace BTCPayServer.Plugins.Lethean.Payments { - public class ZanoPaymentMethodHandler : IPaymentMethodHandler + public class LetheanPaymentMethodHandler : IPaymentMethodHandler { - private readonly ZanoSpecificBtcPayNetwork _network; - public ZanoSpecificBtcPayNetwork Network => _network; + private readonly LetheanSpecificBtcPayNetwork _network; + public LetheanSpecificBtcPayNetwork Network => _network; public JsonSerializer Serializer { get; } - private readonly ZanoRpcProvider _zanoRpcProvider; + private readonly LetheanRpcProvider _letheanRpcProvider; public PaymentMethodId PaymentMethodId { get; } - // Fixed fee: 0.01 ZANO in atomic units (12 decimals) + // Fixed fee: 0.01 LTHN in atomic units (12 decimals) private const long FixedFeeAtomicUnits = 10_000_000_000; - public ZanoPaymentMethodHandler(ZanoSpecificBtcPayNetwork network, ZanoRpcProvider zanoRpcProvider) + public LetheanPaymentMethodHandler(LetheanSpecificBtcPayNetwork network, LetheanRpcProvider letheanRpcProvider) { PaymentMethodId = PaymentTypes.CHAIN.GetPaymentMethodId(network.CryptoCode); _network = network; Serializer = BlobSerializer.CreateSerializer().Serializer; - _zanoRpcProvider = zanoRpcProvider; + _letheanRpcProvider = letheanRpcProvider; } - bool IsReady() => _zanoRpcProvider.IsConfigured(_network.CryptoCode) && _zanoRpcProvider.IsAvailable(_network.CryptoCode); + bool IsReady() => _letheanRpcProvider.IsConfigured(_network.CryptoCode) && _letheanRpcProvider.IsAvailable(_network.CryptoCode); public Task BeforeFetchingRates(PaymentMethodContext context) { @@ -44,7 +44,7 @@ namespace BTCPayServer.Plugins.Zano.Payments try { var paymentId = GeneratePaymentId(); - var walletClient = _zanoRpcProvider.WalletRpcClients[_network.CryptoCode]; + var walletClient = _letheanRpcProvider.WalletRpcClients[_network.CryptoCode]; context.State = new Prepare() { ReserveAddress = walletClient.SendCommandAsync( @@ -63,32 +63,32 @@ namespace BTCPayServer.Plugins.Zano.Payments public async Task ConfigurePrompt(PaymentMethodContext context) { - if (!_zanoRpcProvider.IsConfigured(_network.CryptoCode)) + if (!_letheanRpcProvider.IsConfigured(_network.CryptoCode)) { - throw new PaymentMethodUnavailableException("BTCPAY_ZANO_WALLET_DAEMON_URI or BTCPAY_ZANO_DAEMON_URI isn't configured"); + throw new PaymentMethodUnavailableException("BTCPAY_LTHN_WALLET_DAEMON_URI or BTCPAY_LTHN_DAEMON_URI isn't configured"); } - if (!_zanoRpcProvider.IsAvailable(_network.CryptoCode) || context.State is not Prepare zanoPrepare) + if (!_letheanRpcProvider.IsAvailable(_network.CryptoCode) || context.State is not Prepare letheanPrepare) { throw new PaymentMethodUnavailableException("Node or wallet not available"); } - var address = await zanoPrepare.ReserveAddress; + var address = await letheanPrepare.ReserveAddress; - var details = new ZanoOnChainPaymentMethodDetails() + var details = new LetheanOnChainPaymentMethodDetails() { - PaymentId = zanoPrepare.PaymentId, + PaymentId = letheanPrepare.PaymentId, InvoiceSettledConfirmationThreshold = ParsePaymentMethodConfig(context.PaymentMethodConfig).InvoiceSettledConfirmationThreshold }; context.Prompt.Destination = address.IntegratedAddress; - context.Prompt.PaymentMethodFee = ZanoMoney.Convert(FixedFeeAtomicUnits); + context.Prompt.PaymentMethodFee = LetheanMoney.Convert(FixedFeeAtomicUnits); context.Prompt.Details = JObject.FromObject(details, Serializer); context.TrackedDestinations.Add(address.IntegratedAddress); } - private ZanoPaymentPromptDetails ParsePaymentMethodConfig(JToken config) + private LetheanPaymentPromptDetails ParsePaymentMethodConfig(JToken config) { - return config.ToObject(Serializer) ?? throw new FormatException($"Invalid {nameof(ZanoPaymentMethodHandler)}"); + return config.ToObject(Serializer) ?? throw new FormatException($"Invalid {nameof(LetheanPaymentMethodHandler)}"); } object IPaymentMethodHandler.ParsePaymentMethodConfig(JToken config) { @@ -101,18 +101,18 @@ namespace BTCPayServer.Plugins.Zano.Payments public string PaymentId; } - public ZanoOnChainPaymentMethodDetails ParsePaymentPromptDetails(JToken details) + public LetheanOnChainPaymentMethodDetails ParsePaymentPromptDetails(JToken details) { - return details.ToObject(Serializer); + return details.ToObject(Serializer); } object IPaymentMethodHandler.ParsePaymentPromptDetails(JToken details) { return ParsePaymentPromptDetails(details); } - public ZanoPaymentData ParsePaymentDetails(JToken details) + public LetheanPaymentData ParsePaymentDetails(JToken details) { - return details.ToObject(Serializer) ?? throw new FormatException($"Invalid {nameof(ZanoPaymentMethodHandler)}"); + return details.ToObject(Serializer) ?? throw new FormatException($"Invalid {nameof(LetheanPaymentMethodHandler)}"); } object IPaymentMethodHandler.ParsePaymentDetails(JToken details) { diff --git a/Plugins/Lethean/Payments/LetheanPaymentPromptDetails.cs b/Plugins/Lethean/Payments/LetheanPaymentPromptDetails.cs new file mode 100644 index 0000000..69b706d --- /dev/null +++ b/Plugins/Lethean/Payments/LetheanPaymentPromptDetails.cs @@ -0,0 +1,7 @@ +namespace BTCPayServer.Plugins.Lethean.Payments +{ + public class LetheanPaymentPromptDetails + { + public long? InvoiceSettledConfirmationThreshold { get; set; } + } +} diff --git a/Plugins/Zano/RPC/JsonRpcClient.cs b/Plugins/Lethean/RPC/JsonRpcClient.cs similarity index 98% rename from Plugins/Zano/RPC/JsonRpcClient.cs rename to Plugins/Lethean/RPC/JsonRpcClient.cs index 2d1de83..15ce74f 100644 --- a/Plugins/Zano/RPC/JsonRpcClient.cs +++ b/Plugins/Lethean/RPC/JsonRpcClient.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; using Newtonsoft.Json; using Newtonsoft.Json.Serialization; -namespace BTCPayServer.Plugins.Zano.RPC +namespace BTCPayServer.Plugins.Lethean.RPC { public class JsonRpcClient { diff --git a/Plugins/Lethean/RPC/LetheanEvent.cs b/Plugins/Lethean/RPC/LetheanEvent.cs new file mode 100644 index 0000000..7e358d6 --- /dev/null +++ b/Plugins/Lethean/RPC/LetheanEvent.cs @@ -0,0 +1,7 @@ +namespace BTCPayServer.Plugins.Lethean.RPC +{ + public class LetheanPollEvent + { + public string CryptoCode { get; set; } + } +} diff --git a/Plugins/Zano/RPC/Models/ErrorResponse.cs b/Plugins/Lethean/RPC/Models/ErrorResponse.cs similarity index 80% rename from Plugins/Zano/RPC/Models/ErrorResponse.cs rename to Plugins/Lethean/RPC/Models/ErrorResponse.cs index 53f66c8..9a80126 100644 --- a/Plugins/Zano/RPC/Models/ErrorResponse.cs +++ b/Plugins/Lethean/RPC/Models/ErrorResponse.cs @@ -1,6 +1,6 @@ using Newtonsoft.Json; -namespace BTCPayServer.Plugins.Zano.RPC.Models +namespace BTCPayServer.Plugins.Lethean.RPC.Models { public class ErrorResponse { diff --git a/Plugins/Zano/RPC/Models/GetBalanceResponse.cs b/Plugins/Lethean/RPC/Models/GetBalanceResponse.cs similarity index 73% rename from Plugins/Zano/RPC/Models/GetBalanceResponse.cs rename to Plugins/Lethean/RPC/Models/GetBalanceResponse.cs index 03423cf..853fbad 100644 --- a/Plugins/Zano/RPC/Models/GetBalanceResponse.cs +++ b/Plugins/Lethean/RPC/Models/GetBalanceResponse.cs @@ -1,6 +1,6 @@ using Newtonsoft.Json; -namespace BTCPayServer.Plugins.Zano.RPC.Models; +namespace BTCPayServer.Plugins.Lethean.RPC.Models; public class GetBalanceResponse { diff --git a/Plugins/Zano/RPC/Models/GetBulkPaymentsRequest.cs b/Plugins/Lethean/RPC/Models/GetBulkPaymentsRequest.cs similarity index 88% rename from Plugins/Zano/RPC/Models/GetBulkPaymentsRequest.cs rename to Plugins/Lethean/RPC/Models/GetBulkPaymentsRequest.cs index 524f808..648fe27 100644 --- a/Plugins/Zano/RPC/Models/GetBulkPaymentsRequest.cs +++ b/Plugins/Lethean/RPC/Models/GetBulkPaymentsRequest.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using Newtonsoft.Json; -namespace BTCPayServer.Plugins.Zano.RPC.Models +namespace BTCPayServer.Plugins.Lethean.RPC.Models { public class GetBulkPaymentsRequest { diff --git a/Plugins/Zano/RPC/Models/GetBulkPaymentsResponse.cs b/Plugins/Lethean/RPC/Models/GetBulkPaymentsResponse.cs similarity index 92% rename from Plugins/Zano/RPC/Models/GetBulkPaymentsResponse.cs rename to Plugins/Lethean/RPC/Models/GetBulkPaymentsResponse.cs index 950f54f..5b01a24 100644 --- a/Plugins/Zano/RPC/Models/GetBulkPaymentsResponse.cs +++ b/Plugins/Lethean/RPC/Models/GetBulkPaymentsResponse.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using Newtonsoft.Json; -namespace BTCPayServer.Plugins.Zano.RPC.Models +namespace BTCPayServer.Plugins.Lethean.RPC.Models { public class GetBulkPaymentsResponse { diff --git a/Plugins/Zano/RPC/Models/GetInfoResponse.cs b/Plugins/Lethean/RPC/Models/GetInfoResponse.cs similarity index 92% rename from Plugins/Zano/RPC/Models/GetInfoResponse.cs rename to Plugins/Lethean/RPC/Models/GetInfoResponse.cs index 4960ef3..8c5baaf 100644 --- a/Plugins/Zano/RPC/Models/GetInfoResponse.cs +++ b/Plugins/Lethean/RPC/Models/GetInfoResponse.cs @@ -1,6 +1,6 @@ using Newtonsoft.Json; -namespace BTCPayServer.Plugins.Zano.RPC.Models +namespace BTCPayServer.Plugins.Lethean.RPC.Models { public class GetInfoResponse { diff --git a/Plugins/Zano/RPC/Models/GetWalletInfoResponse.cs b/Plugins/Lethean/RPC/Models/GetWalletInfoResponse.cs similarity index 88% rename from Plugins/Zano/RPC/Models/GetWalletInfoResponse.cs rename to Plugins/Lethean/RPC/Models/GetWalletInfoResponse.cs index 76a4035..5fdfbd9 100644 --- a/Plugins/Zano/RPC/Models/GetWalletInfoResponse.cs +++ b/Plugins/Lethean/RPC/Models/GetWalletInfoResponse.cs @@ -1,6 +1,6 @@ using Newtonsoft.Json; -namespace BTCPayServer.Plugins.Zano.RPC.Models +namespace BTCPayServer.Plugins.Lethean.RPC.Models { public class GetWalletInfoResponse { diff --git a/Plugins/Zano/RPC/Models/MakeIntegratedAddressRequest.cs b/Plugins/Lethean/RPC/Models/MakeIntegratedAddressRequest.cs similarity index 76% rename from Plugins/Zano/RPC/Models/MakeIntegratedAddressRequest.cs rename to Plugins/Lethean/RPC/Models/MakeIntegratedAddressRequest.cs index 1586684..e6e1d84 100644 --- a/Plugins/Zano/RPC/Models/MakeIntegratedAddressRequest.cs +++ b/Plugins/Lethean/RPC/Models/MakeIntegratedAddressRequest.cs @@ -1,6 +1,6 @@ using Newtonsoft.Json; -namespace BTCPayServer.Plugins.Zano.RPC.Models +namespace BTCPayServer.Plugins.Lethean.RPC.Models { public class MakeIntegratedAddressRequest { diff --git a/Plugins/Zano/RPC/Models/MakeIntegratedAddressResponse.cs b/Plugins/Lethean/RPC/Models/MakeIntegratedAddressResponse.cs similarity index 83% rename from Plugins/Zano/RPC/Models/MakeIntegratedAddressResponse.cs rename to Plugins/Lethean/RPC/Models/MakeIntegratedAddressResponse.cs index c3fa498..009db49 100644 --- a/Plugins/Zano/RPC/Models/MakeIntegratedAddressResponse.cs +++ b/Plugins/Lethean/RPC/Models/MakeIntegratedAddressResponse.cs @@ -1,6 +1,6 @@ using Newtonsoft.Json; -namespace BTCPayServer.Plugins.Zano.RPC.Models +namespace BTCPayServer.Plugins.Lethean.RPC.Models { public class MakeIntegratedAddressResponse { diff --git a/Plugins/Zano/RPC/Models/OpenWalletRequest.cs b/Plugins/Lethean/RPC/Models/OpenWalletRequest.cs similarity index 81% rename from Plugins/Zano/RPC/Models/OpenWalletRequest.cs rename to Plugins/Lethean/RPC/Models/OpenWalletRequest.cs index aca0c94..bdd1afd 100644 --- a/Plugins/Zano/RPC/Models/OpenWalletRequest.cs +++ b/Plugins/Lethean/RPC/Models/OpenWalletRequest.cs @@ -1,6 +1,6 @@ using Newtonsoft.Json; -namespace BTCPayServer.Plugins.Zano.RPC.Models +namespace BTCPayServer.Plugins.Lethean.RPC.Models { public class OpenWalletRequest { diff --git a/Plugins/Zano/RPC/Models/OpenWalletResponse.cs b/Plugins/Lethean/RPC/Models/OpenWalletResponse.cs similarity index 87% rename from Plugins/Zano/RPC/Models/OpenWalletResponse.cs rename to Plugins/Lethean/RPC/Models/OpenWalletResponse.cs index ef54b01..138d81b 100644 --- a/Plugins/Zano/RPC/Models/OpenWalletResponse.cs +++ b/Plugins/Lethean/RPC/Models/OpenWalletResponse.cs @@ -1,6 +1,6 @@ using Newtonsoft.Json; -namespace BTCPayServer.Plugins.Zano.RPC.Models +namespace BTCPayServer.Plugins.Lethean.RPC.Models { public class OpenWalletResponse { diff --git a/Plugins/Zano/RPC/Models/ParseStringConverter.cs b/Plugins/Lethean/RPC/Models/ParseStringConverter.cs similarity index 96% rename from Plugins/Zano/RPC/Models/ParseStringConverter.cs rename to Plugins/Lethean/RPC/Models/ParseStringConverter.cs index 223ced3..c562804 100644 --- a/Plugins/Zano/RPC/Models/ParseStringConverter.cs +++ b/Plugins/Lethean/RPC/Models/ParseStringConverter.cs @@ -3,7 +3,7 @@ using System.Globalization; using Newtonsoft.Json; -namespace BTCPayServer.Plugins.Zano.RPC.Models +namespace BTCPayServer.Plugins.Lethean.RPC.Models { public class ParseStringConverter : JsonConverter { diff --git a/Plugins/Zano/Services/ZanoListener.cs b/Plugins/Lethean/Services/LetheanListener.cs similarity index 82% rename from Plugins/Zano/Services/ZanoListener.cs rename to Plugins/Lethean/Services/LetheanListener.cs index e2fa45e..812bd7b 100644 --- a/Plugins/Zano/Services/ZanoListener.cs +++ b/Plugins/Lethean/Services/LetheanListener.cs @@ -9,11 +9,11 @@ using BTCPayServer.Data; using BTCPayServer.Events; using BTCPayServer.HostedServices; using BTCPayServer.Payments; -using BTCPayServer.Plugins.Zano.Configuration; -using BTCPayServer.Plugins.Zano.Payments; -using BTCPayServer.Plugins.Zano.RPC; -using BTCPayServer.Plugins.Zano.RPC.Models; -using BTCPayServer.Plugins.Zano.Utils; +using BTCPayServer.Plugins.Lethean.Configuration; +using BTCPayServer.Plugins.Lethean.Payments; +using BTCPayServer.Plugins.Lethean.RPC; +using BTCPayServer.Plugins.Lethean.RPC.Models; +using BTCPayServer.Plugins.Lethean.Utils; using BTCPayServer.Services; using BTCPayServer.Services.Invoices; @@ -21,34 +21,34 @@ using Microsoft.Extensions.Logging; using Newtonsoft.Json.Linq; -namespace BTCPayServer.Plugins.Zano.Services +namespace BTCPayServer.Plugins.Lethean.Services { - public class ZanoListener : EventHostedServiceBase + public class LetheanListener : EventHostedServiceBase { private readonly InvoiceRepository _invoiceRepository; private readonly EventAggregator _eventAggregator; - private readonly ZanoRpcProvider _zanoRpcProvider; - private readonly ZanoConfiguration _zanoConfiguration; + private readonly LetheanRpcProvider _letheanRpcProvider; + private readonly LetheanConfiguration _letheanConfiguration; private readonly BTCPayNetworkProvider _networkProvider; - private readonly ILogger _logger; + private readonly ILogger _logger; private readonly PaymentMethodHandlerDictionary _handlers; private readonly InvoiceActivator _invoiceActivator; private readonly PaymentService _paymentService; - public ZanoListener(InvoiceRepository invoiceRepository, + public LetheanListener(InvoiceRepository invoiceRepository, EventAggregator eventAggregator, - ZanoRpcProvider zanoRpcProvider, - ZanoConfiguration zanoConfiguration, + LetheanRpcProvider letheanRpcProvider, + LetheanConfiguration letheanConfiguration, BTCPayNetworkProvider networkProvider, - ILogger logger, + ILogger logger, PaymentMethodHandlerDictionary handlers, InvoiceActivator invoiceActivator, PaymentService paymentService) : base(eventAggregator, logger) { _invoiceRepository = invoiceRepository; _eventAggregator = eventAggregator; - _zanoRpcProvider = zanoRpcProvider; - _zanoConfiguration = zanoConfiguration; + _letheanRpcProvider = letheanRpcProvider; + _letheanConfiguration = letheanConfiguration; _networkProvider = networkProvider; _logger = logger; _handlers = handlers; @@ -59,29 +59,29 @@ namespace BTCPayServer.Plugins.Zano.Services protected override void SubscribeToEvents() { base.SubscribeToEvents(); - Subscribe(); - Subscribe(); + Subscribe(); + Subscribe(); } protected override async Task ProcessEvent(object evt, CancellationToken cancellationToken) { - if (evt is ZanoRpcProvider.ZanoDaemonStateChange stateChange) + if (evt is LetheanRpcProvider.LetheanDaemonStateChange stateChange) { - if (_zanoRpcProvider.IsAvailable(stateChange.CryptoCode)) + if (_letheanRpcProvider.IsAvailable(stateChange.CryptoCode)) { _logger.LogInformation("{CryptoCode} just became available", stateChange.CryptoCode); - _ = UpdateAnyPendingZanoPayment(stateChange.CryptoCode); + _ = UpdateAnyPendingLetheanPayment(stateChange.CryptoCode); } else { _logger.LogInformation("{CryptoCode} just became unavailable", stateChange.CryptoCode); } } - else if (evt is ZanoPollEvent pollEvent) + else if (evt is LetheanPollEvent pollEvent) { - if (_zanoRpcProvider.IsAvailable(pollEvent.CryptoCode)) + if (_letheanRpcProvider.IsAvailable(pollEvent.CryptoCode)) { - await UpdateAnyPendingZanoPayment(pollEvent.CryptoCode); + await UpdateAnyPendingLetheanPayment(pollEvent.CryptoCode); } } } @@ -114,14 +114,14 @@ namespace BTCPayServer.Plugins.Zano.Services return; } - var walletRpcClient = _zanoRpcProvider.WalletRpcClients[cryptoCode]; + var walletRpcClient = _letheanRpcProvider.WalletRpcClients[cryptoCode]; var network = _networkProvider.GetNetwork(cryptoCode); var paymentMethodId = PaymentTypes.CHAIN.GetPaymentMethodId(network.CryptoCode); - var handler = (ZanoPaymentMethodHandler)_handlers[paymentMethodId]; + var handler = (LetheanPaymentMethodHandler)_handlers[paymentMethodId]; // Get current daemon height for confirmation calculation long currentHeight = 0; - if (_zanoRpcProvider.Summaries.TryGetValue(cryptoCode, out var summary)) + if (_letheanRpcProvider.Summaries.TryGetValue(cryptoCode, out var summary)) { currentHeight = summary.CurrentHeight; } @@ -129,7 +129,7 @@ namespace BTCPayServer.Plugins.Zano.Services // Collect all payment_ids from pending invoices var expandedInvoices = invoices.Select(entity => ( Invoice: entity, - ExistingPayments: GetAllZanoPayments(entity, cryptoCode), + ExistingPayments: GetAllLetheanPayments(entity, cryptoCode), Prompt: entity.GetPaymentPrompt(paymentMethodId), PaymentMethodDetails: handler.ParsePaymentPromptDetails(entity.GetPaymentPrompt(paymentMethodId).Details))) .ToList(); @@ -174,7 +174,7 @@ namespace BTCPayServer.Plugins.Zano.Services var updatedPaymentEntities = new List<(PaymentEntity Payment, InvoiceEntity invoice)>(); var processingTasks = new List(); - // Deduplicate: Zano returns both confirmed (block_height>0) and mempool (block_height=0) + // Deduplicate: Lethean returns both confirmed (block_height>0) and mempool (block_height=0) // entries for the same tx. Keep the confirmed entry when available. var dedupedPayments = result.Payments .GroupBy(p => $"{p.TxHash}#{p.PaymentId}") @@ -222,7 +222,7 @@ namespace BTCPayServer.Plugins.Zano.Services } private async Task UpdateExistingPaymentConfirmations(string cryptoCode, InvoiceEntity[] invoices, - ZanoPaymentMethodHandler handler, long currentHeight) + LetheanPaymentMethodHandler handler, long currentHeight) { if (currentHeight <= 0) { @@ -233,7 +233,7 @@ namespace BTCPayServer.Plugins.Zano.Services foreach (var invoice in invoices) { - var existingPayments = GetAllZanoPayments(invoice, cryptoCode); + var existingPayments = GetAllLetheanPayments(invoice, cryptoCode); foreach (var payment in existingPayments) { var data = handler.ParsePaymentDetails(payment.Details); @@ -268,9 +268,9 @@ namespace BTCPayServer.Plugins.Zano.Services { var network = _networkProvider.GetNetwork(cryptoCode); var pmi = PaymentTypes.CHAIN.GetPaymentMethodId(network.CryptoCode); - var handler = (ZanoPaymentMethodHandler)_handlers[pmi]; + var handler = (LetheanPaymentMethodHandler)_handlers[pmi]; var promptDetails = handler.ParsePaymentPromptDetails(invoice.GetPaymentPrompt(pmi).Details); - var details = new ZanoPaymentData() + var details = new LetheanPaymentData() { PaymentId = paymentId, TransactionId = txId, @@ -283,7 +283,7 @@ namespace BTCPayServer.Plugins.Zano.Services var paymentData = new PaymentData() { Status = status, - Amount = ZanoMoney.Convert(totalAmount), + Amount = LetheanMoney.Convert(totalAmount), Created = DateTimeOffset.UtcNow, Id = $"{txId}#{paymentId}", Currency = network.CryptoCode, @@ -291,7 +291,7 @@ namespace BTCPayServer.Plugins.Zano.Services }.Set(invoice, handler, details); // Check if this tx exists as a payment to this invoice already - var alreadyExistingPayment = GetAllZanoPayments(invoice, cryptoCode) + var alreadyExistingPayment = GetAllLetheanPayments(invoice, cryptoCode) .SingleOrDefault(c => c.Id == paymentData.Id && c.PaymentMethodId == pmi); if (alreadyExistingPayment == null) @@ -311,10 +311,10 @@ namespace BTCPayServer.Plugins.Zano.Services } } - private bool GetStatus(ZanoPaymentData details, SpeedPolicy speedPolicy) + private bool GetStatus(LetheanPaymentData details, SpeedPolicy speedPolicy) => ConfirmationsRequired(details, speedPolicy) <= details.ConfirmationCount; - public static long ConfirmationsRequired(ZanoPaymentData details, SpeedPolicy speedPolicy) + public static long ConfirmationsRequired(LetheanPaymentData details, SpeedPolicy speedPolicy) => (details, speedPolicy) switch { (_, _) when details.ConfirmationCount < details.LockTime => @@ -327,7 +327,7 @@ namespace BTCPayServer.Plugins.Zano.Services _ => 6, }; - private async Task UpdateAnyPendingZanoPayment(string cryptoCode) + private async Task UpdateAnyPendingLetheanPayment(string cryptoCode) { var paymentMethodId = PaymentTypes.CHAIN.GetPaymentMethodId(cryptoCode); var invoices = await _invoiceRepository.GetMonitoredInvoices(paymentMethodId); @@ -339,7 +339,7 @@ namespace BTCPayServer.Plugins.Zano.Services await UpdatePaymentStates(cryptoCode, invoices); } - private IEnumerable GetAllZanoPayments(InvoiceEntity invoice, string cryptoCode) + private IEnumerable GetAllLetheanPayments(InvoiceEntity invoice, string cryptoCode) { return invoice.GetPayments(false) .Where(p => p.PaymentMethodId == PaymentTypes.CHAIN.GetPaymentMethodId(cryptoCode)); diff --git a/Plugins/Zano/Services/ZanoLoadUpService.cs b/Plugins/Lethean/Services/LetheanLoadUpService.cs similarity index 61% rename from Plugins/Zano/Services/ZanoLoadUpService.cs rename to Plugins/Lethean/Services/LetheanLoadUpService.cs index 2e6ad82..dfa8118 100644 --- a/Plugins/Zano/Services/ZanoLoadUpService.cs +++ b/Plugins/Lethean/Services/LetheanLoadUpService.cs @@ -3,25 +3,25 @@ using System.IO; using System.Threading; using System.Threading.Tasks; -using BTCPayServer.Plugins.Zano.Configuration; -using BTCPayServer.Plugins.Zano.RPC.Models; +using BTCPayServer.Plugins.Lethean.Configuration; +using BTCPayServer.Plugins.Lethean.RPC.Models; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; -namespace BTCPayServer.Plugins.Zano.Services; +namespace BTCPayServer.Plugins.Lethean.Services; -public class ZanoLoadUpService : IHostedService +public class LetheanLoadUpService : IHostedService { - private const string CryptoCode = "ZANO"; - private readonly ILogger _logger; - private readonly ZanoRpcProvider _zanoRpcProvider; - private readonly ZanoConfiguration _zanoConfiguration; + private const string CryptoCode = "LTHN"; + private readonly ILogger _logger; + private readonly LetheanRpcProvider _letheanRpcProvider; + private readonly LetheanConfiguration _letheanConfiguration; - public ZanoLoadUpService(ILogger logger, ZanoRpcProvider zanoRpcProvider, ZanoConfiguration zanoConfiguration) + public LetheanLoadUpService(ILogger logger, LetheanRpcProvider letheanRpcProvider, LetheanConfiguration letheanConfiguration) { - _zanoRpcProvider = zanoRpcProvider; - _zanoConfiguration = zanoConfiguration; + _letheanRpcProvider = letheanRpcProvider; + _letheanConfiguration = letheanConfiguration; _logger = logger; } @@ -29,31 +29,31 @@ public class ZanoLoadUpService : IHostedService { try { - if (!_zanoConfiguration.ZanoConfigurationItems.TryGetValue(CryptoCode, out var configItem)) + if (!_letheanConfiguration.LetheanConfigurationItems.TryGetValue(CryptoCode, out var configItem)) { - _logger.LogInformation("No Zano configuration found, skipping wallet load"); + _logger.LogInformation("No Lethean configuration found, skipping wallet load"); return; } var walletDir = configItem.WalletDirectory; if (!string.IsNullOrEmpty(walletDir)) { - _logger.LogInformation("Attempting to load existing Zano wallet"); + _logger.LogInformation("Attempting to load existing Lethean wallet"); string password = await TryToGetPassword(walletDir, cancellationToken); - await _zanoRpcProvider.WalletRpcClients[CryptoCode] + await _letheanRpcProvider.WalletRpcClients[CryptoCode] .SendCommandAsync("open_wallet", new OpenWalletRequest { Filename = "wallet", Password = password }, cancellationToken); - await _zanoRpcProvider.UpdateSummary(CryptoCode); - _logger.LogInformation("Existing Zano wallet successfully loaded"); + await _letheanRpcProvider.UpdateSummary(CryptoCode); + _logger.LogInformation("Existing Lethean wallet successfully loaded"); } else { _logger.LogInformation("No wallet directory configured. Wallet should be pre-opened in simplewallet RPC mode."); // Still try to update summary — wallet may already be running in RPC mode - await _zanoRpcProvider.UpdateSummary(CryptoCode); + await _letheanRpcProvider.UpdateSummary(CryptoCode); } } catch (Exception ex) diff --git a/Plugins/Zano/Services/ZanoRpcProvider.cs b/Plugins/Lethean/Services/LetheanRpcProvider.cs similarity index 75% rename from Plugins/Zano/Services/ZanoRpcProvider.cs rename to Plugins/Lethean/Services/LetheanRpcProvider.cs index 8a788d3..38c873b 100644 --- a/Plugins/Zano/Services/ZanoRpcProvider.cs +++ b/Plugins/Lethean/Services/LetheanRpcProvider.cs @@ -4,33 +4,33 @@ using System.Collections.Immutable; using System.Net.Http; using System.Threading.Tasks; -using BTCPayServer.Plugins.Zano.Configuration; -using BTCPayServer.Plugins.Zano.RPC; -using BTCPayServer.Plugins.Zano.RPC.Models; +using BTCPayServer.Plugins.Lethean.Configuration; +using BTCPayServer.Plugins.Lethean.RPC; +using BTCPayServer.Plugins.Lethean.RPC.Models; -namespace BTCPayServer.Plugins.Zano.Services +namespace BTCPayServer.Plugins.Lethean.Services { - public class ZanoRpcProvider + public class LetheanRpcProvider { - private readonly ZanoConfiguration _zanoConfiguration; + private readonly LetheanConfiguration _letheanConfiguration; private readonly EventAggregator _eventAggregator; public ImmutableDictionary DaemonRpcClients; public ImmutableDictionary WalletRpcClients; - public ConcurrentDictionary Summaries { get; } = new(); + public ConcurrentDictionary Summaries { get; } = new(); - public ZanoRpcProvider(ZanoConfiguration zanoConfiguration, + public LetheanRpcProvider(LetheanConfiguration letheanConfiguration, EventAggregator eventAggregator, IHttpClientFactory httpClientFactory) { - _zanoConfiguration = zanoConfiguration; + _letheanConfiguration = letheanConfiguration; _eventAggregator = eventAggregator; DaemonRpcClients = - _zanoConfiguration.ZanoConfigurationItems.ToImmutableDictionary(pair => pair.Key, + _letheanConfiguration.LetheanConfigurationItems.ToImmutableDictionary(pair => pair.Key, pair => new JsonRpcClient(pair.Value.DaemonRpcUri, httpClientFactory.CreateClient($"{pair.Key}client"))); WalletRpcClients = - _zanoConfiguration.ZanoConfigurationItems.ToImmutableDictionary(pair => pair.Key, + _letheanConfiguration.LetheanConfigurationItems.ToImmutableDictionary(pair => pair.Key, pair => new JsonRpcClient(pair.Value.InternalWalletRpcUri, httpClientFactory.CreateClient($"{pair.Key}client"))); } @@ -42,13 +42,13 @@ namespace BTCPayServer.Plugins.Zano.Services return Summaries.ContainsKey(cryptoCode) && IsAvailable(Summaries[cryptoCode]); } - private bool IsAvailable(ZanoSummary summary) + private bool IsAvailable(LetheanSummary summary) { return summary.Synced && summary.WalletAvailable; } - public async Task UpdateSummary(string cryptoCode) + public async Task UpdateSummary(string cryptoCode) { if (!DaemonRpcClients.TryGetValue(cryptoCode.ToUpperInvariant(), out var daemonRpcClient) || !WalletRpcClients.TryGetValue(cryptoCode.ToUpperInvariant(), out var walletRpcClient)) @@ -56,7 +56,7 @@ namespace BTCPayServer.Plugins.Zano.Services return null; } - var summary = new ZanoSummary(); + var summary = new LetheanSummary(); try { var daemonResult = @@ -93,19 +93,19 @@ namespace BTCPayServer.Plugins.Zano.Services Summaries[cryptoCode] = summary; if (changed) { - _eventAggregator.Publish(new ZanoDaemonStateChange() { Summary = summary, CryptoCode = cryptoCode }); + _eventAggregator.Publish(new LetheanDaemonStateChange() { Summary = summary, CryptoCode = cryptoCode }); } return summary; } - public class ZanoDaemonStateChange + public class LetheanDaemonStateChange { public string CryptoCode { get; set; } - public ZanoSummary Summary { get; set; } + public LetheanSummary Summary { get; set; } } - public class ZanoSummary + public class LetheanSummary { public bool Synced { get; set; } public long CurrentHeight { get; set; } diff --git a/Plugins/Zano/Services/ZanoSummaryUpdaterHostedService.cs b/Plugins/Lethean/Services/LetheanSummaryUpdaterHostedService.cs similarity index 71% rename from Plugins/Zano/Services/ZanoSummaryUpdaterHostedService.cs rename to Plugins/Lethean/Services/LetheanSummaryUpdaterHostedService.cs index ce1a456..7df6c06 100644 --- a/Plugins/Zano/Services/ZanoSummaryUpdaterHostedService.cs +++ b/Plugins/Lethean/Services/LetheanSummaryUpdaterHostedService.cs @@ -3,31 +3,31 @@ using System.Threading; using System.Threading.Tasks; using BTCPayServer.Logging; -using BTCPayServer.Plugins.Zano.Configuration; -using BTCPayServer.Plugins.Zano.RPC; +using BTCPayServer.Plugins.Lethean.Configuration; +using BTCPayServer.Plugins.Lethean.RPC; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; -namespace BTCPayServer.Plugins.Zano.Services +namespace BTCPayServer.Plugins.Lethean.Services { - public class ZanoSummaryUpdaterHostedService : IHostedService + public class LetheanSummaryUpdaterHostedService : IHostedService { - private readonly ZanoRpcProvider _zanoRpcProvider; - private readonly ZanoConfiguration _zanoConfiguration; + private readonly LetheanRpcProvider _letheanRpcProvider; + private readonly LetheanConfiguration _letheanConfiguration; private readonly EventAggregator _eventAggregator; public Logs Logs { get; } private CancellationTokenSource _cts; - public ZanoSummaryUpdaterHostedService(ZanoRpcProvider zanoRpcProvider, - ZanoConfiguration zanoConfiguration, + public LetheanSummaryUpdaterHostedService(LetheanRpcProvider letheanRpcProvider, + LetheanConfiguration letheanConfiguration, EventAggregator eventAggregator, Logs logs) { - _zanoRpcProvider = zanoRpcProvider; - _zanoConfiguration = zanoConfiguration; + _letheanRpcProvider = letheanRpcProvider; + _letheanConfiguration = letheanConfiguration; _eventAggregator = eventAggregator; Logs = logs; } @@ -35,7 +35,7 @@ namespace BTCPayServer.Plugins.Zano.Services public Task StartAsync(CancellationToken cancellationToken) { _cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); - foreach (var configItem in _zanoConfiguration.ZanoConfigurationItems) + foreach (var configItem in _letheanConfiguration.LetheanConfigurationItems) { _ = StartSummaryLoop(_cts.Token, configItem.Key); _ = StartPollingLoop(_cts.Token, configItem.Key); @@ -45,15 +45,15 @@ namespace BTCPayServer.Plugins.Zano.Services private async Task StartSummaryLoop(CancellationToken cancellation, string cryptoCode) { - Logs.PayServer.LogInformation("Starting Zano daemon summary updater ({CryptoCode})", cryptoCode); + Logs.PayServer.LogInformation("Starting Lethean daemon summary updater ({CryptoCode})", cryptoCode); try { while (!cancellation.IsCancellationRequested) { try { - await _zanoRpcProvider.UpdateSummary(cryptoCode); - if (_zanoRpcProvider.IsAvailable(cryptoCode)) + await _letheanRpcProvider.UpdateSummary(cryptoCode); + if (_letheanRpcProvider.IsAvailable(cryptoCode)) { await Task.Delay(TimeSpan.FromMinutes(1), cancellation); } @@ -77,16 +77,16 @@ namespace BTCPayServer.Plugins.Zano.Services private async Task StartPollingLoop(CancellationToken cancellation, string cryptoCode) { - Logs.PayServer.LogInformation("Starting Zano payment polling loop ({CryptoCode})", cryptoCode); + Logs.PayServer.LogInformation("Starting Lethean payment polling loop ({CryptoCode})", cryptoCode); try { while (!cancellation.IsCancellationRequested) { try { - if (_zanoRpcProvider.IsAvailable(cryptoCode)) + if (_letheanRpcProvider.IsAvailable(cryptoCode)) { - _eventAggregator.Publish(new ZanoPollEvent { CryptoCode = cryptoCode }); + _eventAggregator.Publish(new LetheanPollEvent { CryptoCode = cryptoCode }); } await Task.Delay(TimeSpan.FromSeconds(15), cancellation); } diff --git a/Plugins/Lethean/Services/LetheanSyncSummaryProvider.cs b/Plugins/Lethean/Services/LetheanSyncSummaryProvider.cs new file mode 100644 index 0000000..1795e63 --- /dev/null +++ b/Plugins/Lethean/Services/LetheanSyncSummaryProvider.cs @@ -0,0 +1,47 @@ +using System.Collections.Generic; +using System.Linq; + +using BTCPayServer.Abstractions.Contracts; +using BTCPayServer.Client.Models; +using BTCPayServer.Payments; + +namespace BTCPayServer.Plugins.Lethean.Services +{ + public class LetheanSyncSummaryProvider : ISyncSummaryProvider + { + private readonly LetheanRpcProvider _letheanRpcProvider; + + public LetheanSyncSummaryProvider(LetheanRpcProvider letheanRpcProvider) + { + _letheanRpcProvider = letheanRpcProvider; + } + + public bool AllAvailable() + { + return _letheanRpcProvider.Summaries.All(pair => pair.Value.DaemonAvailable); + } + + public string Partial { get; } = "/Views/Lethean/LetheanSyncSummary.cshtml"; + public IEnumerable GetStatuses() + { + return _letheanRpcProvider.Summaries.Select(pair => new LetheanSyncStatus() + { + Summary = pair.Value, + PaymentMethodId = PaymentMethodId.Parse(pair.Key).ToString() + }); + } + } + + public class LetheanSyncStatus : SyncStatus, ISyncStatus + { + public override bool Available + { + get + { + return Summary?.WalletAvailable ?? false; + } + } + + public LetheanRpcProvider.LetheanSummary Summary { get; set; } + } +} \ No newline at end of file diff --git a/Plugins/Zano/Utils/ZanoMoney.cs b/Plugins/Lethean/Utils/LetheanMoney.cs similarity index 65% rename from Plugins/Zano/Utils/ZanoMoney.cs rename to Plugins/Lethean/Utils/LetheanMoney.cs index 8315078..f968fd2 100644 --- a/Plugins/Zano/Utils/ZanoMoney.cs +++ b/Plugins/Lethean/Utils/LetheanMoney.cs @@ -1,8 +1,8 @@ using System.Globalization; -namespace BTCPayServer.Plugins.Zano.Utils +namespace BTCPayServer.Plugins.Lethean.Utils { - public static class ZanoMoney + public static class LetheanMoney { public static decimal Convert(long atomicUnits) { @@ -12,9 +12,9 @@ namespace BTCPayServer.Plugins.Zano.Utils return decimal.Parse(amt, CultureInfo.InvariantCulture); } - public static long Convert(decimal zano) + public static long Convert(decimal lethean) { - return System.Convert.ToInt64(zano * 1000000000000); + return System.Convert.ToInt64(lethean * 1000000000000); } } } \ No newline at end of file diff --git a/Plugins/Zano/ViewModels/ZanoPaymentViewModel.cs b/Plugins/Lethean/ViewModels/LetheanPaymentViewModel.cs similarity index 83% rename from Plugins/Zano/ViewModels/ZanoPaymentViewModel.cs rename to Plugins/Lethean/ViewModels/LetheanPaymentViewModel.cs index 3ea2536..0cc2d9b 100644 --- a/Plugins/Zano/ViewModels/ZanoPaymentViewModel.cs +++ b/Plugins/Lethean/ViewModels/LetheanPaymentViewModel.cs @@ -2,9 +2,9 @@ using System; using BTCPayServer.Payments; -namespace BTCPayServer.Plugins.Zano.ViewModels +namespace BTCPayServer.Plugins.Lethean.ViewModels { - public class ZanoPaymentViewModel + public class LetheanPaymentViewModel { public PaymentMethodId PaymentMethodId { get; set; } public string Confirmations { get; set; } diff --git a/Plugins/Zano/Views/Zano/GetStoreZanoPaymentMethod.cshtml b/Plugins/Lethean/Views/Lethean/GetStoreLetheanPaymentMethod.cshtml similarity index 81% rename from Plugins/Zano/Views/Zano/GetStoreZanoPaymentMethod.cshtml rename to Plugins/Lethean/Views/Lethean/GetStoreLetheanPaymentMethod.cshtml index c22383f..9cd845b 100644 --- a/Plugins/Zano/Views/Zano/GetStoreZanoPaymentMethod.cshtml +++ b/Plugins/Lethean/Views/Lethean/GetStoreLetheanPaymentMethod.cshtml @@ -1,6 +1,6 @@ -@using ZanoPaymentMethodViewModel = BTCPayServer.Plugins.Zano.Controllers.UIZanoStoreController.ZanoPaymentMethodViewModel -@using ZanoSettlementThresholdChoice = BTCPayServer.Plugins.Zano.Controllers.UIZanoStoreController.ZanoSettlementThresholdChoice; -@model ZanoPaymentMethodViewModel +@using LetheanPaymentMethodViewModel = BTCPayServer.Plugins.Lethean.Controllers.UILetheanStoreController.LetheanPaymentMethodViewModel +@using LetheanSettlementThresholdChoice = BTCPayServer.Plugins.Lethean.Controllers.UILetheanStoreController.LetheanSettlementThresholdChoice; +@model LetheanPaymentMethodViewModel @{ ViewData.SetActivePage(Model.CryptoCode, StringLocalizer["{0} Settings", Model.CryptoCode], Model.CryptoCode); @@ -30,13 +30,13 @@ @if (Model.Summary?.WalletAvailable != true) {
-

To accept Zano payments, you need a Zano wallet running in RPC mode.

-

Start simplewallet with --rpc-bind-port and configure BTCPAY_ZANO_WALLET_DAEMON_URI to point to it.

+

To accept Lethean payments, you need a Lethean wallet running in RPC mode.

+

Start simplewallet with --rpc-bind-port and configure BTCPAY_LTHN_WALLET_DAEMON_URI to point to it.

For view-only monitoring, create a watch-only wallet using simplewallet --save_watch_only first.

} -
@@ -56,20 +56,20 @@ - -