Skip to content

Commit

Permalink
Move altcoins out of btcpay
Browse files Browse the repository at this point in the history
  • Loading branch information
Kukks committed Dec 1, 2023
1 parent afed3a0 commit 21b3b14
Show file tree
Hide file tree
Showing 154 changed files with 1,892 additions and 1,035 deletions.
12 changes: 0 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@ jobs:
GIT_COMMIT=$(git rev-parse HEAD)
#
sudo docker build --build-arg GIT_COMMIT=${GIT_COMMIT} --pull -t $DOCKERHUB_REPO:$LATEST_TAG-amd64 -f amd64.Dockerfile .
sudo docker build --build-arg GIT_COMMIT=${GIT_COMMIT} --pull --build-arg CONFIGURATION_NAME=Altcoins-Release -t $DOCKERHUB_REPO:$LATEST_TAG-altcoins-amd64 -f amd64.Dockerfile .
sudo docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS
sudo docker push $DOCKERHUB_REPO:$LATEST_TAG-amd64
sudo docker push $DOCKERHUB_REPO:$LATEST_TAG-altcoins-amd64
arm32v7:
machine:
Expand All @@ -61,10 +59,8 @@ jobs:
GIT_COMMIT=$(git rev-parse HEAD)
#
sudo docker build --build-arg GIT_COMMIT=${GIT_COMMIT} --pull -t $DOCKERHUB_REPO:$LATEST_TAG-arm32v7 -f arm32v7.Dockerfile .
sudo docker build --build-arg GIT_COMMIT=${GIT_COMMIT} --pull --build-arg CONFIGURATION_NAME=Altcoins-Release -t $DOCKERHUB_REPO:$LATEST_TAG-altcoins-arm32v7 -f arm32v7.Dockerfile .
sudo docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS
sudo docker push $DOCKERHUB_REPO:$LATEST_TAG-arm32v7
sudo docker push $DOCKERHUB_REPO:$LATEST_TAG-altcoins-arm32v7
arm64v8:
machine:
Expand All @@ -78,10 +74,8 @@ jobs:
GIT_COMMIT=$(git rev-parse HEAD)
#
sudo docker build --build-arg GIT_COMMIT=${GIT_COMMIT} --pull -t $DOCKERHUB_REPO:$LATEST_TAG-arm64v8 -f arm64v8.Dockerfile .
sudo docker build --build-arg GIT_COMMIT=${GIT_COMMIT} --build-arg CONFIGURATION_NAME=Altcoins-Release --pull -t $DOCKERHUB_REPO:$LATEST_TAG-altcoins-arm64v8 -f arm64v8.Dockerfile .
sudo docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS
sudo docker push $DOCKERHUB_REPO:$LATEST_TAG-arm64v8
sudo docker push $DOCKERHUB_REPO:$LATEST_TAG-altcoins-arm64v8
multiarch:
machine:
Expand All @@ -98,12 +92,6 @@ jobs:
sudo docker manifest annotate $DOCKERHUB_REPO:$LATEST_TAG $DOCKERHUB_REPO:$LATEST_TAG-arm64v8 --os linux --arch arm64 --variant v8
sudo docker manifest push $DOCKERHUB_REPO:$LATEST_TAG -p
sudo docker manifest create --amend $DOCKERHUB_REPO:$LATEST_TAG-altcoins $DOCKERHUB_REPO:$LATEST_TAG-altcoins-amd64 $DOCKERHUB_REPO:$LATEST_TAG-altcoins-arm32v7 $DOCKERHUB_REPO:$LATEST_TAG-altcoins-arm64v8
sudo docker manifest annotate $DOCKERHUB_REPO:$LATEST_TAG-altcoins $DOCKERHUB_REPO:$LATEST_TAG-altcoins-amd64 --os linux --arch amd64
sudo docker manifest annotate $DOCKERHUB_REPO:$LATEST_TAG-altcoins $DOCKERHUB_REPO:$LATEST_TAG-altcoins-arm32v7 --os linux --arch arm --variant v7
sudo docker manifest annotate $DOCKERHUB_REPO:$LATEST_TAG-altcoins $DOCKERHUB_REPO:$LATEST_TAG-altcoins-arm64v8 --os linux --arch arm64 --variant v8
sudo docker manifest push $DOCKERHUB_REPO:$LATEST_TAG-altcoins -p
workflows:
version: 2
build_and_test:
Expand Down
21 changes: 21 additions & 0 deletions .run/BTCPayServer_ Altcoins-HTTPS.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="BTCPayServer: Altcoins-HTTPS" type="LaunchSettings" factoryName=".NET Launch Settings Profile">
<option name="LAUNCH_PROFILE_PROJECT_FILE_PATH" value="$PROJECT_DIR$/BTCPayServer/BTCPayServer.csproj" />
<option name="LAUNCH_PROFILE_TFM" value="net6.0" />
<option name="LAUNCH_PROFILE_NAME" value="Altcoins-HTTPS" />
<option name="USE_EXTERNAL_CONSOLE" value="0" />
<option name="USE_MONO" value="0" />
<option name="RUNTIME_ARGUMENTS" value="" />
<option name="GENERATE_APPLICATIONHOST_CONFIG" value="1" />
<option name="SHOW_IIS_EXPRESS_OUTPUT" value="0" />
<option name="SEND_DEBUG_REQUEST" value="1" />
<option name="ADDITIONAL_IIS_EXPRESS_ARGUMENTS" value="" />
<method v="2">
<option name="Build" />
<option name="Build" default="false" projectName="BTCPayServer.Plugins.Zcash" projectPath="$PROJECT_DIR$/Plugins/BTCPayServer.Plugins.Zcash/BTCPayServer.Plugins.Zcash.csproj" />
<option name="Build" default="false" projectName="BTCPayServer.Plugins.Monero" projectPath="$PROJECT_DIR$/Plugins/BTCPayServer.Plugins.Monero/BTCPayServer.Plugins.Monero.csproj" />
<option name="Build" default="false" projectName="BTCPayServer.Plugins.Liquid" projectPath="$PROJECT_DIR$/Plugins/BTCPayServer.Plugins.Liquid/BTCPayServer.Plugins.Liquid.csproj" />
<option name="Build" default="false" projectName="BTCPayServer.Plugins.Altcoins" projectPath="$PROJECT_DIR$/Plugins/BTCPayServer.Plugins.Altcoins/BTCPayServer.Plugins.Altcoins.csproj" />
</method>
</configuration>
</component>
2 changes: 1 addition & 1 deletion BTCPayServer.Client/BTCPayServer.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryUrl>https://github.com/btcpayserver/btcpayserver</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<Configurations>Debug;Release;Altcoins-Debug;Altcoins-Release</Configurations>
<Configurations>Debug;Release</Configurations>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>
<PropertyGroup>
Expand Down
18 changes: 18 additions & 0 deletions BTCPayServer.Common/BTCPayNetwork.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,24 @@ public virtual List<TransactionInformation> FilterValidTransactions(List<Transac
{
return transactionInformationSet;
}

public virtual decimal GetValue(IMoney m)
{
switch (m)
{
case Money money:
return money.ToDecimal(MoneyUnit.BTC);
case MoneyBag mb:
return mb.Sum(GetValue);
default:
throw new NotSupportedException("IMoney type not supported");
}
}

public virtual string GetAssetId()
{
return null;
}
}

public abstract class BTCPayNetworkBase
Expand Down
23 changes: 1 addition & 22 deletions BTCPayServer.Common/BTCPayNetworkProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,23 @@
using System.Linq;
using BTCPayServer.Configuration;
using BTCPayServer.Logging;
using Microsoft.AspNetCore.DataProtection.KeyManagement;
using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using NBitcoin;
using NBXplorer;
using StandardConfiguration;

namespace BTCPayServer
{
public partial class BTCPayNetworkProvider
{
protected readonly Dictionary<string, BTCPayNetworkBase> _Networks = new Dictionary<string, BTCPayNetworkBase>();

private readonly NBXplorerNetworkProvider _NBXplorerNetworkProvider;
public NBXplorerNetworkProvider NBXplorerNetworkProvider
{
get
{
return _NBXplorerNetworkProvider;
}
}

public ChainName NetworkType { get; private set; }
public BTCPayNetworkProvider(
IEnumerable<BTCPayNetworkBase> networks,
SelectedChains selectedChains,
NBXplorerNetworkProvider nbxplorerNetworkProvider,
Logs logs,
IConfiguration configuration)
Logs logs)
{
#if !ALTCOINS
var onlyBTC = networks.Count() == 1 && networks.First().IsBTC;
if (!onlyBTC)
throw new ConfigException($"This build of BTCPay Server does not support altcoins");
#endif

_NBXplorerNetworkProvider = nbxplorerNetworkProvider;
NetworkType = nbxplorerNetworkProvider.NetworkType;
foreach (var network in networks)
{
Expand Down
6 changes: 0 additions & 6 deletions BTCPayServer.Common/BTCPayServer.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,4 @@
<PackageReference Include="NBXplorer.Client" Version="4.2.6" />
<PackageReference Include="NicolasDorier.StandardConfiguration" Version="2.0.1" />
</ItemGroup>
<ItemGroup Condition="'$(Altcoins)' != 'true'">
<Compile Remove="Altcoins\**\*.cs"></Compile>
</ItemGroup>
<ItemGroup>
<Folder Include="Altcoins\" />
</ItemGroup>
</Project>
7 changes: 1 addition & 6 deletions BTCPayServer.Tests/AltcoinTests/ElementsTests.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BTCPayServer.Configuration;
using BTCPayServer.Controllers;
using BTCPayServer.Models.WalletViewModels;
using BTCPayServer.Plugins.Altcoins;
using BTCPayServer.Plugins.Liquid;
using BTCPayServer.Services.Wallets;
using BTCPayServer.Tests.Logging;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration.Memory;
using NBitcoin;
using NBitcoin.Payment;
using NBitpayClient;
Expand Down
7 changes: 4 additions & 3 deletions BTCPayServer.Tests/BTCPayServer.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup Condition="'$(Altcoins)' != 'true'">
<Compile Remove="AltcoinTests\**\*.cs"></Compile>
</ItemGroup>
<ItemGroup>
<None Update=".dockerignore">
<DependentUpon>Dockerfile</DependentUpon>
Expand All @@ -52,6 +49,10 @@
<ItemGroup>
<ProjectReference Include="..\BTCPayServer.Rating\BTCPayServer.Rating.csproj" />
<ProjectReference Include="..\BTCPayServer\BTCPayServer.csproj" />
<ProjectReference Include="..\Plugins\BTCPayServer.Plugins.Altcoins\BTCPayServer.Plugins.Altcoins.csproj" />
<ProjectReference Include="..\Plugins\BTCPayServer.Plugins.Liquid\BTCPayServer.Plugins.Liquid.csproj" />
<ProjectReference Include="..\Plugins\BTCPayServer.Plugins.Monero\BTCPayServer.Plugins.Monero.csproj" />
<ProjectReference Include="..\Plugins\BTCPayServer.Plugins.Zcash\BTCPayServer.Plugins.Zcash.csproj" />
</ItemGroup>

</Project>
9 changes: 0 additions & 9 deletions BTCPayServer.Tests/FastTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,6 @@ public void CanParsePaymentMethodId()
Assert.Equal(id, id2);
Assert.Equal("LTC_LightningLike", id.ToString());
Assert.Equal("LTC-LightningNetwork", id.ToStringNormalized());
#if ALTCOINS
id = PaymentMethodId.Parse("XMR");
id1 = PaymentMethodId.Parse("XMR-MoneroLike");
Assert.Equal(id, id1);
Assert.Equal("XMR_MoneroLike", id.ToString());
Assert.Equal("XMR", id.ToStringNormalized());
#endif
}

[Fact]
Expand Down Expand Up @@ -456,7 +449,6 @@ public void CanCalculateDust()

#pragma warning restore CS0618
}
#if ALTCOINS
[Fact]
public void CanCalculateCryptoDue()
{
Expand Down Expand Up @@ -622,7 +614,6 @@ public void CanCalculateCryptoDue()
Assert.Equal(accounting.Paid, accounting.TotalDue);
#pragma warning restore CS0618
}
#endif

[Fact]
public void DeterministicUTXOSorter()
Expand Down
6 changes: 1 addition & 5 deletions BTCPayServer.Tests/ServerTester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public ServerTester(string scope, bool newDb, ILog testLogs, ILoggerProvider log
PayTester.SSHConnection = GetEnvironment("TESTS_SSHCONNECTION", "[email protected]:21622");
PayTester.SocksEndpoint = GetEnvironment("TESTS_SOCKSENDPOINT", "localhost:9050");
}
#if ALTCOINS
public void ActivateLTC()
{
LTCExplorerNode = new RPCClient(RPCCredentialString.Parse(GetEnvironment("TESTS_LTCRPCCONNECTION", "server=http://127.0.0.1:43783;ceiwHEbqWI83:DwubwWsoo3")), NetworkProvider.GetNetwork<BTCPayNetwork>("LTC").NBitcoinNetwork);
Expand All @@ -91,8 +90,7 @@ public void ActivateETH()
{
PayTester.Chains.Add("ETH");
}

#endif

public void ActivateLightning()
{
ActivateLightning(LightningConnectionType.CLightning);
Expand Down Expand Up @@ -220,7 +218,6 @@ public RPCClient ExplorerNode
{
get; set;
}
#if ALTCOINS
public RPCClient LTCExplorerNode
{
get; set;
Expand All @@ -229,7 +226,6 @@ public RPCClient LTCExplorerNode
public RPCClient LBTCExplorerNode { get; set; }
public ExplorerClient LTCExplorerClient { get; set; }
public ExplorerClient LBTCExplorerClient { get; set; }
#endif

public ExplorerClient ExplorerClient
{
Expand Down
11 changes: 8 additions & 3 deletions BTCPayServer.Tests/UnitTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
using BTCPayServer.Logging;
using BTCPayServer.Plugins.Bitcoin;
using BTCPayServer.Plugins;
using BTCPayServer.Plugins.Altcoins;
using BTCPayServer.Plugins.Liquid;
using BTCPayServer.Plugins.Monero;
using BTCPayServer.Plugins.Zcash;
using BTCPayServer.Tests.Logging;
using Microsoft.Extensions.DependencyInjection;
using NBXplorer;
Expand Down Expand Up @@ -58,9 +62,10 @@ public BTCPayNetworkProvider CreateNetworkProvider(IConfiguration conf = null)
var bootstrap = Startup.CreateBootstrap(conf);
var services = new PluginServiceCollection(new ServiceCollection(), bootstrap);
var plugins = new List<BaseBTCPayServerPlugin>() { new BitcoinPlugin() };
#if ALTCOINS
plugins.Add(new BTCPayServer.Plugins.Altcoins.AltcoinsPlugin());
#endif
plugins.Add(new LiquidPlugin());
plugins.Add(new MoneroPlugin());
plugins.Add(new ZcashPlugin());
plugins.Add(new AltcoinsPlugin());
foreach (var p in plugins)
{
p.Execute(services);
Expand Down
2 changes: 1 addition & 1 deletion BTCPayServer.Tests/docker-compose.altcoins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
context: ..
dockerfile: BTCPayServer.Tests/Dockerfile
args:
CONFIGURATION_NAME: Altcoins-Release
CONFIGURATION_NAME: Release
environment:
TESTS_BTCRPCCONNECTION: server=http://bitcoind:43782;ceiwHEbqWI83:DwubwWsoo3
TESTS_LTCRPCCONNECTION: server=http://litecoind:43782;ceiwHEbqWI83:DwubwWsoo3
Expand Down
10 changes: 0 additions & 10 deletions BTCPayServer/BTCPayServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,6 @@
<ItemGroup>
<None Remove="Currencies.txt" />
</ItemGroup>

<ItemGroup Condition="'$(Altcoins)' != 'true'">
<Content Remove="Services\Altcoins\**\*" />
<Compile Remove="Plugins\Altcoins\**\*" />
<Content Remove="Views\UIMoneroLikeStore\**\*" />
<Content Remove="Views\UIZcashLikeStore\**\*" />
<Content Remove="Views\Shared\Monero\**\*" />
<Content Remove="Views\Shared\Zcash\**\*" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="YamlDotNet" Version="8.0.0" />
<PackageReference Include="BIP78.Sender" Version="0.2.2" />
Expand Down
4 changes: 1 addition & 3 deletions BTCPayServer/Components/MainNav/MainNav.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ public async Task<IViewComponentResult> InvokeAsync()
{
var store = ViewContext.HttpContext.GetStoreData();
var vm = new MainNavViewModel { Store = store };
#if ALTCOINS
vm.AltcoinsBuild = true;
#endif
vm.AltcoinsBuild = _networkProvider.GetAll().Count() > 1;
if (store != null)
{
var storeBlob = store.GetStoreBlob();
Expand Down
6 changes: 0 additions & 6 deletions BTCPayServer/Configuration/DefaultConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
Expand All @@ -11,7 +10,6 @@
using BTCPayServer.Plugins.Bitcoin;
using CommandLine;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration.Memory;
using Microsoft.Extensions.DependencyInjection;
using NBitcoin;
using NBXplorer;
Expand Down Expand Up @@ -167,10 +165,6 @@ private BTCPayNetworkProvider CreateBTCPayNetworkProvider(ChainName networkType)
var services = new PluginServiceCollection(collection, Startup.CreateBootstrap(conf));
var p1 = new BitcoinPlugin();
p1.Execute(services);
#if ALTCOINS
var p2 = new Plugins.Altcoins.AltcoinsPlugin();
p2.Execute(services);
#endif
services.AddSingleton(services.BootstrapServices.GetRequiredService<SelectedChains>());
services.AddSingleton(services.BootstrapServices.GetRequiredService<NBXplorerNetworkProvider>());
services.AddSingleton(services.BootstrapServices.GetRequiredService<Logs>());
Expand Down
5 changes: 1 addition & 4 deletions BTCPayServer/Controllers/UIInvoiceController.UI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -836,10 +836,7 @@ public async Task<IActionResult> CheckoutNoScript(string? invoiceId, string? id
Request.Host,
Request.PathBase) : null;

var isAltcoinsBuild = false;
#if ALTCOINS
isAltcoinsBuild = true;
#endif
var isAltcoinsBuild = _NetworkProvider.GetAll().Count() > 1;;

var orderId = invoice.Metadata.OrderId;
var supportUrl = !string.IsNullOrEmpty(storeBlob.StoreSupportUrl)
Expand Down
4 changes: 1 addition & 3 deletions BTCPayServer/Controllers/UIStoresController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -667,9 +667,7 @@ public async Task<IActionResult> CheckoutAppearance(CheckoutAppearanceViewModel
Value = value,
WalletId = new WalletId(store.Id, paymentMethodId.CryptoCode),
Enabled = !excludeFilters.Match(paymentMethodId) && strategy != null,
#if ALTCOINS
Collapsed = network is Plugins.Altcoins.ElementsBTCPayNetwork elementsBTCPayNetwork && elementsBTCPayNetwork.NetworkCryptoCode != elementsBTCPayNetwork.CryptoCode && string.IsNullOrEmpty(value)
#endif
Collapsed = string.IsNullOrEmpty(value) && network.GetAssetId() is not null
});
break;

Expand Down
6 changes: 0 additions & 6 deletions BTCPayServer/Controllers/UIWalletsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -387,12 +387,6 @@ private async Task SendFreeMoney(Cheater cheater, WalletId walletId, DerivationS
{
var c = this.ExplorerClientProvider.GetExplorerClient(walletId.CryptoCode);
var cashCow = cheater.GetCashCow(walletId.CryptoCode);
#if ALTCOINS
if (walletId.CryptoCode == "LBTC")
{
await cashCow.SendCommandAsync("rescanblockchain");
}
#endif
var addresses = Enumerable.Range(0, 200).Select(_ => c.GetUnusedAsync(paymentMethod.AccountDerivation, DerivationFeature.Deposit, reserve: true)).ToArray();

await Task.WhenAll(addresses);
Expand Down

0 comments on commit 21b3b14

Please sign in to comment.