Round max amount to 20999999.9769
MODIFY
WalletWasabi.Tests/UnitTests/Userfacing/BitcoinInputTests.cs
WalletWasabi.Tests/UnitTests/Userfacing/BitcoinInputTests.cs
@@ -22,6 +22,8 @@ namespace WalletWasabi.Tests.UnitTests
[InlineData("20999999", false, null)]
[InlineData("2.1", false, null)]
[InlineData("1.11111111", false, null)]
+ [InlineData("1.00000001", false, null)]
+ [InlineData("20999999.9769", false, null)]
[InlineData(" ", true, "")]
[InlineData(" ", true, "")]
[InlineData("abc", true, "")]
@@ -54,9 +56,19 @@ namespace WalletWasabi.Tests.UnitTests
[InlineData("00", true, "0")]
[InlineData("0 0", true, "0")]
[InlineData("001.", true, "1.")]
- [InlineData("20999999.97690001", true, "20999999")]
- [InlineData("30999999", true, "20999999")]
- [InlineData("303333333333333333999999", true, "20999999")]
+ [InlineData("20999999.97690001", true, "20999999.9769")]
+ [InlineData("30999999", true, "20999999.9769")]
+ [InlineData("303333333333333333999999", true, "20999999.9769")]
+ [InlineData("20999999.977", true, "20999999.9769")]
+ [InlineData("209999990.9769", true, "20999999.9769")]
+ [InlineData("20999999.976910000000000", true, "20999999.9769")]
+ [InlineData("209999990000000000.97000000000069", true, "20999999.9769")]
+ [InlineData("1.000000001", true, "1.00000000")]
+ [InlineData("20999999.97000000000069", true, "20999999.97000000")]
+ [InlineData("00....1...,a", true, "")]
+ [InlineData("0...1.", true, "")]
+ [InlineData("1...1.", true, "")]
+ [InlineData("1.s.1...1.", true, "")]
public void CorrectAmountText(string amount, bool expectedResult, string expectedCorrection)
{
var result = BitcoinInput.TryCorrectAmount(amount, out var correction);

MODIFY
WalletWasabi/Helpers/Constants.cs
WalletWasabi/Helpers/Constants.cs
@@ -29,7 +29,7 @@ namespace WalletWasabi.Helpers
// There are a maximum of 2,099,999,997,690,000 Bitcoin elements (called satoshis), which are currently most commonly measured in units of 100,000,000 known as BTC. Stated another way, no more than 21 million BTC can ever be created.
public const long MaximumNumberOfSatoshis = 2099999997690000;
- public const long MaximumNumberOfWholeBitcoins = 20999999;
+ public const decimal MaximumNumberOfBitcoins = 20999999.9769m;
public const int TwentyMinutesConfirmationTarget = 2;
public const int OneDayConfirmationTarget = 144;

MODIFY
WalletWasabi/Userfacing/BitcoinInput.cs
WalletWasabi/Userfacing/BitcoinInput.cs
@@ -81,10 +81,9 @@ namespace WalletWasabi.Helpers
}
// Make sure you don't send more bitcoins than how much there is in existence.
- var btc = corrected.Split('.').First();
- if (btc.Length != 0 && (!long.TryParse(btc, out long btcLong) || btcLong >= Constants.MaximumNumberOfWholeBitcoins))
+ if (corrected.Length != 0 && corrected != "." && (!decimal.TryParse(corrected, out decimal btcDecimal) || btcDecimal > Constants.MaximumNumberOfBitcoins))
{
- corrected = Constants.MaximumNumberOfWholeBitcoins.ToString();
+ corrected = Constants.MaximumNumberOfBitcoins.ToString();
}
if (corrected != original)

Round max amount to 20999999.9769