mirror of
https://github.com/aljazceru/BTCPayServerPlugins.git
synced 2025-12-17 15:44:26 +01:00
wb
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
**/bin/**/*
|
**/bin/**/*
|
||||||
**/obj
|
**/obj
|
||||||
.idea
|
.idea
|
||||||
|
Plugins/packed
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BTCPayServer.Plugins.AOPP",
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BTCPayServer.Plugins.LSP", "Plugins\BTCPayServer.Plugins.LSP\BTCPayServer.Plugins.LSP.csproj", "{304E4860-8420-4D71-B95A-3E2F75BEE9F6}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BTCPayServer.Plugins.LSP", "Plugins\BTCPayServer.Plugins.LSP\BTCPayServer.Plugins.LSP.csproj", "{304E4860-8420-4D71-B95A-3E2F75BEE9F6}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BTCPayServer.PluginPacker", "submodules\btcpayserver\BTCPayServer.PluginPacker\BTCPayServer.PluginPacker.csproj", "{2FDF2D41-8E75-49F6-9F4D-9E9AECE7922F}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
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-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.ActiveCfg = Release|Any CPU
|
||||||
{304E4860-8420-4D71-B95A-3E2F75BEE9F6}.Altcoins-Release|Any CPU.Build.0 = 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
|
EndGlobalSection
|
||||||
GlobalSection(NestedProjects) = preSolution
|
GlobalSection(NestedProjects) = preSolution
|
||||||
{B19C9F52-DC47-466D-8B5C-2D202B7B003F} = {9E04ECE9-E304-4FF2-9CBC-83256E6C6962}
|
{B19C9F52-DC47-466D-8B5C-2D202B7B003F} = {9E04ECE9-E304-4FF2-9CBC-83256E6C6962}
|
||||||
|
|||||||
2
BTCPayServerPlugins.sln.DotSettings.user
Normal file
2
BTCPayServerPlugins.sln.DotSettings.user
Normal 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>
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Product>Wabisabi Coinjoin</Product>
|
<Product>Wabisabi Coinjoin</Product>
|
||||||
<Description>Allows you to integrate your btcpayserver store with coinjoins.</Description>
|
<Description>Allows you to integrate your btcpayserver store with coinjoins.</Description>
|
||||||
<Version>1.0.10</Version>
|
<Version>1.0.11</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<!-- Plugin development properties -->
|
<!-- Plugin development properties -->
|
||||||
|
|||||||
@@ -5,8 +5,7 @@ using System.ComponentModel;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using BTCPayServer.Abstractions.Contracts;
|
using BTCPayServer.Abstractions.Contracts;
|
||||||
using BTCPayServer.Client.Models;
|
using BTCPayServer.Payments.PayJoin;
|
||||||
using BTCPayServer.Data;
|
|
||||||
using BTCPayServer.Services;
|
using BTCPayServer.Services;
|
||||||
using BTCPayServer.Services.Wallets;
|
using BTCPayServer.Services.Wallets;
|
||||||
using NBitcoin;
|
using NBitcoin;
|
||||||
@@ -26,25 +25,21 @@ public class Smartifier
|
|||||||
private readonly WalletRepository _walletRepository;
|
private readonly WalletRepository _walletRepository;
|
||||||
private readonly ExplorerClient _explorerClient;
|
private readonly ExplorerClient _explorerClient;
|
||||||
public DerivationStrategyBase DerivationScheme { get; }
|
public DerivationStrategyBase DerivationScheme { get; }
|
||||||
private readonly IBTCPayServerClientFactory _btcPayServerClientFactory;
|
|
||||||
private readonly string _storeId;
|
private readonly string _storeId;
|
||||||
private readonly Action<object, PropertyChangedEventArgs> _coinOnPropertyChanged;
|
private readonly IUTXOLocker _utxoLocker;
|
||||||
|
|
||||||
public Smartifier(
|
public Smartifier(
|
||||||
WalletRepository walletRepository,
|
WalletRepository walletRepository,
|
||||||
ExplorerClient explorerClient, DerivationStrategyBase derivationStrategyBase,
|
ExplorerClient explorerClient, DerivationStrategyBase derivationStrategyBase, string storeId,
|
||||||
IBTCPayServerClientFactory btcPayServerClientFactory, string storeId,
|
IUTXOLocker utxoLocker)
|
||||||
Action<object, PropertyChangedEventArgs> coinOnPropertyChanged)
|
|
||||||
{
|
{
|
||||||
_walletRepository = walletRepository;
|
_walletRepository = walletRepository;
|
||||||
_explorerClient = explorerClient;
|
_explorerClient = explorerClient;
|
||||||
DerivationScheme = derivationStrategyBase;
|
DerivationScheme = derivationStrategyBase;
|
||||||
_btcPayServerClientFactory = btcPayServerClientFactory;
|
|
||||||
_storeId = storeId;
|
_storeId = storeId;
|
||||||
_coinOnPropertyChanged = coinOnPropertyChanged;
|
_utxoLocker = utxoLocker;
|
||||||
_accountKeyPath = _explorerClient.GetMetadataAsync<RootedKeyPath>(DerivationScheme,
|
_accountKeyPath = _explorerClient.GetMetadataAsync<RootedKeyPath>(DerivationScheme,
|
||||||
WellknownMetadataKeys.AccountKeyPath);
|
WellknownMetadataKeys.AccountKeyPath);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ConcurrentDictionary<uint256, Task<TransactionInformation>> cached = new();
|
private ConcurrentDictionary<uint256, Task<TransactionInformation>> cached = new();
|
||||||
@@ -68,7 +63,6 @@ public class Smartifier
|
|||||||
|
|
||||||
foreach (var coin in coins)
|
foreach (var coin in coins)
|
||||||
{
|
{
|
||||||
var client = await _btcPayServerClientFactory.Create(null, _storeId);
|
|
||||||
var tx = await Transactions.GetOrAdd(coin.OutPoint.Hash, async uint256 =>
|
var tx = await Transactions.GetOrAdd(coin.OutPoint.Hash, async uint256 =>
|
||||||
{
|
{
|
||||||
var unsmartTx = await cached[coin.OutPoint.Hash];
|
var unsmartTx = await cached[coin.OutPoint.Hash];
|
||||||
@@ -157,11 +151,11 @@ public class Smartifier
|
|||||||
var pubKey = DerivationScheme.GetChild(coin.KeyPath).GetExtPubKeys().First().PubKey;
|
var pubKey = DerivationScheme.GetChild(coin.KeyPath).GetExtPubKeys().First().PubKey;
|
||||||
var kp = (await _accountKeyPath).Derive(coin.KeyPath).KeyPath;
|
var kp = (await _accountKeyPath).Derive(coin.KeyPath).KeyPath;
|
||||||
|
|
||||||
var hdPubKey = new HdPubKey(pubKey, kp, new SmartLabel(labels.labels?? new HashSet<string>()),
|
var hdPubKey = new HdPubKey(pubKey, kp, new SmartLabel(labels.labels ?? new HashSet<string>()),
|
||||||
current == 1 ? KeyState.Clean : KeyState.Used);
|
current == 1 ? KeyState.Clean : KeyState.Used);
|
||||||
|
|
||||||
hdPubKey.SetAnonymitySet(labels.anonset);
|
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;
|
c.PropertyChanged += CoinPropertyChanged;
|
||||||
return c;
|
return c;
|
||||||
});
|
});
|
||||||
@@ -172,6 +166,22 @@ public class Smartifier
|
|||||||
|
|
||||||
private void CoinPropertyChanged(object sender, PropertyChangedEventArgs e)
|
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} ");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
{
|
{
|
||||||
var settings = await WabisabiService.GetWabisabiForStore(storeId);
|
var settings = await WabisabiService.GetWabisabiForStore(storeId);
|
||||||
var enabledSettings = settings.Settings.Where(coordinatorSettings => coordinatorSettings.Enabled);
|
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())
|
@if (!enabledSettings.Any())
|
||||||
{
|
{
|
||||||
@@ -63,7 +63,9 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<div class="widget store-wallet-balance">
|
<div class="widget store-wallet-balance " style="
|
||||||
|
max-height: 500px;
|
||||||
|
overflow-y: auto;">
|
||||||
<header>
|
<header>
|
||||||
<h3>Recent Coinjoins</h3>
|
<h3>Recent Coinjoins</h3>
|
||||||
@if (cjHistory.Any())
|
@if (cjHistory.Any())
|
||||||
|
|||||||
@@ -254,7 +254,7 @@
|
|||||||
<td>@(round.CoordinationFeeRate.Rate * 100)%
|
<td>@(round.CoordinationFeeRate.Rate * 100)%
|
||||||
@if (round.CoordinationFeeRate.PlebsDontPayThreshold > 0)
|
@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
|
+ Free remixing
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class WabisabiPlugin : BaseBTCPayServerPlugin
|
|||||||
{
|
{
|
||||||
public override IBTCPayServerPlugin.PluginDependency[] Dependencies { get; } =
|
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)
|
public override void Execute(IServiceCollection applicationBuilder)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,7 +21,14 @@ public class WabisabiStoreSettings
|
|||||||
public bool BatchPayments { get; set; } = true;
|
public bool BatchPayments { get; set; } = true;
|
||||||
public int ExtraJoinProbability { get; set; } = 0;
|
public int ExtraJoinProbability { get; set; } = 0;
|
||||||
public bool CrossMixBetweenCoordinators { get; set; } = false;
|
public bool CrossMixBetweenCoordinators { get; set; } = false;
|
||||||
|
public CrossMixMode CrossMixBetweenCoordinatorsMode { get; set; } = CrossMixMode.WhenFree;
|
||||||
|
|
||||||
|
public enum CrossMixMode
|
||||||
|
{
|
||||||
|
WhenFree,
|
||||||
|
Never,
|
||||||
|
Always,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class WabisabiStoreCoordinatorSettings
|
public class WabisabiStoreCoordinatorSettings
|
||||||
|
|||||||
@@ -137,26 +137,7 @@ public class WalletProvider : PeriodicRunner,IWalletProvider
|
|||||||
.Where(wallet => wallet is not null);
|
.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()
|
public async Task ResetWabisabiStuckPayouts()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user