Elevate out MaximumNumberOfSatoshis to Constants
MODIFY
MagicalCryptoWallet/Helpers/Constants.cs
MagicalCryptoWallet/Helpers/Constants.cs
@@ -9,5 +9,8 @@ namespace MagicalCryptoWallet.Helpers
public const int P2wpkhInputSizeInBytes = 41;
public const int P2pkhInputSizeInBytes = 146;
public const int OutputSizeInBytes = 33;
+ // https://en.bitcoin.it/wiki/Bitcoin
+ // 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;
}
}

MODIFY
MagicalCryptoWallet/Services/WalletService.cs
MagicalCryptoWallet/Services/WalletService.cs
@@ -474,11 +474,9 @@ namespace MagicalCryptoWallet.Services
}
long sum = toSend.Sum(x => x.Amount);
- if (sum < 0 || sum > 2099999997690000)
+ if (sum < 0 || sum > Constants.MaximumNumberOfSatoshis)
{
- // https://en.bitcoin.it/wiki/Bitcoin
- // 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.
- throw new ArgumentOutOfRangeException($"{nameof(toSend)} sum cannot be smaller than 0 or greater than 2099999997690000.");
+ throw new ArgumentOutOfRangeException($"{nameof(toSend)} sum cannot be smaller than 0 or greater than {Constants.MaximumNumberOfSatoshis}.");
}
int spendAllCount = toSend.Count(x => x.Amount == Money.Zero);

Elevate out MaximumNumberOfSatoshis to Constants