ws coin select

This commit is contained in:
Kukks
2024-03-28 05:52:20 +01:00
parent 2684c3d3ea
commit 930b3e568f
2 changed files with 21 additions and 21 deletions

View File

@@ -13,7 +13,7 @@
<PropertyGroup> <PropertyGroup>
<Product>Coinjoin</Product> <Product>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.74</Version> <Version>1.0.75</Version>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup> </PropertyGroup>

View File

@@ -446,29 +446,29 @@ namespace BTCPayServer.Plugins.Wabisabi
} }
// coinSelect: coinSelect:
var selectedCoinSum = selectedCoins.Sum(coin => ((Money)coin.Amount).ToDecimal(MoneyUnit.BTC)); var selectedCoinSum = selectedCoins.Sum(coin => ((Money)coin.Amount).ToDecimal(MoneyUnit.BTC));
var remaining = amount - selectedCoinSum; var remaining = amount - selectedCoinSum;
var remainingCoins = coins.FilterBy(coin => !selectedCoins.Contains(coin.Coin)).Available().ToList(); var remainingCoins = coins.FilterBy(coin => !selectedCoins.Contains(coin.Coin)).Available().ToList();
// if (remaining > 0 && remainingCoins.Any()) if (remaining > 0 && remainingCoins.Any())
// { {
// //try to select the closest coin to the remaining amount while also prioritizing privacy //try to select the closest coin to the remaining amount while also prioritizing privacy
// //so filter rby the highest anonymity set first and then by closest amount //so filter rby the highest anonymity set first and then by closest amount
// var closestCoin = remainingCoins var closestCoin = remainingCoins
// .OrderByDescending(coin => coin.AnonymitySet) .OrderByDescending(coin => coin.AnonymitySet)
// .ThenBy(coin => Math.Abs(coin.Amount.ToDecimal(MoneyUnit.BTC) - remaining)) .ThenBy(coin => Math.Abs(coin.Amount.ToDecimal(MoneyUnit.BTC) - remaining))
// .FirstOrDefault(); .FirstOrDefault();
// if (closestCoin is not null) if (closestCoin is not null)
// { {
// selectedCoins.Add(closestCoin.Coin); selectedCoins.Add(closestCoin.Coin);
// remainingCoins.Remove(closestCoin); remainingCoins.Remove(closestCoin);
//
// goto coinSelect; goto coinSelect;
// } }
//
// } }
//
// return Ok(selectedCoins.Select(coin => coin.Outpoint.ToString()).ToArray()); return Ok(selectedCoins.Select(coin => coin.Outpoint.ToString()).ToArray());
var defaultCoinSelector = new DefaultCoinSelector(); var defaultCoinSelector = new DefaultCoinSelector();
var defaultSelection = var defaultSelection =