updatewabisabi

This commit is contained in:
Kukks
2023-02-19 12:57:54 +01:00
parent bf1ffe59a5
commit ec0abeac28
8 changed files with 23 additions and 41 deletions

View File

@@ -1,12 +0,0 @@
using System.Collections.Immutable;
using System.ComponentModel;
using WalletWasabi.WabiSabi.Models;
namespace WalletWasabi.Affiliation.Serialization;
public class DefaultAffiliateServersAttribute : DefaultValueAttribute
{
public DefaultAffiliateServersAttribute() : base(ImmutableDictionary<AffiliationFlag, string>.Empty)
{
}
}

View File

@@ -1,11 +0,0 @@
using System.ComponentModel;
using WalletWasabi.WabiSabi.Models;
namespace WalletWasabi.Affiliation.Serialization;
public class DefaultAffiliationFlagAttribute : DefaultValueAttribute
{
public DefaultAffiliationFlagAttribute() : base(AffiliationFlag.Default)
{
}
}

View File

@@ -42,7 +42,7 @@ public class BTCPayCoinjoinCoinSelector : IRoundCoinSelector
utxoSelectionParameters.CoordinationFeeRate); utxoSelectionParameters.CoordinationFeeRate);
var percentageLeft = (effV.ToDecimal(MoneyUnit.BTC) / coin.Amount.ToDecimal(MoneyUnit.BTC)); var percentageLeft = (effV.ToDecimal(MoneyUnit.BTC) / coin.Amount.ToDecimal(MoneyUnit.BTC));
// filter out low value coins where 50% of the value would be eaten up by fees // filter out low value coins where 50% of the value would be eaten up by fees
return effV > 0 && percentageLeft >= 0.5m; return effV > Money.Zero && percentageLeft >= 0.5m;
}) })
.Where(coin => .Where(coin =>
{ {
@@ -119,15 +119,15 @@ public class BTCPayCoinjoinCoinSelector : IRoundCoinSelector
// Sort the coins by their anon score and then by descending order their value, and then slightly randomize in 2 ways: // Sort the coins by their anon score and then by descending order their value, and then slightly randomize in 2 ways:
//attempt to shift coins that comes from the same tx AND also attempt to shift coins based on percentage probability //attempt to shift coins that comes from the same tx AND also attempt to shift coins based on percentage probability
var remainingCoins = SlightlyShiftOrder(RandomizeCoins( var remainingCoins = SlightlyShiftOrder(RandomizeCoins(
coins.OrderBy(coin => coin.CoinColor(_wallet.AnonymitySetTarget)).ThenByDescending(x => coins.OrderBy(coin => coin.CoinColor(_wallet.AnonScoreTarget)).ThenByDescending(x =>
x.EffectiveValue(utxoSelectionParameters.MiningFeeRate, x.EffectiveValue(utxoSelectionParameters.MiningFeeRate,
utxoSelectionParameters.CoordinationFeeRate)) utxoSelectionParameters.CoordinationFeeRate))
.ToList(), liquidityClue), 10); .ToList(), liquidityClue), 10);
var remainingPendingPayments = new List<PendingPayment>(pendingPayments); var remainingPendingPayments = new List<PendingPayment>(pendingPayments);
var solution = new SubsetSolution(remainingPendingPayments.Count, _wallet.AnonymitySetTarget, var solution = new SubsetSolution(remainingPendingPayments.Count, _wallet.AnonScoreTarget,
utxoSelectionParameters); utxoSelectionParameters);
if (remainingCoins.All(coin => coin.CoinColor(_wallet.AnonymitySetTarget) == AnonsetType.Green) && if (remainingCoins.All(coin => coin.CoinColor(_wallet.AnonScoreTarget) == AnonsetType.Green) &&
!remainingPendingPayments.Any()) !remainingPendingPayments.Any())
{ {
// var decidedAmt = Random.Shared.Next(10, maxCoins); // var decidedAmt = Random.Shared.Next(10, maxCoins);
@@ -179,20 +179,20 @@ public class BTCPayCoinjoinCoinSelector : IRoundCoinSelector
coinColorCount.TryGetValue(coinColor.Key, out var currentCoinColorCount); coinColorCount.TryGetValue(coinColor.Key, out var currentCoinColorCount);
if (currentCoinColorCount < coinColor.Value) if (currentCoinColorCount < coinColor.Value)
{ {
predicate = coin1 => coin1.CoinColor(_wallet.AnonymitySetTarget) == coinColor.Key; predicate = coin1 => coin1.CoinColor(_wallet.AnonScoreTarget) == coinColor.Key;
break; break;
} }
} }
else else
{ {
//if the ideal amount = 0, then we should de-prioritize. //if the ideal amount = 0, then we should de-prioritize.
predicate = coin1 => coin1.CoinColor(_wallet.AnonymitySetTarget) != coinColor.Key; predicate = coin1 => coin1.CoinColor(_wallet.AnonScoreTarget) != coinColor.Key;
break; break;
} }
} }
var coin = remainingCoins.FirstOrDefault(predicate) ?? remainingCoins.First(); var coin = remainingCoins.FirstOrDefault(predicate) ?? remainingCoins.First();
var color = coin.CoinColor(_wallet.AnonymitySetTarget); var color = coin.CoinColor(_wallet.AnonScoreTarget);
// If the selected coins list is at its maximum size, break out of the loop // If the selected coins list is at its maximum size, break out of the loop
if (solution.Coins.Count == maxCoins) if (solution.Coins.Count == maxCoins)
{ {
@@ -201,7 +201,7 @@ public class BTCPayCoinjoinCoinSelector : IRoundCoinSelector
remainingCoins.Remove(coin); remainingCoins.Remove(coin);
if (maxPerType.TryGetValue(color, out var maxColor) && if (maxPerType.TryGetValue(color, out var maxColor) &&
solution.Coins.Count(coin1 => coin1.CoinColor(_wallet.AnonymitySetTarget) == color) == maxColor) solution.Coins.Count(coin1 => coin1.CoinColor(_wallet.AnonScoreTarget) == color) == maxColor)
{ {
continue; continue;
} }
@@ -280,7 +280,7 @@ public class BTCPayCoinjoinCoinSelector : IRoundCoinSelector
var currentCoin = remainingCoins.First(); var currentCoin = remainingCoins.First();
remainingCoins.RemoveAt(0); remainingCoins.RemoveAt(0);
var lastCoin = workingList.LastOrDefault(); var lastCoin = workingList.LastOrDefault();
if (lastCoin is null || currentCoin.CoinColor(_wallet.AnonymitySetTarget) == AnonsetType.Green || if (lastCoin is null || currentCoin.CoinColor(_wallet.AnonScoreTarget) == AnonsetType.Green ||
!remainingCoins.Any() || !remainingCoins.Any() ||
(remainingCoins.Count == 1 && remainingCoins.First().TransactionId == currentCoin.TransactionId) || (remainingCoins.Count == 1 && remainingCoins.First().TransactionId == currentCoin.TransactionId) ||
lastCoin.TransactionId != currentCoin.TransactionId || lastCoin.TransactionId != currentCoin.TransactionId ||

View File

@@ -108,7 +108,7 @@ public class BTCPayWallet : IWallet, IDestinationProvider
public IKeyChain KeyChain { get; } public IKeyChain KeyChain { get; }
public IDestinationProvider DestinationProvider => this; public IDestinationProvider DestinationProvider => this;
public int AnonymitySetTarget => WabisabiStoreSettings.PlebMode? 2: WabisabiStoreSettings.AnonymitySetTarget; public int AnonScoreTarget => WabisabiStoreSettings.PlebMode? 2: WabisabiStoreSettings.AnonymitySetTarget;
public bool ConsolidationMode => !WabisabiStoreSettings.PlebMode && WabisabiStoreSettings.ConsolidationMode; public bool ConsolidationMode => !WabisabiStoreSettings.PlebMode && WabisabiStoreSettings.ConsolidationMode;
public TimeSpan FeeRateMedianTimeFrame { get; } = TimeSpan.FromHours(KeyManager.DefaultFeeRateMedianTimeFrameHours); public TimeSpan FeeRateMedianTimeFrame { get; } = TimeSpan.FromHours(KeyManager.DefaultFeeRateMedianTimeFrameHours);
public bool RedCoinIsolation => !WabisabiStoreSettings.PlebMode &&WabisabiStoreSettings.RedCoinIsolation; public bool RedCoinIsolation => !WabisabiStoreSettings.PlebMode &&WabisabiStoreSettings.RedCoinIsolation;
@@ -121,7 +121,7 @@ public class BTCPayWallet : IWallet, IDestinationProvider
public async Task<double> GetPrivacyPercentageAsync() public async Task<double> GetPrivacyPercentageAsync()
{ {
return GetPrivacyPercentage(await GetAllCoins(), AnonymitySetTarget); return GetPrivacyPercentage(await GetAllCoins(), AnonScoreTarget);
} }
public async Task<CoinsView> GetAllCoins() public async Task<CoinsView> GetAllCoins()

View File

@@ -91,10 +91,10 @@
var wallet = (BTCPayWallet) await WalletProvider.GetWalletAsync(storeId); var wallet = (BTCPayWallet) await WalletProvider.GetWalletAsync(storeId);
var coins = await wallet.GetAllCoins(); var coins = await wallet.GetAllCoins();
var privacy = wallet.GetPrivacyPercentage(coins, wallet.AnonymitySetTarget); var privacy = wallet.GetPrivacyPercentage(coins, wallet.AnonScoreTarget);
var privacyPercentage = Math.Round(privacy * 100); var privacyPercentage = Math.Round(privacy * 100);
var colorCoins = coins.GroupBy(coin => coin.CoinColor(wallet.AnonymitySetTarget)).ToDictionary(grouping => grouping.Key, grouping => grouping); var colorCoins = coins.GroupBy(coin => coin.CoinColor(wallet.AnonScoreTarget)).ToDictionary(grouping => grouping.Key, grouping => grouping);
<div class="widget store-numbers" > <div class="widget store-numbers" >
@if (wallet is BTCPayWallet btcPayWallet) @if (wallet is BTCPayWallet btcPayWallet)

View File

@@ -63,9 +63,12 @@
.Select(pair => new SelectListItem(pair.Value.Result, pair.Key, Model.MixToOtherWallet == pair.Key)).Prepend(new SelectListItem("None", "")); .Select(pair => new SelectListItem(pair.Value.Result, pair.Key, Model.MixToOtherWallet == pair.Key)).Prepend(new SelectListItem("None", ""));
} }
<div class="row">
<h2 class="mb-4">Coinjoin configuration</h2> <h2 class="">Coinjoin configuration</h2>
<a href="https://github.com/Kukks/BTCPayServerPlugins/blob/master/Plugins/BTCPayServer.Plugins.Wabisabi/readme.md" class="ms-1" target="_blank" rel="noreferrer noopener">
<span class="fa fa-question-circle-o text-secondary" title="More information..."></span>
</a>
<span class="fa fa-question-circle-o text-secondary" title="More information..."></span></div>
<form method="post"> <form method="post">
@{ @{
var wallet = await WalletProvider.GetWalletAsync(storeId); var wallet = await WalletProvider.GetWalletAsync(storeId);

View File

@@ -1,4 +1,6 @@
@using BTCPayServer.Abstractions.Extensions @using BTCPayServer.Abstractions.Extensions
@inject BTCPayServer.Abstractions.Services.Safe Safe
@addTagHelper *, BTCPayServer.Abstractions @addTagHelper *, BTCPayServer.Abstractions
@addTagHelper *, BTCPayServer.TagHelpers
@addTagHelper *, BTCPayServer.Views.TagHelpers
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers