This commit is contained in:
Kukks
2023-02-02 10:13:06 +01:00
parent 9e67a6ee06
commit 38199cc751
10 changed files with 53 additions and 40 deletions

1
.gitignore vendored
View File

@@ -1,3 +1,4 @@
**/bin/**/*
**/obj
.idea
Plugins/packed

View File

@@ -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}

View File

@@ -0,0 +1,2 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UnloadedProject/UnloadedProjects/=b4e2ed08_002D4ad3_002D4648_002D8bdb_002D3107200460b9_0023BTCPayServer_002EPlugins_002ELiquidPlus/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

View File

@@ -13,7 +13,7 @@
<PropertyGroup>
<Product>Wabisabi Coinjoin</Product>
<Description>Allows you to integrate your btcpayserver store with coinjoins.</Description>
<Version>1.0.10</Version>
<Version>1.0.11</Version>
</PropertyGroup>
<!-- Plugin development properties -->

View File

@@ -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<object, PropertyChangedEventArgs> _coinOnPropertyChanged;
private readonly IUTXOLocker _utxoLocker;
public Smartifier(
WalletRepository walletRepository,
ExplorerClient explorerClient, DerivationStrategyBase derivationStrategyBase,
IBTCPayServerClientFactory btcPayServerClientFactory, string storeId,
Action<object, PropertyChangedEventArgs> 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<RootedKeyPath>(DerivationScheme,
WellknownMetadataKeys.AccountKeyPath);
}
private ConcurrentDictionary<uint256, Task<TransactionInformation>> 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];
@@ -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} ");
});
}
}
}
}
}

View File

@@ -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
{
<div class="widget store-wallet-balance">
<div class="widget store-wallet-balance " style="
max-height: 500px;
overflow-y: auto;">
<header>
<h3>Recent Coinjoins</h3>
@if (cjHistory.Any())

View File

@@ -254,7 +254,7 @@
<td>@(round.CoordinationFeeRate.Rate * 100)%
@if (round.CoordinationFeeRate.PlebsDontPayThreshold > 0)
{
@Safe.Raw($"+ Free under {round.CoordinationFeeRate.PlebsDontPayThreshold.ToDecimal(MoneyUnit.BTC)} BTC")<br/>
@Safe.Raw($"+ Free under {round.CoordinationFeeRate.PlebsDontPayThreshold.ToDecimal(MoneyUnit.BTC)} BTC")
}
+ Free remixing
</td>

View File

@@ -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)
{

View File

@@ -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

View File

@@ -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()
{