diff --git a/.gitignore b/.gitignore index 7ab637e..9d65564 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ **/bin/**/* **/obj .idea +Plugins/packed diff --git a/BTCPayServerPlugins.sln b/BTCPayServerPlugins.sln index 255bcf5..bca6356 100644 --- a/BTCPayServerPlugins.sln +++ b/BTCPayServerPlugins.sln @@ -41,6 +41,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BTCPayServer.Plugins.AOPP", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BTCPayServer.Plugins.LSP", "Plugins\BTCPayServer.Plugins.LSP\BTCPayServer.Plugins.LSP.csproj", "{304E4860-8420-4D71-B95A-3E2F75BEE9F6}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BTCPayServer.PluginPacker", "submodules\btcpayserver\BTCPayServer.PluginPacker\BTCPayServer.PluginPacker.csproj", "{2FDF2D41-8E75-49F6-9F4D-9E9AECE7922F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -193,6 +195,14 @@ Global {304E4860-8420-4D71-B95A-3E2F75BEE9F6}.Altcoins-Debug|Any CPU.Build.0 = Debug|Any CPU {304E4860-8420-4D71-B95A-3E2F75BEE9F6}.Altcoins-Release|Any CPU.ActiveCfg = Release|Any CPU {304E4860-8420-4D71-B95A-3E2F75BEE9F6}.Altcoins-Release|Any CPU.Build.0 = Release|Any CPU + {2FDF2D41-8E75-49F6-9F4D-9E9AECE7922F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2FDF2D41-8E75-49F6-9F4D-9E9AECE7922F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2FDF2D41-8E75-49F6-9F4D-9E9AECE7922F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2FDF2D41-8E75-49F6-9F4D-9E9AECE7922F}.Release|Any CPU.Build.0 = Release|Any CPU + {2FDF2D41-8E75-49F6-9F4D-9E9AECE7922F}.Altcoins-Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2FDF2D41-8E75-49F6-9F4D-9E9AECE7922F}.Altcoins-Debug|Any CPU.Build.0 = Debug|Any CPU + {2FDF2D41-8E75-49F6-9F4D-9E9AECE7922F}.Altcoins-Release|Any CPU.ActiveCfg = Debug|Any CPU + {2FDF2D41-8E75-49F6-9F4D-9E9AECE7922F}.Altcoins-Release|Any CPU.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {B19C9F52-DC47-466D-8B5C-2D202B7B003F} = {9E04ECE9-E304-4FF2-9CBC-83256E6C6962} diff --git a/BTCPayServerPlugins.sln.DotSettings.user b/BTCPayServerPlugins.sln.DotSettings.user new file mode 100644 index 0000000..ee25a68 --- /dev/null +++ b/BTCPayServerPlugins.sln.DotSettings.user @@ -0,0 +1,2 @@ + + True \ No newline at end of file diff --git a/Plugins/BTCPayServer.Plugins.Wabisabi/BTCPayServer.Plugins.Wabisabi.csproj b/Plugins/BTCPayServer.Plugins.Wabisabi/BTCPayServer.Plugins.Wabisabi.csproj index e17266d..3c0f32c 100644 --- a/Plugins/BTCPayServer.Plugins.Wabisabi/BTCPayServer.Plugins.Wabisabi.csproj +++ b/Plugins/BTCPayServer.Plugins.Wabisabi/BTCPayServer.Plugins.Wabisabi.csproj @@ -13,7 +13,7 @@ Wabisabi Coinjoin Allows you to integrate your btcpayserver store with coinjoins. - 1.0.10 + 1.0.11 diff --git a/Plugins/BTCPayServer.Plugins.Wabisabi/Smartifier.cs b/Plugins/BTCPayServer.Plugins.Wabisabi/Smartifier.cs index ecee494..74e8333 100644 --- a/Plugins/BTCPayServer.Plugins.Wabisabi/Smartifier.cs +++ b/Plugins/BTCPayServer.Plugins.Wabisabi/Smartifier.cs @@ -5,8 +5,7 @@ using System.ComponentModel; using System.Linq; using System.Threading.Tasks; using BTCPayServer.Abstractions.Contracts; -using BTCPayServer.Client.Models; -using BTCPayServer.Data; +using BTCPayServer.Payments.PayJoin; using BTCPayServer.Services; using BTCPayServer.Services.Wallets; using NBitcoin; @@ -26,25 +25,21 @@ public class Smartifier private readonly WalletRepository _walletRepository; private readonly ExplorerClient _explorerClient; public DerivationStrategyBase DerivationScheme { get; } - private readonly IBTCPayServerClientFactory _btcPayServerClientFactory; private readonly string _storeId; - private readonly Action _coinOnPropertyChanged; + private readonly IUTXOLocker _utxoLocker; public Smartifier( WalletRepository walletRepository, - ExplorerClient explorerClient, DerivationStrategyBase derivationStrategyBase, - IBTCPayServerClientFactory btcPayServerClientFactory, string storeId, - Action coinOnPropertyChanged) + ExplorerClient explorerClient, DerivationStrategyBase derivationStrategyBase, string storeId, + IUTXOLocker utxoLocker) { _walletRepository = walletRepository; _explorerClient = explorerClient; DerivationScheme = derivationStrategyBase; - _btcPayServerClientFactory = btcPayServerClientFactory; _storeId = storeId; - _coinOnPropertyChanged = coinOnPropertyChanged; + _utxoLocker = utxoLocker; _accountKeyPath = _explorerClient.GetMetadataAsync(DerivationScheme, WellknownMetadataKeys.AccountKeyPath); - } private ConcurrentDictionary> cached = new(); @@ -68,7 +63,6 @@ public class Smartifier foreach (var coin in coins) { - var client = await _btcPayServerClientFactory.Create(null, _storeId); var tx = await Transactions.GetOrAdd(coin.OutPoint.Hash, async uint256 => { var unsmartTx = await cached[coin.OutPoint.Hash]; @@ -157,11 +151,11 @@ public class Smartifier var pubKey = DerivationScheme.GetChild(coin.KeyPath).GetExtPubKeys().First().PubKey; var kp = (await _accountKeyPath).Derive(coin.KeyPath).KeyPath; - var hdPubKey = new HdPubKey(pubKey, kp, new SmartLabel(labels.labels?? new HashSet()), + var hdPubKey = new HdPubKey(pubKey, kp, new SmartLabel(labels.labels ?? new HashSet()), current == 1 ? KeyState.Clean : KeyState.Used); hdPubKey.SetAnonymitySet(labels.anonset); - var c = new SmartCoin(tx, coin.OutPoint.N, hdPubKey); + var c = new SmartCoin(tx, coin.OutPoint.N, hdPubKey); c.PropertyChanged += CoinPropertyChanged; return c; }); @@ -172,6 +166,22 @@ public class Smartifier private void CoinPropertyChanged(object sender, PropertyChangedEventArgs e) { - _coinOnPropertyChanged.Invoke(sender, e); + if (sender is SmartCoin smartCoin) + { + if (e.PropertyName == nameof(SmartCoin.CoinJoinInProgress)) + { + // _logger.LogInformation($"{smartCoin.Outpoint}.CoinJoinInProgress = {smartCoin.CoinJoinInProgress}"); + if (_utxoLocker is not null) + { + _ = (smartCoin.CoinJoinInProgress + ? _utxoLocker.TryLock(smartCoin.Outpoint) + : _utxoLocker.TryUnlock(smartCoin.Outpoint)).ContinueWith(task => + { + // _logger.LogInformation( + // $"{(task.Result ? "Success" : "Fail")}: {(smartCoin.CoinJoinInProgress ? "" : "un")}locking coin for coinjoin: {smartCoin.Outpoint} "); + }); + } + } + } } -} +} \ No newline at end of file diff --git a/Plugins/BTCPayServer.Plugins.Wabisabi/Views/Shared/Wabisabi/WabisabiDashboard.cshtml b/Plugins/BTCPayServer.Plugins.Wabisabi/Views/Shared/Wabisabi/WabisabiDashboard.cshtml index 278f063..88b1319 100644 --- a/Plugins/BTCPayServer.Plugins.Wabisabi/Views/Shared/Wabisabi/WabisabiDashboard.cshtml +++ b/Plugins/BTCPayServer.Plugins.Wabisabi/Views/Shared/Wabisabi/WabisabiDashboard.cshtml @@ -42,7 +42,7 @@ { var settings = await WabisabiService.GetWabisabiForStore(storeId); var enabledSettings = settings.Settings.Where(coordinatorSettings => coordinatorSettings.Enabled); - var cjHistory = (await WabisabiService.GetCoinjoinHistory(storeId)).Take(10).ToList(); + var cjHistory = (await WabisabiService.GetCoinjoinHistory(storeId)).Take(5).ToList(); @if (!enabledSettings.Any()) { @@ -63,7 +63,9 @@ } else { -
+

Recent Coinjoins

@if (cjHistory.Any()) diff --git a/Plugins/BTCPayServer.Plugins.Wabisabi/Views/WabisabiStore/UpdateWabisabiStoreSettings.cshtml b/Plugins/BTCPayServer.Plugins.Wabisabi/Views/WabisabiStore/UpdateWabisabiStoreSettings.cshtml index b9b330f..22bab39 100644 --- a/Plugins/BTCPayServer.Plugins.Wabisabi/Views/WabisabiStore/UpdateWabisabiStoreSettings.cshtml +++ b/Plugins/BTCPayServer.Plugins.Wabisabi/Views/WabisabiStore/UpdateWabisabiStoreSettings.cshtml @@ -254,7 +254,7 @@ @(round.CoordinationFeeRate.Rate * 100)% @if (round.CoordinationFeeRate.PlebsDontPayThreshold > 0) { - @Safe.Raw($"+ Free under {round.CoordinationFeeRate.PlebsDontPayThreshold.ToDecimal(MoneyUnit.BTC)} BTC")
+ @Safe.Raw($"+ Free under {round.CoordinationFeeRate.PlebsDontPayThreshold.ToDecimal(MoneyUnit.BTC)} BTC") } + Free remixing diff --git a/Plugins/BTCPayServer.Plugins.Wabisabi/WabisabiPlugin.cs b/Plugins/BTCPayServer.Plugins.Wabisabi/WabisabiPlugin.cs index 4170cb6..6300d37 100644 --- a/Plugins/BTCPayServer.Plugins.Wabisabi/WabisabiPlugin.cs +++ b/Plugins/BTCPayServer.Plugins.Wabisabi/WabisabiPlugin.cs @@ -44,7 +44,7 @@ public class WabisabiPlugin : BaseBTCPayServerPlugin { public override IBTCPayServerPlugin.PluginDependency[] Dependencies { get; } = { - new() { Identifier = nameof(BTCPayServer), Condition = ">=1.7.4" } + new() { Identifier = nameof(BTCPayServer), Condition = ">=1.8" } }; public override void Execute(IServiceCollection applicationBuilder) { diff --git a/Plugins/BTCPayServer.Plugins.Wabisabi/WabisabiStoreSettings.cs b/Plugins/BTCPayServer.Plugins.Wabisabi/WabisabiStoreSettings.cs index 0ccfbb2..296ab63 100644 --- a/Plugins/BTCPayServer.Plugins.Wabisabi/WabisabiStoreSettings.cs +++ b/Plugins/BTCPayServer.Plugins.Wabisabi/WabisabiStoreSettings.cs @@ -21,7 +21,14 @@ public class WabisabiStoreSettings public bool BatchPayments { get; set; } = true; public int ExtraJoinProbability { get; set; } = 0; public bool CrossMixBetweenCoordinators { get; set; } = false; + public CrossMixMode CrossMixBetweenCoordinatorsMode { get; set; } = CrossMixMode.WhenFree; + public enum CrossMixMode + { + WhenFree, + Never, + Always, + } } public class WabisabiStoreCoordinatorSettings diff --git a/Plugins/BTCPayServer.Plugins.Wabisabi/WalletProvider.cs b/Plugins/BTCPayServer.Plugins.Wabisabi/WalletProvider.cs index ae1adf0..a6f9d2b 100644 --- a/Plugins/BTCPayServer.Plugins.Wabisabi/WalletProvider.cs +++ b/Plugins/BTCPayServer.Plugins.Wabisabi/WalletProvider.cs @@ -137,26 +137,7 @@ public class WalletProvider : PeriodicRunner,IWalletProvider .Where(wallet => wallet is not null); } - private void CoinOnPropertyChanged(object sender, PropertyChangedEventArgs e) - { - if (sender is SmartCoin smartCoin) - { - if (e.PropertyName == nameof(SmartCoin.CoinJoinInProgress)) - { - // _logger.LogInformation($"{smartCoin.Outpoint}.CoinJoinInProgress = {smartCoin.CoinJoinInProgress}"); - if (UtxoLocker is not null) - { - _ = (smartCoin.CoinJoinInProgress - ? UtxoLocker.TryLock(smartCoin.Outpoint) - : UtxoLocker.TryUnlock(smartCoin.Outpoint)).ContinueWith(task => - { - // _logger.LogInformation( - // $"{(task.Result ? "Success" : "Fail")}: {(smartCoin.CoinJoinInProgress ? "" : "un")}locking coin for coinjoin: {smartCoin.Outpoint} "); - }); - } - } - } - } + public async Task ResetWabisabiStuckPayouts() {