PRCYCoin  2.0.0.7rc1
P2P Digital Currency
amount.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2014 The Bitcoin developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef BITCOIN_AMOUNT_H
7 #define BITCOIN_AMOUNT_H
8 
9 #include "serialize.h"
10 
11 #include <stdlib.h>
12 #include <string>
13 
14 extern const std::string CURRENCY_UNIT;
15 
17 typedef int64_t CAmount;
18 
19 static const CAmount COIN = 100000000;
20 static const CAmount CENT = 1000000;
21 static const CAmount MIN_FEE = COIN / 10000;
22 static const CAmount MAX_FEE = COIN / 100;
23 
33 static const CAmount MAX_MONEY_OUT = 70000000 * COIN;
34 inline bool MoneyRange(const CAmount& nValue) { return (nValue >= 0 && nValue <= MAX_MONEY_OUT); }
35 
39 class CFeeRate
40 {
41 private:
42  CAmount nSatoshisPerK; // unit is satoshis-per-1,000-bytes
43 public:
45  explicit CFeeRate(const CAmount& _nSatoshisPerK) : nSatoshisPerK(_nSatoshisPerK) {}
46  CFeeRate(const CAmount& nFeePaid, size_t nSize);
47  CFeeRate(const CFeeRate& other) { nSatoshisPerK = other.nSatoshisPerK; }
48 
49  CAmount GetFee(size_t size) const; // unit returned is satoshis
50  CAmount GetFeePerK() const { return GetFee(1000); } // satoshis-per-1000-bytes
51 
52  friend bool operator<(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK < b.nSatoshisPerK; }
53  friend bool operator>(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK > b.nSatoshisPerK; }
54  friend bool operator==(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK == b.nSatoshisPerK; }
55  friend bool operator<=(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK <= b.nSatoshisPerK; }
56  friend bool operator>=(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK >= b.nSatoshisPerK; }
57  std::string ToString() const;
58 
60 
61  template <typename Stream, typename Operation>
62  inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion)
63  {
65  }
66 };
67 
68 #endif // BITCOIN_AMOUNT_H
b
void const uint64_t * b
Definition: field_5x52_asm_impl.h:10
CFeeRate::operator>
friend bool operator>(const CFeeRate &a, const CFeeRate &b)
Definition: amount.h:53
CFeeRate::SerializationOp
void SerializationOp(Stream &s, Operation ser_action, int nType, int nVersion)
Definition: amount.h:62
CFeeRate::CFeeRate
CFeeRate(const CAmount &_nSatoshisPerK)
Definition: amount.h:45
MoneyRange
bool MoneyRange(const CAmount &nValue)
Definition: amount.h:34
CFeeRate::operator>=
friend bool operator>=(const CFeeRate &a, const CFeeRate &b)
Definition: amount.h:56
CFeeRate::operator<=
friend bool operator<=(const CFeeRate &a, const CFeeRate &b)
Definition: amount.h:55
CFeeRate
Fee rate in PRCY per kilobyte: CAmount / kB.
Definition: amount.h:39
CFeeRate::nSatoshisPerK
CAmount nSatoshisPerK
Definition: amount.h:42
CFeeRate::ADD_SERIALIZE_METHODS
ADD_SERIALIZE_METHODS
Definition: amount.h:59
CAmount
int64_t CAmount
Amount in PRCY (Can be negative)
Definition: amount.h:17
CFeeRate::CFeeRate
CFeeRate(const CFeeRate &other)
Definition: amount.h:47
CFeeRate::operator<
friend bool operator<(const CFeeRate &a, const CFeeRate &b)
Definition: amount.h:52
READWRITE
#define READWRITE(obj)
Definition: serialize.h:164
CURRENCY_UNIT
const std::string CURRENCY_UNIT
Definition: amount.cpp:10
CFeeRate::ToString
std::string ToString() const
Definition: amount.cpp:30
serialize.h
CFeeRate::CFeeRate
CFeeRate()
Definition: amount.h:44
CFeeRate::operator==
friend bool operator==(const CFeeRate &a, const CFeeRate &b)
Definition: amount.h:54
CFeeRate::GetFee
CAmount GetFee(size_t size) const
Definition: amount.cpp:20
CFeeRate::GetFeePerK
CAmount GetFeePerK() const
Definition: amount.h:50