Skip to content

Commit

Permalink
Merge pull request qtumproject#13 from qtumproject/time/QTUMCORE-31
Browse files Browse the repository at this point in the history
Update the maximum amount of coins
  • Loading branch information
qtum-neil authored Mar 29, 2017
2 parents 3f731c8 + 6639bfc commit 7592ead
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
12 changes: 2 additions & 10 deletions src/amount.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,8 @@ static const CAmount CENT = 1000000;

extern const std::string CURRENCY_UNIT;

/** No amount larger than this (in satoshi) is valid.
*
* Note that this constant is *not* the total money supply, which in Bitcoin
* currently happens to be less than 21,000,000 BTC for various reasons, but
* rather a sanity check. As this sanity check is used by consensus-critical
* validation code, the exact value of the MAX_MONEY constant is consensus
* critical; in unusual circumstances like a(nother) overflow bug that allowed
* for the creation of coins out of thin air modification could lead to a fork.
* */
static const CAmount MAX_MONEY = 21000000 * COIN;
/** No amount larger than this (in satoshi) is valid.*/
static const CAmount MAX_MONEY = 107822406 * COIN + 25 * CENT;
inline bool MoneyRange(const CAmount& nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }

/**
Expand Down
4 changes: 2 additions & 2 deletions src/test/compress_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
// amounts 1 .. 10000
#define NUM_MULTIPLES_1BTC 10000

// amounts 50 .. 21000000
#define NUM_MULTIPLES_50BTC 420000
// amounts 50 .. 100000000
#define NUM_MULTIPLES_50BTC 2000000

BOOST_FIXTURE_TEST_SUITE(compress_tests, BasicTestingSetup)

Expand Down
10 changes: 6 additions & 4 deletions src/test/rpc_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,9 @@ BOOST_AUTO_TEST_CASE(rpc_format_monetary_values)
BOOST_CHECK(ValueFromAmount(50000000LL).write() == "0.50000000");
BOOST_CHECK(ValueFromAmount(89898989LL).write() == "0.89898989");
BOOST_CHECK(ValueFromAmount(100000000LL).write() == "1.00000000");
BOOST_CHECK(ValueFromAmount(2099999999999990LL).write() == "20999999.99999990");
BOOST_CHECK(ValueFromAmount(2099999999999999LL).write() == "20999999.99999999");
BOOST_CHECK(ValueFromAmount(10782240624999990LL).write() == "107822406.24999990");
BOOST_CHECK(ValueFromAmount(10782240624999999LL).write() == "107822406.24999999");
BOOST_CHECK(ValueFromAmount(10782240625000000LL).write() == "107822406.25000000");

BOOST_CHECK_EQUAL(ValueFromAmount(0).write(), "0.00000000");
BOOST_CHECK_EQUAL(ValueFromAmount((COIN/10000)*123456789).write(), "12345.67890000");
Expand Down Expand Up @@ -194,8 +195,9 @@ BOOST_AUTO_TEST_CASE(rpc_parse_monetary_values)
BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.50000000")), 50000000LL);
BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.89898989")), 89898989LL);
BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("1.00000000")), 100000000LL);
BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("20999999.9999999")), 2099999999999990LL);
BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("20999999.99999999")), 2099999999999999LL);
BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("107822406.2499999")), 10782240624999990LL);
BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("107822406.24999999")), 10782240624999999LL);
BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("107822406.25")), 10782240625000000LL);

BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("1e-8")), COIN/100000000);
BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.1e-7")), COIN/100000000);
Expand Down

0 comments on commit 7592ead

Please sign in to comment.