Do not regenerate denominations
RENAME
WalletWasabi.Tests/UnitTests/WabiSabi/Models/AmountDecompositionTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Models/StandardDenominationsTests.cs
-using NBitcoin;
using System.Linq;
using WalletWasabi.WabiSabi.Models.Decomposition;
using Xunit;
namespace WalletWasabi.Tests.UnitTests.WabiSabi.Models
{
- public class AmountDecompositionTests
+ public class StandardDenominationsTests
{
[Fact]
public void BaseDenomGeneratorTest()
{
- var denoms = BaseDenominationGenerator.Generate();
+ var denoms = StandardDenomination.Values;
Assert.Equal(157, denoms.Count());
Assert.Equal(denoms, denoms.Distinct());

DELETE
WalletWasabi/WabiSabi/Models/Decomposition/BaseDenomGenerator.cs
-using NBitcoin;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using WalletWasabi.Helpers;
-
-namespace WalletWasabi.WabiSabi.Models.Decomposition
-{
- public static class BaseDenominationGenerator
- {
- private static Money MaxSats = Money.Satoshis(Constants.MaximumNumberOfSatoshis);
-
- private static IEnumerable<Money> Multiple(IEnumerable<long> coefficients, IEnumerable<long> values) =>
- values.SelectMany(v => coefficients.Select(c => Money.Satoshis(c * v))).Where(x => x <= MaxSats);
-
- public static IEnumerable<Money> Generate()
- {
- var powersOfTwo = Enumerable.Range(0, 50).Select(x => (long)1m << x);
- var powersOfThree = Enumerable.Range(0, 32).Select(x => (long)Math.Pow(3, x));
- var powersOfTen = Enumerable.Range(0, 16).Select(x => (long)Math.Pow(10, x));
-
- var ternary = Multiple(new long[] { 1, 2 }, powersOfThree);
- var preferredValueSeries = Multiple(new long[] { 1, 2, 5 }, powersOfTen);
-
- return powersOfTwo
- .Select(x => Money.Satoshis(x))
- .Union(ternary)
- .Union(preferredValueSeries)
- .OrderBy(v => v);
- }
- }
-}

ADD
WalletWasabi/WabiSabi/Models/Decomposition/StandardDenomination.cs
+using NBitcoin;
+using System;
+using System.Collections.Generic;
+using System.Collections.Immutable;
+using System.Linq;
+
+namespace WalletWasabi.WabiSabi.Models.Decomposition
+{
+ public static class StandardDenomination
+ {
+ public static readonly ImmutableArray<Money> Values = Generate().ToImmutableArray();
+
+ private static IEnumerable<long> Multiple(IEnumerable<long> coefficients, IEnumerable<long> values) =>
+ values
+ .SelectMany(c => coefficients, (v, c) => c * v)
+ .TakeWhile(x => x < ProtocolConstants.MaxAmountPerAlice);
+
+ private static IEnumerable<long> PowersOf(int b) =>
+ Enumerable
+ .Range(0, int.MaxValue)
+ .Select(x => (long)Math.Pow(b, x))
+ .TakeWhile(x => x < ProtocolConstants.MaxAmountPerAlice);
+
+ private static IEnumerable<Money> Generate()
+ {
+ var ternary = Multiple(new long[] { 1, 2 }, PowersOf(3));
+ var preferredValueSeries = Multiple(new long[] { 1, 2, 5 }, PowersOf(10));
+
+ return PowersOf(2)
+ .Union(ternary)
+ .Union(preferredValueSeries)
+ .OrderBy(v => v)
+ .Select(Money.Satoshis);
+ }
+ }
+}

Do not regenerate denominations