Changeset View
Changeset View
Standalone View
Standalone View
src/amount.h
Show First 20 Lines • Show All 148 Lines • ▼ Show 20 Lines | public: | ||||
// serialization support | // serialization support | ||||
SERIALIZE_METHODS(Amount, obj) { READWRITE(obj.amount); } | SERIALIZE_METHODS(Amount, obj) { READWRITE(obj.amount); } | ||||
}; | }; | ||||
static constexpr Amount SATOSHI = Amount::satoshi(); | static constexpr Amount SATOSHI = Amount::satoshi(); | ||||
static constexpr Amount CASH = 100 * SATOSHI; | static constexpr Amount CASH = 100 * SATOSHI; | ||||
static constexpr Amount COIN = 100000000 * SATOSHI; | static constexpr Amount COIN = 100000000 * SATOSHI; | ||||
struct Currency { | |||||
Amount baseunit, subunit; | |||||
Fabien: Nit: Place on their own line (with a description comment maybe ?) so when touching one you… | |||||
uint8_t decimals; | |||||
static const Currency &get(); | |||||
}; | |||||
/** | /** | ||||
* No amount larger than this (in satoshi) is valid. | * No amount larger than this (in satoshi) is valid. | ||||
* | * | ||||
* Note that this constant is *not* the total money supply, which in Bitcoin | * Note that this constant is *not* the total money supply, which in Bitcoin | ||||
* currently happens to be less than 21,000,000 BCH for various reasons, but | * currently happens to be less than 21,000,000 BCH for various reasons, but | ||||
* rather a sanity check. As this sanity check is used by consensus-critical | * 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 | * validation code, the exact value of the MAX_MONEY constant is consensus | ||||
* critical; in unusual circumstances like a(nother) overflow bug that allowed | * 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. | * for the creation of coins out of thin air modification could lead to a fork. | ||||
*/ | */ | ||||
static const Amount MAX_MONEY = 21000000 * COIN; | static const Amount MAX_MONEY = 21000000 * COIN; | ||||
inline bool MoneyRange(const Amount nValue) { | inline bool MoneyRange(const Amount nValue) { | ||||
return nValue >= Amount::zero() && nValue <= MAX_MONEY; | return nValue >= Amount::zero() && nValue <= MAX_MONEY; | ||||
} | } | ||||
#endif // BITCOIN_AMOUNT_H | #endif // BITCOIN_AMOUNT_H |
Nit: Place on their own line (with a description comment maybe ?) so when touching one you don't touch the other